From f8a6deefefc459c9e9fe0eb79345bb21ca34ca94 Mon Sep 17 00:00:00 2001 From: Adrian del Campo <107918259+adriancampo@users.noreply.github.com> Date: Tue, 16 Apr 2024 14:58:33 +0200 Subject: [PATCH] Update xtypes 1.3 doc (#730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #20359: Updates for xtypes1.3. Removed TypeLookupSettings. Removed auto_fill_typeonject. Renamede discovery methods. Added typelookup_service_threads. Signed-off-by: adriancampo * Refs #20359: Updates fastddsgen args. Removed TypeObjectFactory. Removed on_type_discovery, on_type_dependencies_reply, on_type_information_received, register_remote_type. Updated references to DDS-XTypes V1.3. Signed-off-by: adriancampo * Refs #20359: DDSCodeTester updates for DynamicTypes and discovery callbacks Signed-off-by: adriancampo * Refs #20359: Updated xtypes doc. Signed-off-by: adriancampo * Refs #20359: Applied first suggestions. Signed-off-by: adriancampo * Refs #20359: Updates to discovery and endpoint matching. Signed-off-by: adriancampo * Refs #20359: Apply suggestions from code review Co-authored-by: Ricardo González Signed-off-by: adriancampo * Refs #20359: Regenerated example types. Removed classes after monitor service refactor. Signed-off-by: adriancampo * Refs #20631: apply review suggestions to Fast DDS-Gen usage Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: inheritance not yet supported with XML. Use correct typelookup service thread name Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: fix tests: trailing whitespaces Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: fix spelling Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: migrate to list tables and use proper C++ types Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: rewrite XTypes introduction section Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: rewrite remote data type discovery section Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: implement pending TODO Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: rewrite XTypes sections and related information Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: apply remaining suggestions Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: regenerate example types Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: little block comment Signed-off-by: Ricardo González Moreno * Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima * Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima --------- Signed-off-by: adriancampo Signed-off-by: JLBuenoLopez-eProsima Signed-off-by: Ricardo González Moreno Co-authored-by: Ricardo González Co-authored-by: JLBuenoLopez-eProsima Signed-off-by: eduponz --- code/CodeTester.cpp | 719 +-------- code/DDSCodeTester.cpp | 1423 ++++++++++++++--- code/DynamicTypesIDLExamples.idl | 204 +++ .../C++/DDSHelloWorld/src/HelloWorld.cxx | 168 -- .../src/{HelloWorld.h => HelloWorld.hpp} | 124 +- .../DDSHelloWorld/src/HelloWorldCdrAux.hpp | 4 +- .../DDSHelloWorld/src/HelloWorldCdrAux.ipp | 2 - .../src/HelloWorldPubSubTypes.cxx | 14 +- .../DDSHelloWorld/src/HelloWorldPubSubTypes.h | 7 +- .../src/HelloWorldSubscriber.cpp | 16 +- .../src/HelloWorldTypeObjectSupport.cxx | 248 +++ .../src/HelloWorldTypeObjectSupport.hpp | 54 + .../C++/DDSHelloWorld/src/HelloWorldv1.cxx | 286 ---- .../C++/DDSHelloWorld/src/HelloWorldv1.h | 244 --- code/XMLTester.xml | 192 ++- code/XMLTesterExample.xml | 21 +- .../listeners_inheritance_diagram.svg | 804 +++++++++- docs/03-exports/aliases-api.include | 72 +- docs/03-exports/aliases.include | 63 +- .../fastdds/api_reference/dds_pim/dds_pim.rst | 1 + .../api_reference/dds_pim/topic/topic.rst | 2 - .../api_reference/dds_pim/topic/typeidv1.rst | 11 - .../dds_pim/topic/typeinformation.rst | 8 +- .../dds_pim/topic/typeobjectv1.rst | 11 - .../dds_pim/xtypes/annotationdescriptor.rst | 10 + .../dds_pim/xtypes/dynamic_types.rst | 18 + .../dds_pim/xtypes/dynamicdata.rst | 10 + .../dds_pim/xtypes/dynamicdatafactory.rst | 10 + .../dds_pim/xtypes/dynamicpubsubtype.rst | 10 + .../dds_pim/xtypes/dynamictype.rst | 10 + .../dds_pim/xtypes/dynamictypebuilder.rst | 10 + .../xtypes/dynamictypebuilderfactory.rst | 10 + .../dds_pim/xtypes/dynamictypemember.rst | 10 + .../dds_pim/xtypes/exception.rst | 10 + .../dds_pim/xtypes/memberdescriptor.rst | 10 + .../dds_pim/xtypes/type_representation.rst | 7 + .../dds_pim/xtypes/typedescriptor.rst | 10 + .../dds_pim/xtypes/typeobjectregistry.rst | 10 + .../dds_pim/xtypes/typeobjectutils.rst | 10 + .../dds_pim/xtypes/verbatimtextdescriptor.rst | 10 + .../api_reference/dds_pim/xtypes/xtypes.rst | 8 + .../rtps/attributes/TypeLookupSettings.rst | 8 - .../rtps/attributes/attributes.rst | 1 - .../api_reference/spelling_wordlist.txt | 111 ++ docs/fastdds/dds_layer/core/entity/entity.rst | 7 +- .../core/policy/xtypesExtensions.rst | 4 +- .../domainParticipant/domainParticipant.rst | 3 + .../domainParticipantListener.rst | 19 +- .../createContentFilteredTopic.rst | 4 +- .../dds_layer/topic/fastddsgen/fastddsgen.rst | 22 +- docs/fastdds/discovery/disc_callbacks.rst | 7 +- docs/fastdds/dynamic_types/annotations.rst | 63 - docs/fastdds/dynamic_types/complex_types.rst | 85 - docs/fastdds/dynamic_types/concepts.rst | 188 --- docs/fastdds/dynamic_types/discovery.rst | 183 --- docs/fastdds/dynamic_types/dynamic_types.rst | 27 - docs/fastdds/dynamic_types/examples.rst | 51 - .../dynamic_types/memory_management.rst | 34 - docs/fastdds/dynamic_types/serialization.rst | 16 - .../fastdds/dynamic_types/supported_types.rst | 321 ---- docs/fastdds/dynamic_types/xml_profiles.rst | 17 - .../simple_app/includes/dataType.rst | 5 +- .../simple_app/includes/workspace.rst | 7 +- .../simple_python_app/includes/dataType.rst | 5 +- .../simple_python_app/includes/workspace.rst | 5 +- .../simple_python_app/simple_python_app.rst | 1 + .../library_overview/includes/exec_model.rst | 39 +- .../remote_type_discovery_matching.rst | 69 + .../rosbag_capture/rosbag_capture.rst | 14 +- docs/fastdds/use_cases/use_cases.rst | 5 + .../xml_configuration/domainparticipant.rst | 34 +- .../xml_configuration/dynamic_types.rst | 547 ++++--- docs/fastdds/xtypes/discovery_matching.rst | 81 + docs/fastdds/xtypes/language_binding.rst | 1010 ++++++++++++ docs/fastdds/xtypes/xtypes.rst | 30 + docs/fastddsgen/dataTypes/dataTypes.rst | 183 ++- .../pubsub_app/includes/workspace.rst | 7 +- docs/fastddsgen/usage/usage.rst | 36 +- docs/index.rst | 2 +- docs/notes/previous_versions/v2.11.0.rst | 2 +- docs/notes/previous_versions/v2.4.2.rst | 2 +- docs/spelling_wordlist.txt | 5 + 82 files changed, 4835 insertions(+), 3296 deletions(-) create mode 100644 code/DynamicTypesIDLExamples.idl delete mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx rename code/Examples/C++/DDSHelloWorld/src/{HelloWorld.h => HelloWorld.hpp} (69%) create mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.cxx create mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.hpp delete mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.cxx delete mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.h delete mode 100644 docs/fastdds/api_reference/dds_pim/topic/typeidv1.rst delete mode 100644 docs/fastdds/api_reference/dds_pim/topic/typeobjectv1.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/annotationdescriptor.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamicdata.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamicdatafactory.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamicpubsubtype.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamictype.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilder.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilderfactory.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/dynamictypemember.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/exception.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/memberdescriptor.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/type_representation.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/typedescriptor.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/typeobjectregistry.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/typeobjectutils.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/verbatimtextdescriptor.rst create mode 100644 docs/fastdds/api_reference/dds_pim/xtypes/xtypes.rst delete mode 100644 docs/fastdds/api_reference/rtps/attributes/TypeLookupSettings.rst delete mode 100644 docs/fastdds/dynamic_types/annotations.rst delete mode 100644 docs/fastdds/dynamic_types/complex_types.rst delete mode 100644 docs/fastdds/dynamic_types/concepts.rst delete mode 100644 docs/fastdds/dynamic_types/discovery.rst delete mode 100644 docs/fastdds/dynamic_types/dynamic_types.rst delete mode 100644 docs/fastdds/dynamic_types/examples.rst delete mode 100644 docs/fastdds/dynamic_types/memory_management.rst delete mode 100644 docs/fastdds/dynamic_types/serialization.rst delete mode 100644 docs/fastdds/dynamic_types/supported_types.rst delete mode 100644 docs/fastdds/dynamic_types/xml_profiles.rst create mode 100644 docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst create mode 100644 docs/fastdds/xtypes/discovery_matching.rst create mode 100644 docs/fastdds/xtypes/language_binding.rst create mode 100644 docs/fastdds/xtypes/xtypes.rst diff --git a/code/CodeTester.cpp b/code/CodeTester.cpp index ca60dd998..d1a0037bb 100644 --- a/code/CodeTester.cpp +++ b/code/CodeTester.cpp @@ -12,15 +12,12 @@ #include #include #include -#include -#include -#include +#include using namespace eprosima::fastrtps; using namespace ::rtps; using namespace ::security; -using namespace ::types; class HelloWorld { @@ -294,720 +291,6 @@ void rtps_api_example_conf() //!-- } -void xml_dyn_examples_check() -{ - //XML-DYN-ENUM - eprosima::fastrtps::types::DynamicTypeBuilder_ptr enum_builder = - DynamicTypeBuilderFactory::get_instance()->create_enum_builder(); - enum_builder->set_name("MyEnum"); - enum_builder->add_empty_member(0, "A"); - enum_builder->add_empty_member(1, "B"); - enum_builder->add_empty_member(2, "C"); - DynamicType_ptr enum_type = DynamicTypeBuilderFactory::get_instance()->create_type(enum_builder.get()); - //!-- - //XML-TYPEDEF - eprosima::fastrtps::types::DynamicTypeBuilder_ptr alias1_builder = - DynamicTypeBuilderFactory::get_instance()->create_alias_builder( - enum_builder.get(), "MyAlias1"); - DynamicType_ptr alias1_type = DynamicTypeBuilderFactory::get_instance()->create_type(alias1_builder.get()); - - std::vector sequence_lengths = { 2, 2 }; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr int_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr array_builder = - DynamicTypeBuilderFactory::get_instance()->create_array_builder( - int_builder.get(), sequence_lengths); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr alias2_builder = - DynamicTypeBuilderFactory::get_instance()->create_alias_builder( - array_builder.get(), "MyAlias2"); - DynamicType_ptr alias2_type = DynamicTypeBuilderFactory::get_instance()->create_type(alias2_builder.get()); - //!-- - { - //XML-STRUCT - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int64_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - - struct_builder->set_name("MyStruct"); - struct_builder->add_member(0, "first", long_builder.get()); - struct_builder->add_member(1, "second", long_long_builder.get()); - DynamicType_ptr struct_type = DynamicTypeBuilderFactory::get_instance()->create_type(struct_builder.get()); - //!-- - } - { - //XML-STRUCT-INHERIT - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int64_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - - struct_builder->set_name("ParentStruct"); - struct_builder->add_member(0, "first", long_builder.get()); - struct_builder->add_member(1, "second", long_long_builder.get()); - DynamicType_ptr struct_type = DynamicTypeBuilderFactory::get_instance()->create_type(struct_builder.get()); - - eprosima::fastrtps::types::DynamicTypeBuilder_ptr child_builder = - DynamicTypeBuilderFactory::get_instance()->create_child_struct_builder(struct_builder.get()); - - child_builder->set_name("ChildStruct"); - child_builder->add_member(0, "third", long_builder.get()); - child_builder->add_member(1, "fourth", long_long_builder.get()); - DynamicType_ptr child_struct_type = DynamicTypeBuilderFactory::get_instance()->create_type(child_builder.get()); - //!-- - } - { - //XML-UNION - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int64_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr octet_builder = - DynamicTypeBuilderFactory::get_instance()->create_byte_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr union_builder = - DynamicTypeBuilderFactory::get_instance()->create_union_builder( - octet_builder.get()); - - union_builder->set_name("MyUnion"); - union_builder->add_member(0, "first", long_builder.get(), "", { 0, 1 }, false); - union_builder->add_member(1, "second", struct_builder.get(), "", { 2 }, false); - union_builder->add_member(2, "third", long_long_builder.get(), "", { }, true); - DynamicType_ptr union_type = DynamicTypeBuilderFactory::get_instance()->create_type(union_builder.get()); - //!-- - } - { - //XML-GENERIC - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int64_builder(); - long_long_builder->set_name("my_long"); - DynamicType_ptr long_long_type = - DynamicTypeBuilderFactory::get_instance()->create_type(long_long_builder.get()); - //!-- - } - { - //XML-BOUNDEDSTRINGS - eprosima::fastrtps::types::DynamicTypeBuilder_ptr string_builder = - DynamicTypeBuilderFactory::get_instance()->create_string_builder(41925); - string_builder->set_name("my_large_string"); - DynamicType_ptr string_type = DynamicTypeBuilderFactory::get_instance()->create_type(string_builder.get()); - - eprosima::fastrtps::types::DynamicTypeBuilder_ptr wstring_builder = - DynamicTypeBuilderFactory::get_instance()->create_wstring_builder(20925); - wstring_builder->set_name("my_large_wstring"); - DynamicType_ptr wstring_type = DynamicTypeBuilderFactory::get_instance()->create_type(wstring_builder.get()); - //!-- - } - { - //XML-ARRAYS - std::vector lengths = { 2, 3, 4 }; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr array_builder = - DynamicTypeBuilderFactory::get_instance()->create_array_builder( - long_builder.get(), lengths); - array_builder->set_name("long_array"); - DynamicType_ptr array_type = DynamicTypeBuilderFactory::get_instance()->create_type(array_builder.get()); - //!-- - } - { - //XML-SEQUENCES - uint32_t child_len = 2; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr seq_builder = - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - long_builder.get(), - child_len); - uint32_t length = 3; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr seq_seq_builder = - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder( - seq_builder.get(), length); - seq_seq_builder->set_name("my_sequence_sequence"); - DynamicType_ptr seq_type = DynamicTypeBuilderFactory::get_instance()->create_type(seq_seq_builder.get()); - //!-- - } - { - //XML-MAPS - uint32_t length = 2; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr long_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr map_builder = - DynamicTypeBuilderFactory::get_instance()->create_map_builder( - long_builder.get(), - long_builder.get(), length); - - eprosima::fastrtps::types::DynamicTypeBuilder_ptr map_map_builder = - DynamicTypeBuilderFactory::get_instance()->create_map_builder( - long_builder.get(), - map_builder.get(), length); - map_map_builder->set_name("my_map_map"); - DynamicType_ptr map_type = DynamicTypeBuilderFactory::get_instance()->create_type(map_map_builder.get()); - //!-- - } - { - //XML-BITSET - DynamicTypeBuilderFactory* m_factory = DynamicTypeBuilderFactory::get_instance(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder_ptr = m_factory->create_bitset_builder(); - builder_ptr->add_member(0, "a", m_factory->create_byte_builder()->build()); - builder_ptr->add_member(1, "b", m_factory->create_bool_builder()->build()); - builder_ptr->add_member(3, "c", m_factory->create_uint16_builder()->build()); - builder_ptr->add_member(4, "d", m_factory->create_int16_builder()->build()); - builder_ptr->apply_annotation_to_member(0, ANNOTATION_BIT_BOUND_ID, "value", "3"); - builder_ptr->apply_annotation_to_member(0, ANNOTATION_POSITION_ID, "value", "0"); - builder_ptr->apply_annotation_to_member(1, ANNOTATION_BIT_BOUND_ID, "value", "1"); - builder_ptr->apply_annotation_to_member(1, ANNOTATION_POSITION_ID, "value", "3"); - builder_ptr->apply_annotation_to_member(3, ANNOTATION_BIT_BOUND_ID, "value", "10"); - builder_ptr->apply_annotation_to_member(3, ANNOTATION_POSITION_ID, "value", "8"); // 4 empty - builder_ptr->apply_annotation_to_member(4, ANNOTATION_BIT_BOUND_ID, "value", "12"); - builder_ptr->apply_annotation_to_member(4, ANNOTATION_POSITION_ID, "value", "18"); - builder_ptr->set_name("MyBitSet"); - //!-- - } - { - //XML-BITMASK - DynamicTypeBuilderFactory* m_factory = DynamicTypeBuilderFactory::get_instance(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder_ptr = m_factory->create_bitmask_builder(8); - builder_ptr->add_empty_member(0, "flag0"); - builder_ptr->add_empty_member(1, "flag1"); - builder_ptr->add_empty_member(2, "flag2"); - builder_ptr->add_empty_member(5, "flag5"); - builder_ptr->set_name("MyBitMask"); - //!-- - } - { - //XML-BITSET-INHERIT - DynamicTypeBuilderFactory* m_factory = DynamicTypeBuilderFactory::get_instance(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder_ptr = m_factory->create_bitset_builder(); - builder_ptr->add_member(0, "a", m_factory->create_byte_builder()->build()); - builder_ptr->add_member(1, "b", m_factory->create_bool_builder()->build()); - builder_ptr->apply_annotation_to_member(0, ANNOTATION_BIT_BOUND_ID, "value", "3"); - builder_ptr->apply_annotation_to_member(0, ANNOTATION_POSITION_ID, "value", "0"); - builder_ptr->apply_annotation_to_member(1, ANNOTATION_BIT_BOUND_ID, "value", "1"); - builder_ptr->apply_annotation_to_member(1, ANNOTATION_POSITION_ID, "value", "3"); - builder_ptr->set_name("ParentBitSet"); - - eprosima::fastrtps::types::DynamicTypeBuilder_ptr child_ptr = m_factory->create_child_struct_builder( - builder_ptr.get()); - child_ptr->add_member(3, "c", m_factory->create_uint16_builder()->build()); - child_ptr->add_member(4, "d", m_factory->create_int16_builder()->build()); - child_ptr->apply_annotation_to_member(3, ANNOTATION_BIT_BOUND_ID, "value", "10"); - child_ptr->apply_annotation_to_member(3, ANNOTATION_POSITION_ID, "value", "8"); // 4 empty - child_ptr->apply_annotation_to_member(4, ANNOTATION_BIT_BOUND_ID, "value", "12"); - child_ptr->apply_annotation_to_member(4, ANNOTATION_POSITION_ID, "value", "18"); - child_ptr->set_name("ChildBitSet"); - //!-- - } -} - -void dynamictypes_configuration() -{ - { - //DYNAMIC_TYPES_QUICK_EXAMPLE - // Create a builder for a specific type - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_enum_builder(); - - // Use the builder to configure the type - builder->add_empty_member(0, "DEFAULT"); - builder->add_empty_member(1, "FIRST"); - builder->add_empty_member(2, "SECOND"); - - // Create the data type using the builder - // The builder will internally use the DynamicTypeBuilderFactory to create the type - DynamicType_ptr type = builder->build(); - - // Create a new data instance of the create data type - DynamicData_ptr data (DynamicDataFactory::get_instance()->create_data(type)); - - // Now we can set or read data values - data->set_int32_value(1); - - // No need of deleting the objects, since we used the - // automanaged smart pointers - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_PRIMITIVES - // Using Builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr created_builder = - DynamicTypeBuilderFactory::get_instance()->create_int32_builder(); - DynamicType_ptr created_type = DynamicTypeBuilderFactory::get_instance()->create_type(created_builder.get()); - DynamicData* data = DynamicDataFactory::get_instance()->create_data(created_type); - data->set_int32_value(1); - - // Creating directly the Dynamic Type - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - DynamicData* data2 = DynamicDataFactory::get_instance()->create_data(pType); - data2->set_int32_value(1); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_STRINGS - // Using Builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr created_builder = - DynamicTypeBuilderFactory::get_instance()->create_string_builder(100); - DynamicType_ptr created_type = DynamicTypeBuilderFactory::get_instance()->create_type(created_builder.get()); - DynamicData* data = DynamicDataFactory::get_instance()->create_data(created_type); - data->set_string_value("Dynamic String"); - - // Creating directly the Dynamic Type - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_string_type(100); - DynamicData* data2 = DynamicDataFactory::get_instance()->create_data(pType); - data2->set_string_value("Dynamic String"); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_ALIAS - // Create the base type - eprosima::fastrtps::types::DynamicTypeBuilder_ptr base_builder = - DynamicTypeBuilderFactory::get_instance()->create_string_builder(100); - DynamicType_ptr base_type = DynamicTypeBuilderFactory::get_instance()->create_type(base_builder.get()); - - // Create alias using Builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_alias_builder(base_type, - "alias"); - DynamicData* data = DynamicDataFactory::get_instance()->create_data(builder.get()); - data->set_string_value("Dynamic Alias String"); - - // Create alias type directly - DynamicType_ptr pAliasType = DynamicTypeBuilderFactory::get_instance()->create_alias_type(base_type, "alias"); - DynamicData* data2 = DynamicDataFactory::get_instance()->create_data(pAliasType); - data2->set_string_value("Dynamic Alias String"); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_ENUMERATIONS - // Add enumeration values using the DynamicTypeBuilder - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_enum_builder(); - builder->add_empty_member(0, "DEFAULT"); - builder->add_empty_member(1, "FIRST"); - builder->add_empty_member(2, "SECOND"); - - // Create the data instance - DynamicData* data = DynamicDataFactory::get_instance()->create_data(builder.get()); - - // Access value using the name - std::string sValue = "SECOND"; - data->set_enum_value(sValue); - std::string sStoredValue; - data->get_enum_value(sStoredValue, MEMBER_ID_INVALID); - - // Access value using the index - uint32_t uValue = 2; - data->set_enum_value(uValue); - uint32_t uStoredValue; - data->get_enum_value(uStoredValue, MEMBER_ID_INVALID); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_BITSETS - // Create bitfields with the appropriate type for their size - eprosima::fastrtps::types::DynamicTypeBuilder_ptr base_type_byte_builder = - DynamicTypeBuilderFactory::get_instance()->create_byte_builder(); - auto base_type_byte = base_type_byte_builder->build(); - - eprosima::fastrtps::types::DynamicTypeBuilder_ptr base_type_uint32_builder = - DynamicTypeBuilderFactory::get_instance()->create_uint32_builder(); - auto base_type_uint32 = base_type_uint32_builder->build(); - - // Create the bitset with two bitfields - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_bitset_builder(); - builder->add_member(0, "byte", base_type_byte); - builder->add_member(1, "uint32", base_type_uint32); - - // Apply members' annotations - builder->apply_annotation_to_member(0, ANNOTATION_POSITION_ID, "value", "0"); // "byte" starts at position 0 - builder->apply_annotation_to_member(0, ANNOTATION_BIT_BOUND_ID, "value", "2"); // "byte" is 2 bit length - builder->apply_annotation_to_member(1, ANNOTATION_POSITION_ID, "value", "10"); // "uint32" starts at position 10 (8 bits empty) - builder->apply_annotation_to_member(1, ANNOTATION_BIT_BOUND_ID, "value", "20"); // "uint32" is 20 bits length - - // Create the data instance - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(builder.get())); - - // Access values - data->set_byte_value(234, 0); - data->set_uint32_value(2340, 1); - octet bValue; - uint32_t uValue; - data->get_byte_value(bValue, 0); - data->get_uint32_value(uValue, 1); - //!-- - //DYNAMIC_TYPES_CREATE_BITSETS-INHERIT - eprosima::fastrtps::types::DynamicTypeBuilder_ptr child_builder = - DynamicTypeBuilderFactory::get_instance()->create_child_struct_builder(builder.get()); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_BITMASKS - uint32_t limit = 5; // Stores as "octet" - - // Add bitmask flags using the DynamicTypeBuilder - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_bitmask_builder(limit); - builder->add_empty_member(0, "FIRST"); - builder->add_empty_member(1, "SECOND"); - - // Create the data instance - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(builder.get())); - - // Access the mask values using the name - data->set_bool_value(true, "FIRST"); // Set the "FIRST" bit - bool bSecondValue = data->get_bool_value("SECOND"); // Get the "SECOND" bit - - // Access the mask values using the index - data->set_bool_value(true, 1); // Set the "SECOND" bit - bool bFirstValue = data->get_bool_value(0); // Get the "FIRST" bit - - // Get the complete bitmask as integer - uint64_t fullValue; - data->get_bitmask_value(fullValue); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_STRUCTS - // Build a structure with two fields ("first" as int32, "other" as uint64) using DynamicTypeBuilder - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type()); - builder->add_member(1, "other", DynamicTypeBuilderFactory::get_instance()->create_uint64_type()); - DynamicType_ptr struct_type(builder->build()); - - // Create the data instance - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(struct_type)); - - // Access struct members - data->set_int32_value(5, 0); - data->set_uint64_value(13, 1); - //!-- - //DYNAMIC_TYPES_CREATE_STRUCTS-INHERIT - eprosima::fastrtps::types::DynamicTypeBuilder_ptr child_builder = - DynamicTypeBuilderFactory::get_instance()->create_child_struct_builder(builder.get()); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_UNIONS - // Create the union DynamicTypeBuilder with an int32 discriminator - DynamicType_ptr discriminator = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_union_builder(discriminator); - - // Add the union members. "firts" will be the default value - builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type(), "", { 0 }, - true); - builder->add_member(0, "second", DynamicTypeBuilderFactory::get_instance()->create_int64_type(), "", { 1 }, - false); - - // Create the data instance - DynamicType_ptr union_type = builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(union_type)); - - // Access the values using the member index - data->set_int32_value(9, 0); - data->set_int64_value(13, 1); - - // Get the label of the currently selected member - uint64_t unionLabel; - data->get_union_label(unionLabel); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_SEQUENCES - // Create a DynamicTypeBuilder for a sequence of two elements of type inte32 - uint32_t length = 2; - DynamicType_ptr base_type = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_sequence_builder(base_type, length); - - // Create the data instance - DynamicType_ptr sequence_type = builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(sequence_type)); - - // Insert and remove elements - MemberId newId, newId2; - data->insert_int32_value(10, newId); - data->insert_int32_value(12, newId2); - data->remove_sequence_data(newId); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_ARRAYS - // Create an array DynamicTypeBuilder for a 2x2 elements of type int32 - std::vector lengths = { 2, 2 }; - DynamicType_ptr base_type = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_array_builder(base_type, lengths); - - // Create the data instance - DynamicType_ptr array_type = builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(array_type)); - - // Access elements in the multidimensional array - MemberId pos = data->get_array_index({1, 0}); - data->set_int32_value(11, pos); - data->set_int32_value(27, pos + 1); - data->clear_array_data(pos); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_MAPS - // Create DynamicTypeBuilder for a map of two pairs of {key:int32, value:int32} - uint32_t length = 2; - DynamicType_ptr base = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_map_builder(base, base, length); - - // Create the data instance - DynamicType_ptr map_type = builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(map_type)); - - // Add a new element to the map with key 1 - DynamicData_ptr key(DynamicDataFactory::get_instance()->create_data(base)); - MemberId keyId; - MemberId valueId; - key->set_int32_value(1); - data->insert_map_data(key.get(), keyId, valueId); - - // Add a new element to the map with key 2 - // insert_map_data creates a copy of the key, so the same instance can be reused - MemberId keyId2; - MemberId valueId2; - key->set_int32_value(2); - data->insert_map_data(key.get(), keyId2, valueId2); - - // Set the value to the element with key 2, using the returned value Id - data->set_int32_value(53, valueId2); - - // Remove elements from the map - data->remove_map_data(keyId); - data->remove_map_data(keyId2); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_NESTED_STRUCTS - // Create a struct type - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type()); - builder->add_member(1, "other", DynamicTypeBuilderFactory::get_instance()->create_uint64_type()); - DynamicType_ptr struct_type = builder->build(); - - // Create a struct type with the previous struct as member - eprosima::fastrtps::types::DynamicTypeBuilder_ptr parent_builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - parent_builder->add_member(0, "child_struct", struct_type); - parent_builder->add_member(1, "second", DynamicTypeBuilderFactory::get_instance()->create_int32_type()); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(parent_builder.get())); - - // Access the child struct with the loan operations - DynamicData* child_data = data->loan_value(0); - child_data->set_int32_value(5, 0); - child_data->set_uint64_value(13, 1); - data->return_loaned_value(child_data); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_INHERITANCE_STRUCTS - // Create a base struct type - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type()); - builder->add_member(1, "other", DynamicTypeBuilderFactory::get_instance()->create_uint64_type()); - - // Create a struct type derived from the previous struct - eprosima::fastrtps::types::DynamicTypeBuilder_ptr child_builder = - DynamicTypeBuilderFactory::get_instance()->create_child_struct_builder(builder.get()); - - // Add new members to the derived type - builder->add_member(2, "third", DynamicTypeBuilderFactory::get_instance()->create_uint64_type()); - - // Create the data instance - DynamicType_ptr struct_type = child_builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(struct_type)); - - // The derived type includes the members defined on the base type - data->set_int32_value(5, 0); - data->set_uint64_value(13, 1); - data->set_uint64_value(47, 2); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_NESTED_ALIAS - // Using Builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr created_builder = - DynamicTypeBuilderFactory::get_instance()->create_string_builder(100); - DynamicType_ptr created_type = DynamicTypeBuilderFactory::get_instance()->create_type(created_builder.get()); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_alias_builder( - created_builder.get(), "alias"); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder2 = - DynamicTypeBuilderFactory::get_instance()->create_alias_builder( - builder.get(), "alias2"); - DynamicData* data(DynamicDataFactory::get_instance()->create_data(builder2->build())); - data->set_string_value("Dynamic Alias 2 String"); - - // Creating directly the Dynamic Type - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_string_type(100); - DynamicType_ptr pAliasType = DynamicTypeBuilderFactory::get_instance()->create_alias_type(pType, "alias"); - DynamicType_ptr pAliasType2 = - DynamicTypeBuilderFactory::get_instance()->create_alias_type(pAliasType, "alias2"); - DynamicData* data2(DynamicDataFactory::get_instance()->create_data(pAliasType)); - data2->set_string_value("Dynamic Alias 2 String"); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_NESTED_UNIONS - // Create a union DynamicTypeBuilder - DynamicType_ptr discriminator = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_union_builder(discriminator); - - // Add a int32 to the union - builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type(), "", { 0 }, - true); - - // Create a struct type and add it to the union - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - struct_builder->add_member(0, "first", DynamicTypeBuilderFactory::get_instance()->create_int32_type()); - struct_builder->add_member(1, "other", DynamicTypeBuilderFactory::get_instance()->create_uint64_type()); - builder->add_member(1, "first", struct_builder.get(), "", { 1 }, false); - - // Create the union data instance - DynamicType_ptr union_type = builder->build(); - DynamicData_ptr data(DynamicDataFactory::get_instance()->create_data(union_type)); - - // Access the struct member using the loan operations - DynamicData* child_data = data->loan_value(1); - child_data->set_int32_value(9, 0); - child_data->set_int64_value(13, 1); - data->return_loaned_value(child_data); - //!-- - } - - { - //DYNAMIC_TYPES_CREATE_ANNOTATION - // Apply the annotation - eprosima::fastrtps::types::DynamicTypeBuilder_ptr builder = - DynamicTypeBuilderFactory::get_instance()->create_struct_builder(); - //... - builder->apply_annotation("MyAnnotation", "value", "5"); - builder->apply_annotation("MyAnnotation", "name", "length"); - //!-- - } - - { - //DYNAMIC_TYPES_SERIALIZATION - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - DynamicPubSubType pubsubType(pType); - - // SERIALIZATION EXAMPLE - DynamicData* pData = DynamicDataFactory::get_instance()->create_data(pType); - uint32_t payloadSize = static_cast(pubsubType.getSerializedSizeProvider(pData)()); - SerializedPayload_t payload(payloadSize); - pubsubType.serialize(pData, &payload); - - // DESERIALIZATION EXAMPLE - types::DynamicData* data2 = DynamicDataFactory::get_instance()->create_data(pType); - pubsubType.deserialize(&payload, data2); - //!-- - } - - { - //DYNAMIC_TYPES_NOTES_1 - DynamicTypeBuilder* pBuilder = DynamicTypeBuilderFactory::get_instance()->create_uint32_builder(); - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - DynamicData* pData = DynamicDataFactory::get_instance()->create_data(pType); - - DynamicTypeBuilderFactory::get_instance()->delete_builder(pBuilder); - DynamicDataFactory::get_instance()->delete_data(pData); - //!-- - } - - { - //DYNAMIC_TYPES_NOTES_2 - eprosima::fastrtps::types::DynamicTypeBuilder_ptr pBuilder = - DynamicTypeBuilderFactory::get_instance()->create_uint32_builder(); - DynamicType_ptr pType = DynamicTypeBuilderFactory::get_instance()->create_int32_type(); - DynamicData_ptr pData(DynamicDataFactory::get_instance()->create_data(pType)); - //!-- - } - - { - //DYNAMIC_HELLO_WORLD_API - // In HelloWorldPublisher.h - // Dynamic Types - eprosima::fastrtps::types::DynamicData* m_DynHello; - eprosima::fastrtps::types::DynamicPubSubType m_DynType; - - // In HelloWorldPublisher.cpp - // Create basic builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_type_builder(DynamicTypeBuilderFactory::get_instance() - ->create_struct_builder()); - - // Add members to the struct. - struct_type_builder->add_member(0, "index", DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); - struct_type_builder->add_member(1, "message", DynamicTypeBuilderFactory::get_instance()->create_string_type()); - struct_type_builder->set_name("HelloWorld"); - - DynamicType_ptr dynType = struct_type_builder->build(); - m_DynType.SetDynamicType(dynType); - m_DynHello = DynamicDataFactory::get_instance()->create_data(dynType); - m_DynHello->set_uint32_value(0, 0); - m_DynHello->set_string_value("HelloWorld", 1); - //!-- - } - - { - //DYNAMIC_HELLO_WORLD_API - // In HelloWorldPublisher.h - // Dynamic Types - eprosima::fastrtps::types::DynamicData* m_DynHello; - eprosima::fastrtps::types::DynamicPubSubType m_DynType; - - // In HelloWorldPublisher.cpp - // Create basic builders - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_type_builder(DynamicTypeBuilderFactory::get_instance() - ->create_struct_builder()); - - // Add members to the struct. - struct_type_builder->add_member(0, "index", DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); - struct_type_builder->add_member(1, "message", DynamicTypeBuilderFactory::get_instance()->create_string_type()); - struct_type_builder->set_name("HelloWorld"); - - DynamicType_ptr dynType = struct_type_builder->build(); - m_DynType.SetDynamicType(dynType); - m_DynHello = DynamicDataFactory::get_instance()->create_data(dynType); - m_DynHello->set_uint32_value(0, 0); - m_DynHello->set_string_value("HelloWorld", 1); - //!-- - } - -} - bool permissions_test( std::string main_ca_file, std::string appcert_file, diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 84a3b794c..f0c4a33c0 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -27,10 +27,16 @@ #include #include #include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -47,11 +53,6 @@ #include #include #include -#include -#include -#include -#include - using namespace eprosima::fastdds::dds; @@ -161,7 +162,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener } void on_participant_discovery( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::ParticipantDiscoveryInfo&& info, bool& should_be_ignored) override { @@ -180,13 +181,13 @@ class CustomDomainParticipantListener : public DomainParticipantListener else if (info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT || info.status == eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::DROPPED_PARTICIPANT) { - std::cout << "New participant lost" << std::endl; + std::cout << "Participant lost" << std::endl; } } #if HAVE_SECURITY void onParticipantAuthentication( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::ParticipantAuthenticationInfo&& info) override { if (info.status == eprosima::fastrtps::rtps::ParticipantAuthenticationInfo::AUTHORIZED_PARTICIPANT) @@ -201,76 +202,52 @@ class CustomDomainParticipantListener : public DomainParticipantListener #endif // if HAVE_SECURITY - void on_subscriber_discovery( - DomainParticipant* /*participant*/, - eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override + void on_data_reader_discovery( + DomainParticipant* participant, + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) override { + should_be_ignored = false; if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) { - std::cout << "New subscriber discovered" << std::endl; + std::cout << "New datareader discovered" << std::endl; + // The following line can be modified to evaluate whether the discovered datareader should be ignored + // (usually based on fields present in the discovery information) + bool ignoring_condition = false; + if (ignoring_condition) + { + should_be_ignored = true; // Request the ignoring of the discovered datareader + } } else if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER) { - std::cout << "New subscriber lost" << std::endl; + std::cout << "Datareader lost" << std::endl; } } - void on_publisher_discovery( - DomainParticipant* /*participant*/, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + void on_data_writer_discovery( + DomainParticipant* participant, + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& should_be_ignored) override { + should_be_ignored = false; if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) { - std::cout << "New publisher discovered" << std::endl; + std::cout << "New datawriter discovered" << std::endl; + // The following line can be modified to evaluate whether the discovered datawriter should be ignored + // (usually based on fields present in the discovery information) + bool ignoring_condition = false; + if (ignoring_condition) + { + should_be_ignored = true; // Request the ignoring of the discovered datawriter + } } else if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER) { - std::cout << "New publisher lost" << std::endl; + std::cout << "Datawriter lost" << std::endl; } } - void on_type_discovery( - DomainParticipant* participant, - const eprosima::fastrtps::rtps::SampleIdentity& request_sample_id, - const eprosima::fastcdr::string_255& topic, - const eprosima::fastrtps::types::TypeIdentifier* identifier, - const eprosima::fastrtps::types::TypeObject* object, - eprosima::fastrtps::types::DynamicType_ptr dyn_type) override - { - static_cast(participant); - static_cast(request_sample_id); - static_cast(topic); - static_cast(identifier); - static_cast(object); - static_cast(dyn_type); - std::cout << "New data type discovered" << std::endl; - - } - - void on_type_dependencies_reply( - DomainParticipant* participant, - const eprosima::fastrtps::rtps::SampleIdentity& request_sample_id, - const eprosima::fastrtps::types::TypeIdentifierWithSizeSeq& dependencies) override - { - static_cast(participant); - static_cast(request_sample_id); - static_cast(dependencies); - std::cout << "Answer to a request for type dependencies was received" << std::endl; - } - - void on_type_information_received( - DomainParticipant* participant, - const eprosima::fastcdr::string_255 topic_name, - const eprosima::fastcdr::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) override - { - static_cast(participant); - static_cast(topic_name); - static_cast(type_name); - static_cast(type_information); - std::cout << "New data type information received" << std::endl; - } - }; //!-- @@ -408,7 +385,7 @@ void dds_domain_examples() CustomDomainParticipantListener custom_listener; DomainParticipant* participant_with_custom_listener = DomainParticipantFactory::get_instance()->create_participant_with_default_profile( - &custom_listener, StatusMask::none()); + &custom_listener, StatusMask::none()); if (nullptr == participant_with_custom_listener) { // Error @@ -457,7 +434,7 @@ void dds_domain_examples() } // Set the QoS on the participant to the default - if (participant->set_qos(PARTICIPANT_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (participant->set_qos(PARTICIPANT_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -465,7 +442,7 @@ void dds_domain_examples() // The previous instruction is equivalent to the following: if (participant->set_qos(DomainParticipantFactory::get_instance()->get_default_participant_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -488,14 +465,14 @@ void dds_domain_examples() // (...) // Delete entities created by the DomainParticipant - if (participant->delete_contained_entities() != ReturnCode_t::RETCODE_OK) + if (participant->delete_contained_entities() != RETCODE_OK) { // DomainParticipant failed to delete the entities it created. return; } // Delete the DomainParticipant - if (DomainParticipantFactory::get_instance()->delete_participant(participant) != ReturnCode_t::RETCODE_OK) + if (DomainParticipantFactory::get_instance()->delete_participant(participant) != RETCODE_OK) { // Error return; @@ -513,7 +490,7 @@ void dds_domain_examples() // Set as the new default TopicQos if (DomainParticipantFactory::get_instance()->set_default_participant_qos(qos_type1) != - ReturnCode_t::RETCODE_OK) + RETCODE_OK) { // Error return; @@ -536,7 +513,7 @@ void dds_domain_examples() // Set as the new default TopicQos if (DomainParticipantFactory::get_instance()->set_default_participant_qos(qos_type2) != - ReturnCode_t::RETCODE_OK) + RETCODE_OK) { // Error return; @@ -553,7 +530,7 @@ void dds_domain_examples() // Resetting the default DomainParticipantQos to the original default constructed values if (DomainParticipantFactory::get_instance()->set_default_participant_qos(PARTICIPANT_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -561,7 +538,7 @@ void dds_domain_examples() // The previous instruction is equivalent to the following if (DomainParticipantFactory::get_instance()->set_default_participant_qos(DomainParticipantQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -576,7 +553,7 @@ void dds_domain_examples() // Setting autoenable_created_entities to true makes the created DomainParticipants // to be enabled upon creation qos.entity_factory().autoenable_created_entities = true; - if (DomainParticipantFactory::get_instance()->set_qos(qos) != ReturnCode_t::RETCODE_OK) + if (DomainParticipantFactory::get_instance()->set_qos(qos) != RETCODE_OK) { // Error return; @@ -595,7 +572,7 @@ void dds_domain_examples() // Setting autoenable_created_entities to false makes the created DomainParticipants // to be disabled upon creation qos.entity_factory().autoenable_created_entities = false; - if (DomainParticipantFactory::get_instance()->set_qos(qos) != ReturnCode_t::RETCODE_OK) + if (DomainParticipantFactory::get_instance()->set_qos(qos) != RETCODE_OK) { // Error return; @@ -811,7 +788,7 @@ void dds_domain_examples() // Enable statistics DataWriter if (statistics_participant->enable_statistics_datawriter(eprosima::fastdds::statistics::GAP_COUNT_TOPIC, - eprosima::fastdds::statistics::dds::STATISTICS_DATAWRITER_QOS) != ReturnCode_t::RETCODE_OK) + eprosima::fastdds::statistics::dds::STATISTICS_DATAWRITER_QOS) != RETCODE_OK) { // Error return; @@ -822,14 +799,14 @@ void dds_domain_examples() // Disable statistics DataWriter if (statistics_participant->disable_statistics_datawriter(eprosima::fastdds::statistics::GAP_COUNT_TOPIC) != - ReturnCode_t::RETCODE_OK) + RETCODE_OK) { // Error return; } // Delete DomainParticipant - if (DomainParticipantFactory::get_instance()->delete_participant(participant) != ReturnCode_t::RETCODE_OK) + if (DomainParticipantFactory::get_instance()->delete_participant(participant) != RETCODE_OK) { // Error return; @@ -946,7 +923,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener std::cout << "New DomainParticipant '" << info.info.m_participantName << "' with ID '" << info.info.m_guid.entityId << "' and GuidPrefix '" << info.info.m_guid.guidPrefix << "' discovered." << std::endl; - /* The following line can be substitue to evaluate whether the discovered participant should be ignored */ + /* The following line can be substituted to evaluate whether the discovered participant should be ignored */ bool ignoring_condition = false; if (ignoring_condition) { @@ -959,77 +936,181 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener break; case eprosima::fastrtps::rtps::ParticipantDiscoveryInfo::REMOVED_PARTICIPANT: /* Process the case when a DomainParticipant was removed from the domain */ - std::cout << "New DomainParticipant '" << info.info.m_participantName << + std::cout << "DomainParticipant '" << info.info.m_participantName << "' with ID '" << info.info.m_guid.entityId << "' and GuidPrefix '" << info.info.m_guid.guidPrefix << "' left the domain." << std::endl; break; } } - /* Custom Callback on_subscriber_discovery */ - void on_subscriber_discovery( + /* Custom Callback on_data_reader_discovery */ + void on_data_reader_discovery( DomainParticipant* participant, - eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) override { + should_be_ignored = false; static_cast(participant); switch (info.status){ case eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER: - /* Process the case when a new subscriber was found in the domain */ + { + /* Process the case when a new datareader was found in the domain */ std::cout << "New DataReader subscribed to topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' discovered"; - break; + /* The following line can be substituted to evaluate whether the discovered datareader should be ignored */ + bool ignoring_condition = false; + if (ignoring_condition) + { + should_be_ignored = true; // Request the ignoring of the discovered datareader + } + } + break; case eprosima::fastrtps::rtps::ReaderDiscoveryInfo::CHANGED_QOS_READER: - /* Process the case when a subscriber changed its QOS */ + /* Process the case when a datareader changed its QOS */ break; case eprosima::fastrtps::rtps::ReaderDiscoveryInfo::REMOVED_READER: - /* Process the case when a subscriber was removed from the domain */ - std::cout << "New DataReader subscribed to topic '" << info.info.topicName() << + /* Process the case when a datareader was removed from the domain */ + std::cout << "DataReader subscribed to topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' left the domain."; break; } } - /* Custom Callback on_publisher_discovery */ - void on_publisher_discovery( + /* Custom Callback on_data_writer_discovery */ + void on_data_writer_discovery( DomainParticipant* participant, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& should_be_ignored) override { + should_be_ignored = false; static_cast(participant); switch (info.status){ case eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER: - /* Process the case when a new publisher was found in the domain */ + { + /* Process the case when a new datawriter was found in the domain */ std::cout << "New DataWriter publishing under topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' discovered"; - break; + /* The following line can be substituted to evaluate whether the discovered datawriter should be ignored */ + bool ignoring_condition = false; + if (ignoring_condition) + { + should_be_ignored = true; // Request the ignoring of the discovered datawriter + } + } + break; case eprosima::fastrtps::rtps::WriterDiscoveryInfo::CHANGED_QOS_WRITER: - /* Process the case when a publisher changed its QOS */ + /* Process the case when a datawriter changed its QOS */ break; case eprosima::fastrtps::rtps::WriterDiscoveryInfo::REMOVED_WRITER: - /* Process the case when a publisher was removed from the domain */ - std::cout << "New DataWriter publishing under topic '" << info.info.topicName() << + /* Process the case when a datawriter was removed from the domain */ + std::cout << "DataWriter publishing under topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' left the domain."; break; } } - /* Custom Callback on_type_discovery */ - void on_type_discovery( +}; +//!-- + +//!--REMOTE_TYPE_MATCHING +class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListener +{ + /* Custom Callback on_data_reader_discovery */ + void on_data_reader_discovery( DomainParticipant* participant, - const eprosima::fastrtps::rtps::SampleIdentity& request_sample_id, - const eprosima::fastcdr::string_255& topic, - const eprosima::fastrtps::types::TypeIdentifier* identifier, - const eprosima::fastrtps::types::TypeObject* object, - eprosima::fastrtps::types::DynamicType_ptr dyn_type) override + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) override { - static_cast(participant); - static_cast(request_sample_id); - static_cast(topic); - static_cast(identifier); - static_cast(object); - static_cast(dyn_type); - std::cout << "New data type of topic '" << topic << "' discovered." << std::endl; + should_be_ignored = false; + // Get remote type information + xtypes::TypeObject remote_type_object; + if (RETCODE_OK != DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + info.info.type_information().type_information.complete().typeid_with_size().type_id(), + remote_type_object)) + { + // Error + return; + } + // Register remotely discovered type + DynamicType::_ref_type remote_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + remote_type_object)->build(); + TypeSupport dyn_type_support(new DynamicPubSubType(remote_type)); + dyn_type_support.register_type(participant); + + // Create a Topic with the remotely discovered type. + Topic* topic = + participant->create_topic(info.info.topicName().to_string(), dyn_type_support.get_type_name(), + TOPIC_QOS_DEFAULT); + if (nullptr == topic) + { + // Error + return; + } + + // Create endpoint + Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); + if (nullptr == publisher) + { + // Error + return; + } + + DataWriter* data_writer = publisher->create_datawriter(topic, DATAWRITER_QOS_DEFAULT); + if (nullptr == data_writer) + { + // Error + return; + } } + /* Custom Callback on_data_writer_discovery */ + void on_data_writer_discovery( + DomainParticipant* participant, + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& should_be_ignored) override + { + should_be_ignored = false; + // Get remote type information + xtypes::TypeObject remote_type_object; + if (RETCODE_OK != DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + info.info.type_information().type_information.complete().typeid_with_size().type_id(), + remote_type_object)) + { + // Error + return; + } + // Register remotely discovered type + DynamicType::_ref_type remote_type = DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + remote_type_object)->build(); + TypeSupport dyn_type_support(new DynamicPubSubType(remote_type)); + dyn_type_support.register_type(participant); + + // Create a Topic with the remotely discovered type. + Topic* topic = + participant->create_topic(info.info.topicName().to_string(), dyn_type_support.get_type_name(), + TOPIC_QOS_DEFAULT); + if (nullptr == topic) + { + // Error + return; + } + + // Create endpoint + Subscriber* subscriber = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT); + if (nullptr == subscriber) + { + // Error + return; + } + + // The QoS depends on the remote endpoint QoS. For simplicity, default QoS have been assumed. + DataReader* data_reader = subscriber->create_datareader(topic, DATAREADER_QOS_DEFAULT); + if (nullptr == data_reader) + { + // Error + return; + } + } }; //!-- @@ -1240,7 +1321,7 @@ void dds_discovery_examples() /* Update list of remote servers for this client or server */ client_or_server_qos.wire_protocol().builtin.discovery_config.m_DiscoveryServers.push_back(remote_server_att); - if (ReturnCode_t::RETCODE_OK != client_or_server->set_qos(client_or_server_qos)) + if (RETCODE_OK != client_or_server->set_qos(client_or_server_qos)) { // Error return; @@ -1345,7 +1426,7 @@ void dds_discovery_examples() // The (file://) flag is optional. std::string file = "file://static_Discovery.xml"; DomainParticipantFactory* factory = DomainParticipantFactory::get_instance(); - if (ReturnCode_t::RETCODE_OK != factory->check_xml_static_discovery(file)) + if (RETCODE_OK != factory->check_xml_static_discovery(file)) { std::cout << "Error parsing xml file " << file << std::endl; } @@ -1365,7 +1446,7 @@ void dds_discovery_examples() "" \ "" \ ""; - if (ReturnCode_t::RETCODE_OK != factory->check_xml_static_discovery(fileData)) + if (RETCODE_OK != factory->check_xml_static_discovery(fileData)) { std::cout << "Error parsing xml file data:" << std::endl << fileData << std::endl; } @@ -1419,21 +1500,21 @@ class CustomDataType : public TopicDataType } bool serialize( - void* /*data*/, - eprosima::fastrtps::rtps::SerializedPayload_t* /*payload*/) override + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override { return true; } bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* /*payload*/, - void* /*data*/) override + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override { return true; } std::function getSerializedSizeProvider( - void* /*data*/) override + void* data) override { return std::function(); } @@ -1444,14 +1525,14 @@ class CustomDataType : public TopicDataType } void deleteData( - void* /*data*/) override + void* data) override { } bool getKey( - void* /*data*/, - eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/, - bool /*force_md5*/) override + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5) override { return true; } @@ -1602,7 +1683,7 @@ void dds_topic_examples() } // Set the QoS on the topic to the default - if (topic->set_qos(TOPIC_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (topic->set_qos(TOPIC_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -1610,7 +1691,7 @@ void dds_topic_examples() // The previous instruction is equivalent to the following: if (topic->set_qos(participant->get_default_topic_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -1642,7 +1723,7 @@ void dds_topic_examples() // (...) // Delete the Topic - if (participant->delete_topic(topic) != ReturnCode_t::RETCODE_OK) + if (participant->delete_topic(topic) != RETCODE_OK) { // Error return; @@ -1668,7 +1749,7 @@ void dds_topic_examples() // (...) // Set as the new default TopicQos - if (participant->set_default_topic_qos(qos_type1) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_topic_qos(qos_type1) != RETCODE_OK) { // Error return; @@ -1690,7 +1771,7 @@ void dds_topic_examples() // (...) // Set as the new default TopicQos - if (participant->set_default_topic_qos(qos_type2) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_topic_qos(qos_type2) != RETCODE_OK) { // Error return; @@ -1707,7 +1788,7 @@ void dds_topic_examples() // Resetting the default TopicQos to the original default constructed values if (participant->set_default_topic_qos(TOPIC_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -1715,7 +1796,7 @@ void dds_topic_examples() // The previous instruction is equivalent to the following if (participant->set_default_topic_qos(TopicQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -1781,12 +1862,11 @@ void dds_topic_examples() DomainParticipantFactory::get_instance()->load_XML_profiles_file("example_type.xml"); // Retrieve the an instance of the desired type - eprosima::fastrtps::types::DynamicTypeBuilder* type; - DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("DynamicType", type); + DynamicType::_ref_type dyn_type; + DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("DynamicType", dyn_type); - // Build and register it - eprosima::fastrtps::types::DynamicType_ptr dyn_type = type->build(); - TypeSupport dyn_type_support(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type)); + // Register dynamic type + TypeSupport dyn_type_support(new DynamicPubSubType(dyn_type)); dyn_type_support.register_type(participant, nullptr); // Create a Topic with the registered type. @@ -1945,7 +2025,7 @@ void dds_content_filtered_topic_examples() // (...) // Update the expression - if (ReturnCode_t::RETCODE_OK != + if (RETCODE_OK != filter_topic->set_filter_expression("message like %0 or index > %1", {"'Hello*'", "15"})) { // Error @@ -1956,7 +2036,7 @@ void dds_content_filtered_topic_examples() print_filter_info(filter_topic); // Update the parameters - if (ReturnCode_t::RETCODE_OK != + if (RETCODE_OK != filter_topic->set_expression_parameters({"'*world*'", "222"})) { // Error @@ -2020,7 +2100,7 @@ void dds_content_filtered_topic_examples() // (...) // Delete the ContentFilteredTopic - if (ReturnCode_t::RETCODE_OK != participant->delete_contentfilteredtopic(filter_topic)) + if (RETCODE_OK != participant->delete_contentfilteredtopic(filter_topic)) { // Error return; @@ -2069,7 +2149,7 @@ void dds_custom_filters_examples() { deser >> index; } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& exception) { return false; } @@ -2108,19 +2188,19 @@ void dds_custom_filters_examples() // Check the ContentFilteredTopic should be created by my factory. if (0 != strcmp(filter_class_name, "MY_CUSTOM_FILTER")) { - return ReturnCode_t::RETCODE_BAD_PARAMETER; + return RETCODE_BAD_PARAMETER; } // Check the ContentFilteredTopic is created for the unique type this Custom Filter supports. if (0 != strcmp(type_name, "HelloWorld")) { - return ReturnCode_t::RETCODE_BAD_PARAMETER; + return RETCODE_BAD_PARAMETER; } // Check that the two mandatory filter parameters are set. if (2 != filter_parameters.length()) { - return ReturnCode_t::RETCODE_BAD_PARAMETER; + return RETCODE_BAD_PARAMETER; } // If there is an update, delete previous instance. @@ -2132,7 +2212,7 @@ void dds_custom_filters_examples() // Instantiation of the Custom Filter. filter_instance = new MyCustomFilter(std::stoi(filter_parameters[0]), std::stoi(filter_parameters[1])); - return ReturnCode_t::RETCODE_OK; + return RETCODE_OK; } ReturnCode_t delete_content_filter( @@ -2142,13 +2222,13 @@ void dds_custom_filters_examples() // Check the ContentFilteredTopic should be created by my factory. if (0 != strcmp(filter_class_name, "MY_CUSTOM_FILTER")) { - return ReturnCode_t::RETCODE_BAD_PARAMETER; + return RETCODE_BAD_PARAMETER; } // Deletion of the Custom Filter. delete(dynamic_cast(filter_instance)); - return ReturnCode_t::RETCODE_OK; + return RETCODE_OK; } }; @@ -2170,7 +2250,7 @@ void dds_custom_filters_examples() // Registration of the factory - if (ReturnCode_t::RETCODE_OK != + if (RETCODE_OK != participant->register_content_filter_factory("MY_CUSTOM_FILTER", factory)) { // Error @@ -2383,7 +2463,7 @@ void dds_publisher_examples() } // Set the QoS on the publisher to the default - if (publisher->set_qos(PUBLISHER_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (publisher->set_qos(PUBLISHER_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -2391,7 +2471,7 @@ void dds_publisher_examples() // The previous instruction is equivalent to the following: if (publisher->set_qos(participant->get_default_publisher_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2423,14 +2503,14 @@ void dds_publisher_examples() // (...) // Delete the entities the Publisher created. - if (publisher->delete_contained_entities() != ReturnCode_t::RETCODE_OK) + if (publisher->delete_contained_entities() != RETCODE_OK) { // Publisher failed to delete the entities it created. return; } // Delete the Publisher - if (participant->delete_publisher(publisher) != ReturnCode_t::RETCODE_OK) + if (participant->delete_publisher(publisher) != RETCODE_OK) { // Error return; @@ -2456,7 +2536,7 @@ void dds_publisher_examples() // (...) // Set as the new default PublisherQos - if (participant->set_default_publisher_qos(qos_type1) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_publisher_qos(qos_type1) != RETCODE_OK) { // Error return; @@ -2478,7 +2558,7 @@ void dds_publisher_examples() // (...) // Set as the new default PublisherQos - if (participant->set_default_publisher_qos(qos_type2) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_publisher_qos(qos_type2) != RETCODE_OK) { // Error return; @@ -2495,7 +2575,7 @@ void dds_publisher_examples() // Resetting the default PublisherQos to the original default constructed values if (participant->set_default_publisher_qos(PUBLISHER_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2503,7 +2583,7 @@ void dds_publisher_examples() // The previous instruction is equivalent to the following if (participant->set_default_publisher_qos(PublisherQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2552,7 +2632,7 @@ class CustomDataWriterListener : public DataWriterListener } void on_offered_incompatible_qos( - DataWriter* /*writer*/, + DataWriter* writer, const OfferedIncompatibleQosStatus& status) override { std::cout << "Found a remote Topic with incompatible QoS (QoS ID: " << status.last_policy_id << @@ -2726,7 +2806,7 @@ void dds_dataWriter_examples() } // Set the QoS on the DataWriter to the default - if (data_writer->set_qos(DATAWRITER_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (data_writer->set_qos(DATAWRITER_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -2734,7 +2814,7 @@ void dds_dataWriter_examples() // The previous instruction is equivalent to the following: if (data_writer->set_qos(publisher->get_default_datawriter_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2757,7 +2837,7 @@ void dds_dataWriter_examples() // (...) // Delete the DataWriter - if (publisher->delete_datawriter(data_writer) != ReturnCode_t::RETCODE_OK) + if (publisher->delete_datawriter(data_writer) != RETCODE_OK) { // Error return; @@ -2774,7 +2854,7 @@ void dds_dataWriter_examples() // (...) // Set as the new default DataWriterQos - if (publisher->set_default_datawriter_qos(qos_type1) != ReturnCode_t::RETCODE_OK) + if (publisher->set_default_datawriter_qos(qos_type1) != RETCODE_OK) { // Error return; @@ -2796,7 +2876,7 @@ void dds_dataWriter_examples() // (...) // Set as the new default DataWriterQos - if (publisher->set_default_datawriter_qos(qos_type2) != ReturnCode_t::RETCODE_OK) + if (publisher->set_default_datawriter_qos(qos_type2) != RETCODE_OK) { // Error return; @@ -2813,7 +2893,7 @@ void dds_dataWriter_examples() // Resetting the default DataWriterQos to the original default constructed values if (publisher->set_default_datawriter_qos(DATAWRITER_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2821,7 +2901,7 @@ void dds_dataWriter_examples() // The previous instruction is equivalent to the following if (publisher->set_default_datawriter_qos(DataWriterQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -2860,7 +2940,7 @@ void dds_dataWriter_examples() // (...) // Publish the new value, deduce the instance handle - if (data_writer->write(data, eprosima::fastrtps::rtps::InstanceHandle_t()) != ReturnCode_t::RETCODE_OK) + if (data_writer->write(data, eprosima::fastrtps::rtps::InstanceHandle_t()) != RETCODE_OK) { // Error return; @@ -2875,7 +2955,7 @@ void dds_dataWriter_examples() //DDS_DATAWRITER_LOAN_SAMPLES // Borrow a data instance void* data = nullptr; - if (ReturnCode_t::RETCODE_OK == data_writer->loan_sample(data)) + if (RETCODE_OK == data_writer->loan_sample(data)) { bool error = false; @@ -2890,7 +2970,7 @@ void dds_dataWriter_examples() } // Publish the new value - if (data_writer->write(data, eprosima::fastrtps::rtps::InstanceHandle_t()) != ReturnCode_t::RETCODE_OK) + if (data_writer->write(data, eprosima::fastrtps::rtps::InstanceHandle_t()) != RETCODE_OK) { // Error return; @@ -3166,7 +3246,7 @@ void dds_subscriber_examples() } // Set the QoS on the subscriber to the default - if (subscriber->set_qos(SUBSCRIBER_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (subscriber->set_qos(SUBSCRIBER_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -3174,7 +3254,7 @@ void dds_subscriber_examples() // The previous instruction is equivalent to the following: if (subscriber->set_qos(participant->get_default_subscriber_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3206,14 +3286,14 @@ void dds_subscriber_examples() // (...) // Delete the entities the subscriber created - if (subscriber->delete_contained_entities() != ReturnCode_t::RETCODE_OK) + if (subscriber->delete_contained_entities() != RETCODE_OK) { // Subscriber failed to delete the entities it created return; } // Delete the Subscriber - if (participant->delete_subscriber(subscriber) != ReturnCode_t::RETCODE_OK) + if (participant->delete_subscriber(subscriber) != RETCODE_OK) { // Error return; @@ -3239,7 +3319,7 @@ void dds_subscriber_examples() // (...) // Set as the new default SubscriberQos - if (participant->set_default_subscriber_qos(qos_type1) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_subscriber_qos(qos_type1) != RETCODE_OK) { // Error return; @@ -3261,7 +3341,7 @@ void dds_subscriber_examples() // (...) // Set as the new default SubscriberQos - if (participant->set_default_subscriber_qos(qos_type2) != ReturnCode_t::RETCODE_OK) + if (participant->set_default_subscriber_qos(qos_type2) != RETCODE_OK) { // Error return; @@ -3278,7 +3358,7 @@ void dds_subscriber_examples() // Resetting the default SubscriberQos to the original default constructed values if (participant->set_default_subscriber_qos(SUBSCRIBER_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3286,7 +3366,7 @@ void dds_subscriber_examples() // The previous instruction is equivalent to the following if (participant->set_default_subscriber_qos(SubscriberQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3366,7 +3446,7 @@ class CustomDataReaderListener : public DataReaderListener } void on_requested_incompatible_qos( - DataReader* /*reader*/, + DataReader* reader, const RequestedIncompatibleQosStatus& info) override { std::cout << "Found a remote Topic with incompatible QoS (QoS ID: " << info.last_policy_id << @@ -3530,7 +3610,7 @@ void dds_dataReader_examples() } // Set the QoS on the DataWriter to the default - if (data_reader->set_qos(DATAREADER_QOS_DEFAULT) != ReturnCode_t::RETCODE_OK) + if (data_reader->set_qos(DATAREADER_QOS_DEFAULT) != RETCODE_OK) { // Error return; @@ -3538,7 +3618,7 @@ void dds_dataReader_examples() // The previous instruction is equivalent to the following: if (data_reader->set_qos(subscriber->get_default_datareader_qos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3561,14 +3641,14 @@ void dds_dataReader_examples() // (...) // Delete the entities the DataReader created - if (data_reader->delete_contained_entities() != ReturnCode_t::RETCODE_OK) + if (data_reader->delete_contained_entities() != RETCODE_OK) { // DataReader failed to delete the entities it created. return; } // Delete the DataReader - if (subscriber->delete_datareader(data_reader) != ReturnCode_t::RETCODE_OK) + if (subscriber->delete_datareader(data_reader) != RETCODE_OK) { // Error return; @@ -3585,7 +3665,7 @@ void dds_dataReader_examples() // (...) // Set as the new default DataReaderQos - if (subscriber->set_default_datareader_qos(qos_type1) != ReturnCode_t::RETCODE_OK) + if (subscriber->set_default_datareader_qos(qos_type1) != RETCODE_OK) { // Error return; @@ -3607,7 +3687,7 @@ void dds_dataReader_examples() // (...) // Set as the new default DataReaderQos - if (subscriber->set_default_datareader_qos(qos_type2) != ReturnCode_t::RETCODE_OK) + if (subscriber->set_default_datareader_qos(qos_type2) != RETCODE_OK) { // Error return; @@ -3624,7 +3704,7 @@ void dds_dataReader_examples() // Resetting the default DataReaderQos to the original default constructed values if (subscriber->set_default_datareader_qos(DATAREADER_QOS_DEFAULT) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3632,7 +3712,7 @@ void dds_dataReader_examples() // The previous instruction is equivalent to the following if (subscriber->set_default_datareader_qos(DataReaderQos()) - != ReturnCode_t::RETCODE_OK) + != RETCODE_OK) { // Error return; @@ -3669,9 +3749,9 @@ void dds_dataReader_examples() while (true) { ConditionSeq active_conditions; - if (ReturnCode_t::RETCODE_OK == wait_set.wait(active_conditions, timeout)) + if (RETCODE_OK == wait_set.wait(active_conditions, timeout)) { - while (ReturnCode_t::RETCODE_OK == data_reader->take_next_sample(&data, &info)) + while (RETCODE_OK == data_reader->take_next_sample(&data, &info)) { if (info.valid_data) { @@ -3722,7 +3802,7 @@ void dds_dataReader_examples() { if (data_reader->wait_for_unread_message(timeout)) { - if (ReturnCode_t::RETCODE_OK == data_reader->take_next_sample(&data, &info)) + if (RETCODE_OK == data_reader->take_next_sample(&data, &info)) { if (info.valid_data) { @@ -3750,7 +3830,7 @@ void dds_dataReader_examples() { //READING-INSTANCE - if (ReturnCode_t::RETCODE_OK == data_reader->take_next_sample(&data, &info)) + if (RETCODE_OK == data_reader->take_next_sample(&data, &info)) { if (info.valid_data) { @@ -3801,7 +3881,7 @@ void dds_dataReader_examples() ANY_VIEW_STATE, ANY_INSTANCE_STATE); // process the returned data - if (ret_code == ReturnCode_t::RETCODE_OK) + if (ret_code == RETCODE_OK) { // Both info_seq.length() and data_seq.length() will have the number of samples returned for (FooSeq::size_type n = 0; n < info_seq.length(); ++n) @@ -3844,7 +3924,7 @@ class CustomizedDataReaderListener : public DataReaderListener SampleInfo info; // Keep taking data until there is nothing to take - while (reader->take_next_sample(&data, &info) == ReturnCode_t::RETCODE_OK) + while (reader->take_next_sample(&data, &info) == RETCODE_OK) { if (info.valid_data) { @@ -4389,17 +4469,6 @@ void dds_qos_examples() } } -void dds_dynamic_types_examples () -{ - { - //DDS_TYPELOOKUP_SERVICE_ENABLING - DomainParticipantQos qos; - qos.wire_protocol().builtin.typelookup_config.use_client = true; - qos.wire_protocol().builtin.typelookup_config.use_server = true; - //!-- - } -} - void log_examples() { //LOG_MESSAGES @@ -4524,11 +4593,847 @@ void log_examples() } +void dynamictypes_examples() +{ + { + //!--CPP_PRIMITIVES + // Define a struct type with various primitive members + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("PrimitivesStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define and add primitive members to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_bool"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_octet"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BYTE)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_char"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_wchar"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR16)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_long"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_ulong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_int8"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT8)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_uint8"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT8)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_short"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_ushort"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_longlong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_ulonglong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT64)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_float"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT32)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_double"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT64)); + struct_builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->name("my_longdouble"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT128)); + struct_builder->add_member(member_descriptor); + + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for a member of type int32_t + int32_t in_value {2}; + int32_t out_value {0}; + data->set_int32_value(data->get_member_id_by_name("my_long"), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name("my_long")); + //!-- + } + { + //!--CPP_STRINGS + // Define a struct type to contain the strings + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("StringsStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define and add string members to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + + member_descriptor->name("my_string"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_string_type(static_cast(LENGTH_UNLIMITED))->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_STRING8); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); + type_descriptor->bound().push_back(static_cast(LENGTH_UNLIMITED)); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)->build()); + */ + + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_wstring"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_wstring_type(static_cast(LENGTH_UNLIMITED))->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_STRING16); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR16)); + type_descriptor->bound().push_back(static_cast(LENGTH_UNLIMITED)); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)->build()); + */ + + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_bounded_string"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_string_type(41925)->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_STRING8); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); + type_descriptor->bound().push_back(41925); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)->build()); + */ + + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_bounded_wstring"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_wstring_type(20925)->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_STRING16); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR16)); + type_descriptor->bound().push_back(20925); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)->build()); + */ + + struct_builder->add_member(member_descriptor); + + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for a string member + std::string in_value {"helloworld"}; + std::string out_value; + data->set_string_value(data->get_member_id_by_name("my_string"), in_value); + data->get_string_value(out_value, data->get_member_id_by_name("my_string")); + //!-- + } + { + //!--CPP_ENUM + enum MyEnum : uint32_t + { + A, + B, + C + }; + + // Define a struct type to contain an enum + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("EnumStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Define the enum type + TypeDescriptor::_ref_type enum_type_descriptor {traits::make_shared()}; + enum_type_descriptor->kind(TK_ENUM); + enum_type_descriptor->name("MyEnum"); + DynamicTypeBuilder::_ref_type enum_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(enum_type_descriptor)}; + // Add enum literals to the enum type + MemberDescriptor::_ref_type enum_member_descriptor {traits::make_shared()}; + enum_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + enum_member_descriptor->name("A"); + enum_builder->add_member(enum_member_descriptor); + enum_member_descriptor = traits::make_shared(); + enum_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + enum_member_descriptor->name("B"); + enum_builder->add_member(enum_member_descriptor); + enum_member_descriptor = traits::make_shared(); + enum_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + enum_member_descriptor->name("C"); + enum_builder->add_member(enum_member_descriptor); + // Build the enum type + DynamicType::_ref_type enum_type = enum_builder->build(); + + // Add an enum member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_enum"); + member_descriptor->type(enum_type); + struct_builder->add_member(member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for an enum member + MyEnum in_value {MyEnum::C}; + + /* Alternative + uint32_t in_value {2}; // Selecting MyEnum::C + */ + + uint32_t out_value {0}; + data->set_uint32_value(data->get_member_id_by_name("my_enum"), in_value); + data->get_uint32_value(out_value, data->get_member_id_by_name("my_enum")); + //!-- + } + { + //!--CPP_BITMASK + // Define a struct type to contain a bitmask + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("BitmaskStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define the bitmask type + DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_bitmask_type(8)}; + + /* Alternative + TypeDescriptor::_ref_type bitmask_type_descriptor {traits::make_shared()}; + bitmask_type_descriptor->kind(TK_BITMASK); + bitmask_type_descriptor->name("MyBitMask"); + bitmask_type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type( + TK_BOOLEAN)); + bitmask_type_descriptor->bound().push_back(8); + DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + bitmask_type_descriptor)}; + */ + + // Add bitfield members to the bitmask type + MemberDescriptor::_ref_type bitfield_member_descriptor {traits::make_shared()}; + bitfield_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + bitfield_member_descriptor->name("flag0"); + bitfield_member_descriptor->id(0); + bitmask_builder->add_member(bitfield_member_descriptor); + bitfield_member_descriptor = traits::make_shared(); + bitfield_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + bitfield_member_descriptor->name("flag1"); + bitmask_builder->add_member(bitfield_member_descriptor); + bitfield_member_descriptor = traits::make_shared(); + bitfield_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + bitfield_member_descriptor->name("flag2"); + bitmask_builder->add_member(bitfield_member_descriptor); + bitfield_member_descriptor = traits::make_shared(); + bitfield_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + bitfield_member_descriptor->name("flag5"); + bitfield_member_descriptor->id(5); + bitmask_builder->add_member(bitfield_member_descriptor); + // Build the bitmask type + DynamicType::_ref_type bitmask_type = bitmask_builder->build(); + + // Add a bitmask member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_bitmask"); + member_descriptor->type(bitmask_type); + struct_builder->add_member(member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for bitmask member. + uint8_t in_value {3}; // Setting both "flag0" and "flag1" simultaneously. + uint8_t out_value {0}; + data->set_uint8_value(data->get_member_id_by_name("my_bitmask"), in_value); + data->get_uint8_value(out_value, data->get_member_id_by_name("my_bitmask")); + + // Set and retrieve specific bitflag + bool in_bitflag_value = true; + bool out_bitflag_value = false; + DynamicData::_ref_type bitmask_data = data->loan_value(data->get_member_id_by_name("my_bitmask")); + bitmask_data->set_boolean_value(bitmask_data->get_member_id_by_name("flag5"), in_bitflag_value); + bitmask_data->get_boolean_value(out_bitflag_value, bitmask_data->get_member_id_by_name("flag5")); + //!-- + } + { + // Type created as described in enumeration type section. + enum MyEnum : int32_t + { + A, + B, + C + }; + DynamicType::_ref_type enum_type; + + //!--CPP_TYPEDEF + // Define a struct type to contain the alias + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("AliasStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define an alias type for the enum + TypeDescriptor::_ref_type aliasenum_type_descriptor {traits::make_shared()}; + aliasenum_type_descriptor->kind(TK_ALIAS); + aliasenum_type_descriptor->name("MyAliasedEnum"); + aliasenum_type_descriptor->base_type(enum_type); + DynamicTypeBuilder::_ref_type aliasenum_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(aliasenum_type_descriptor)}; + // Build the alias type + DynamicType::_ref_type aliasenum_type = aliasenum_builder->build(); + + // Define an alias type for a bounded string + TypeDescriptor::_ref_type alias_bounded_string_type_descriptor {traits::make_shared()}; + alias_bounded_string_type_descriptor->kind(TK_ALIAS); + alias_bounded_string_type_descriptor->name("MyAliasedBoundedString"); + alias_bounded_string_type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> + create_string_type(100)->build()); + DynamicTypeBuilder::_ref_type alias_bounded_string_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(alias_bounded_string_type_descriptor)}; + // Build the alias type for the bounded string + DynamicType::_ref_type alias_bounded_string_type = alias_bounded_string_builder->build(); + + // Define a recursive alias + TypeDescriptor::_ref_type recursive_alias_type_descriptor {traits::make_shared()}; + recursive_alias_type_descriptor->kind(TK_ALIAS); + recursive_alias_type_descriptor->name("MyRecursiveAlias"); + recursive_alias_type_descriptor->base_type(aliasenum_type); + DynamicTypeBuilder::_ref_type recursive_alias_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(recursive_alias_type_descriptor)}; + // Build the recursive alias type + DynamicType::_ref_type recursive_alias_type = recursive_alias_builder->build(); + + // Add alias enum member to the structure + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_aliased_enum"); + member_descriptor->type(aliasenum_type); + struct_builder->add_member(member_descriptor); + // Add alias bounded string member to the structure + member_descriptor = traits::make_shared(); + member_descriptor->name("my_aliased_bounded_string"); + member_descriptor->type(alias_bounded_string_type); + struct_builder->add_member(member_descriptor); + // Add recursive alias member to the structure + member_descriptor = traits::make_shared(); + member_descriptor->name("my_recursive_alias"); + member_descriptor->type(recursive_alias_type); + struct_builder->add_member(member_descriptor); + + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for the alias enum member + MyEnum in_value {MyEnum::C}; + int32_t out_value {0}; + data->set_int32_value(data->get_member_id_by_name("my_alias_enum"), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name("my_alias_enum")); + //!-- + } + { + // Type created as described in enumeration type section. + DynamicType::_ref_type bitmask_type; + + //!--CPP_SEQUENCES + // Define a struct type to contain the sequence + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("SequenceStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define a member for the sequence + MemberDescriptor::_ref_type sequence_member_descriptor {traits::make_shared()}; + sequence_member_descriptor->name("bitmask_sequence"); + sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type(bitmask_type, + static_cast(LENGTH_UNLIMITED))->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_SEQUENCE); + type_descriptor->element_type(bitmask_type); + type_descriptor->bound().push_back(static_cast(LENGTH_UNLIMITED)); + sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)->build()); + */ + + // Add the sequence member to the struct + struct_builder->add_member(sequence_member_descriptor); + + sequence_member_descriptor = traits::make_shared(); + sequence_member_descriptor->name("short_sequence"); + sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type( + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16), 5)->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_SEQUENCE); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + type_descriptor->bound().push_back(5); + sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)->build()); + */ + + // Add the sequence member to the struct + struct_builder->add_member(sequence_member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for the sequence member + Int16Seq in_value = {1, 2}; + Int16Seq out_value; + data->set_int16_values(data->get_member_id_by_name("short_sequence"), in_value); + data->get_int16_values(out_value, data->get_member_id_by_name("short_sequence")); + + DynamicData::_ref_type sequence_data {data->loan_value(data->get_member_id_by_name("short_sequence"))}; + // Set the two latest possible values on the sequence + sequence_data->set_int16_values(3, in_value); + // Read every sequence value from index 1 to the end + sequence_data->get_int16_values(out_value, 1); + + int16_t in_simple_value = 8; + int16_t out_simple_value; + sequence_data->set_int16_value(2, in_simple_value); + sequence_data->get_int16_value(out_simple_value, 2); + + data->return_loaned_value(sequence_data); + //!-- + } + { + //!--CPP_ARRAYS + // Define a struct type to contain the array + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("ArrayStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Define a member for the array + MemberDescriptor::_ref_type array_member_descriptor {traits::make_shared()}; + array_member_descriptor->name("long_array"); + array_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_array_type( + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), { 2, 3, 4 })->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_ARRAY); + type_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + type_descriptor->bound().push_back(2); + type_descriptor->bound().push_back(3); + type_descriptor->bound().push_back(4); + array_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)->build()); + */ + + // Add the array member to the struct + struct_builder->add_member(array_member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Set and retrieve values for the array member + Int32Seq in_value = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 23, 24}; + Int32Seq out_value; + data->set_int32_values(data->get_member_id_by_name("long_array"), in_value); + data->get_int32_values(out_value, data->get_member_id_by_name("long_array")); + + DynamicData::_ref_type array_data {data->loan_value(data->get_member_id_by_name("long_array"))}; + // Set the two latest possible values on the array + Int32Seq small_in_value = {0, 1}; + array_data->set_int32_values(22, small_in_value); + // Read every array value from index 1 to the end + array_data->get_int32_values(out_value, 1); + + int32_t in_simple_value = 8; + int32_t out_simple_value; + array_data->set_int32_value(2, in_simple_value); + array_data->get_int32_value(out_simple_value, 2); + + data->return_loaned_value(array_data); + //!-- + } + { + // Type created as described in enumeration type section. + DynamicType::_ref_type alias_bounded_string_type; + + //!--CPP_MAPS + // Define a struct type to contain the map + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("MapStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Define a member for the map + MemberDescriptor::_ref_type map_member_descriptor {traits::make_shared()}; + map_member_descriptor->name("string_long_array_unbounded_map"); + map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_map_type( + DynamicTypeBuilderFactory::get_instance()->create_string_type(static_cast( + LENGTH_UNLIMITED))->build(), alias_bounded_string_type, static_cast( + LENGTH_UNLIMITED))->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_MAP); + type_descriptor->key_element_type(DynamicTypeBuilderFactory::get_instance()->create_string_type( + static_cast(LENGTH_UNLIMITED)->build()); + type_descriptor->element_type(alias_bounded_string_type); + type_descriptor->bound().push_back(static_cast(LENGTH_UNLIMITED)); + map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)->build()); + */ + + // Add the map member to the struct + struct_builder->add_member(map_member_descriptor); + + map_member_descriptor = traits::make_shared(); + map_member_descriptor->name("short_long_map"); + map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_map_type( + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16), + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), 2)->build()); + + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_MAP); + type_descriptor->key_element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + type_descriptor->element_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + type_descriptor->bound().push_back(2); + map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type( + type_descriptor)->build()); + */ + + struct_builder->add_member(map_member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + + // Get the data loan of the map member + DynamicData::_ref_type map_data = data->loan_value(data->get_member_id_by_name("short_long_map")); + + // Set and retrieve values for the map member + int32_t key {1}; + int32_t in_value {2}; + int32_t out_value; + map_data->set_int32_value(map_data->get_member_id_by_name(std::to_string(key)), in_value); + map_data->get_int32_value(out_value, map_data->get_member_id_by_name(std::to_string(key))); + + // Return de data loan of the map member + data->return_loaned_value(map_data); + //!-- + } + { + //!--CPP_STRUCT + // Create inner struct type + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(eprosima::fastdds::dds::TK_STRUCTURE); + type_descriptor->name("InnerStruct"); + DynamicTypeBuilder::_ref_type builder {DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor)}; + // Add members to the inner struct type + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::TK_INT32)); + member_descriptor->name("first"); + member_descriptor->id(16); + builder->add_member(member_descriptor); + // Build the inner struct type + DynamicType::_ref_type inner_struct_type {builder->build()}; + + // Create parent struct type + TypeDescriptor::_ref_type parentstruct_type_descriptor {traits::make_shared()}; + parentstruct_type_descriptor->kind(TK_STRUCTURE); + parentstruct_type_descriptor->name("ParentStruct"); + DynamicTypeBuilder::_ref_type parentstruct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(parentstruct_type_descriptor)}; + // Add members to the parent struct type + MemberDescriptor::_ref_type parentstruct_member {traits::make_shared()}; + parentstruct_member->name("first"); + parentstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT32)); + parentstruct_builder->add_member(parentstruct_member); + parentstruct_member = traits::make_shared(); + parentstruct_member->name("second"); + parentstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + parentstruct_builder->add_member(parentstruct_member); + // Build the parent struct type + DynamicType::_ref_type parentstruct_type = parentstruct_builder->build(); + + // Create complex struct type + TypeDescriptor::_ref_type complexstruct_type_descriptor {traits::make_shared()}; + complexstruct_type_descriptor->kind(TK_STRUCTURE); + complexstruct_type_descriptor->name("ComplexStruct"); + complexstruct_type_descriptor->base_type(parentstruct_type); + DynamicTypeBuilder::_ref_type complexstruct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(complexstruct_type_descriptor)}; + // Add members to the complex struct type + MemberDescriptor::_ref_type complexstruct_member {traits::make_shared()}; + complexstruct_member->name("complex_member"); + complexstruct_member->type(inner_struct_type); + complexstruct_builder->add_member(complexstruct_member); + + // Build the complex struct type + DynamicType::_ref_type complexstruct_type = complexstruct_builder->build(); + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(complexstruct_type)}; + + // Set and retrieve values for member of type float + float in_value {3.14}; + float out_value {0.0}; + data->set_float32_value(data->get_member_id_by_name("first"), in_value); + data->get_float32_value(out_value, data->get_member_id_by_name("first")); + //!-- + } + + { + // Skipped this type creation: same as primitives struct created in previous section. + DynamicType::_ref_type struct_type; + + //!--CPP_UNION + // Define a struct type to contain the union + // Create the inner union + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_UNION); + type_descriptor->name("InnerUnion"); + type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_INT16)); + DynamicTypeBuilder::_ref_type builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Add members to the inner union type + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->type(struct_type); + member_descriptor->name("first"); + member_descriptor->id(16); + member_descriptor->label({0}); + builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_INT64)); + member_descriptor->name("second"); + member_descriptor->label({1}); + member_descriptor->is_default_label(true); + builder->add_member(member_descriptor); + // Build the inner union type + DynamicType::_ref_type inner_union_type {builder->build()}; + + // Create a complex union type + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_UNION); + type_descriptor->name("ComplexUnion"); + type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_INT32)); + builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); + // Add members to the complex union type + member_descriptor = traits::make_shared(); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_INT32)); + member_descriptor->name("third"); + member_descriptor->label({0, 1}); + builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->type(inner_union_type); + member_descriptor->name("fourth"); + member_descriptor->is_default_label(true); + builder->add_member(member_descriptor); + // Build the complex union type + DynamicType::_ref_type union_type {builder->build()}; + + // Create dynamic data based on the union type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(union_type)}; + // Get the loan for the InnerUnion member + DynamicData::_ref_type union_data = data->loan_value(data->get_member_id_by_name("InnerUnion")); + + // Set and retrieve values for the long long member within InnerUnion member + int64_t in_value {2}; + int64_t out_value; + union_data->set_int64_value(union_data->get_member_id_by_name("second"), in_value); + union_data->get_int64_value(out_value, union_data->get_member_id_by_name("second")); + // Return de data loan of the member + data->return_loaned_value(union_data); + //!-- + } + { + //!--CPP_BITSET + // Define a struct type to contain the bitset + TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; + struct_type_descriptor->kind(TK_STRUCTURE); + struct_type_descriptor->name("BitsetStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + struct_type_descriptor)}; + + // Define type for parent bitset + TypeDescriptor::_ref_type bitset_type_descriptor {traits::make_shared()}; + bitset_type_descriptor->kind(TK_BITSET); + bitset_type_descriptor->name("ParentBitSet"); + bitset_type_descriptor->bound({3, 1, 10, 12}); + DynamicTypeBuilder::_ref_type bitset_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + bitset_type_descriptor)}; + // Add members to the bitset type + MemberDescriptor::_ref_type bitset_member_descriptor {traits::make_shared()}; + bitset_member_descriptor->name("a"); + bitset_member_descriptor->id(0); + bitset_builder->add_member(bitset_member_descriptor); + bitset_member_descriptor = traits::make_shared(); + bitset_member_descriptor->name("b"); + bitset_member_descriptor->id(3); + bitset_builder->add_member(bitset_member_descriptor); + bitset_member_descriptor = traits::make_shared(); + bitset_member_descriptor->name("c"); + bitset_member_descriptor->id(8); + bitset_builder->add_member(bitset_member_descriptor); + bitset_member_descriptor = traits::make_shared(); + bitset_member_descriptor->name("d"); + bitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + bitset_member_descriptor->id(18); + bitset_builder->add_member(bitset_member_descriptor); + // Build the bitset type + DynamicType::_ref_type parentbitset_type = bitset_builder->build(); + + // Create child bitset type + TypeDescriptor::_ref_type childbitset_type_descriptor {traits::make_shared()}; + childbitset_type_descriptor->kind(TK_BITSET); + childbitset_type_descriptor->name("ChildBitSet"); + childbitset_type_descriptor->base_type(parentbitset_type); + childbitset_type_descriptor->bound({1, 20}); + DynamicTypeBuilder::_ref_type childbitset_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + childbitset_type_descriptor)}; + // Add members to the child bitset type + MemberDescriptor::_ref_type childbitset_member_descriptor {traits::make_shared()}; + childbitset_member_descriptor->name("e"); + childbitset_member_descriptor->id(30); + childbitset_builder->add_member(childbitset_member_descriptor); + childbitset_member_descriptor = traits::make_shared(); + childbitset_member_descriptor->name("d"); + childbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + childbitset_member_descriptor->id(31); + childbitset_builder->add_member(childbitset_member_descriptor); + // Build the child bitset type + DynamicType::_ref_type bitset_type = childbitset_builder->build(); + + // Add the bitset member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_bitset"); + member_descriptor->type(bitset_type); + struct_builder->add_member(member_descriptor); + // Build the struct type + DynamicType::_ref_type struct_type {struct_builder->build()}; + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; + // Get the loan for the bitset member + DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name("my_bitset")); + + // Set and retrieve bitfield values + int16_t in_value {2}; + int16_t out_value; + bitset_data->set_int16_value(bitset_data->get_member_id_by_name("d"), in_value); + bitset_data->get_int16_value(out_value, bitset_data->get_member_id_by_name("d")); + // Return de data loan of the member + data->return_loaned_value(bitset_data); + //!-- + } + { + //!--CPP_CUSTOM_ANNOTATION + // Create the structure to annotate + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name("AnnotatedStruct"); + DynamicTypeBuilder::_ref_type type_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("string_var"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_string_type(static_cast( + LENGTH_UNLIMITED))->build()); + type_builder->add_member(member_descriptor); + + // Create the annotation type + AnnotationDescriptor::_ref_type annotation_descriptor {traits::make_shared()}; + TypeDescriptor::_ref_type annotation_type {traits::make_shared()}; + annotation_type->kind(TK_ANNOTATION); + annotation_type->name("MyAnnotation"); + DynamicTypeBuilder::_ref_type annotation_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(annotation_type)}; + + // Add members to the annotation type + MemberDescriptor::_ref_type annotation_parameter {traits::make_shared()}; + annotation_parameter->name("length"); + annotation_parameter->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + annotation_builder->add_member(annotation_parameter); + // Set the annotation type using the annotation descriptor + annotation_descriptor->type(annotation_builder->build()); + // Set the value of the annotation + annotation_descriptor->set_value("length", std::to_string(5)); + // Apply the annotation to the structure + type_builder->apply_annotation(annotation_descriptor); + + // Reuse annotation descriptor to annotate struct member + annotation_descriptor = traits::make_shared(); + annotation_descriptor->type(annotation_builder->build()); + annotation_descriptor->set_value("length", std::to_string(10)); + + DynamicTypeMember::_ref_type member; + type_builder->get_member_by_name(member, "string_var"); + type_builder->apply_annotation_to_member(member->get_id(), annotation_descriptor); + //!-- + } + { + // Complex struct type defined previously + DynamicType::_ref_type complexstruct_type; + //!--CPP_COMPLEX_DATA + // Create dynamic data based on the struct type + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(complexstruct_type)}; + + // Get/Set complex API (copy) + DynamicData::_ref_type complex_data; + data->get_complex_value(complex_data, data->get_member_id_by_name("complex_member")); + // Set data + int32_t in_value {10}; + complex_data->set_int32_value(complex_data->get_member_id_by_name("first"), in_value); + data->set_complex_value(data->get_member_id_by_name("complex_member"), complex_data); + + // Loan API + DynamicData::_ref_type loan_data = data->loan_value(data->get_member_id_by_name("complex_member")); + loan_data->set_int32_value(loan_data->get_member_id_by_name("first"), in_value); + int32_t out_value; + loan_data->get_int32_value(out_value, loan_data->get_member_id_by_name("first")); + data->return_loaned_value(loan_data); + //!-- + } +} + void xml_profiles_examples() { { //XML-LOAD-APPLY-PROFILES - if (ReturnCode_t::RETCODE_OK == + if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { DomainParticipant* participant = @@ -4550,7 +5455,7 @@ void xml_profiles_examples() \ \ \ - \ + \ \ \ TRANSIENT_LOCAL\ @@ -4560,7 +5465,7 @@ void xml_profiles_examples() \ \ "; - if (ReturnCode_t::RETCODE_OK == + if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_string(xml_profile.c_str(), xml_profile.length())) { @@ -4580,16 +5485,21 @@ void xml_profiles_examples() } // Load the XML File - if (ReturnCode_t::RETCODE_OK == + if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { - // Retrieve the an instance of MyStruct type - eprosima::fastrtps::types::DynamicTypeBuilder* type; - DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("MyStruct", type); - eprosima::fastrtps::types::DynamicType_ptr my_struct_type = type->build(); + // Retrieve instance of the desired type + DynamicType::_ref_type my_struct_type; + if (RETCODE_OK != + DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name( + "MyStruct", my_struct_type)) + { + // Error + return; + } // Register MyStruct type - TypeSupport my_struct_type_support(new eprosima::fastrtps::types::DynamicPubSubType(my_struct_type)); + TypeSupport my_struct_type_support(new DynamicPubSubType(my_struct_type)); my_struct_type_support.register_type(participant, nullptr); } else @@ -4603,7 +5513,7 @@ void xml_profiles_examples() { std::string custom_name; //XML-MIX-WITH-CODE - if (ReturnCode_t::RETCODE_OK == + if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { DomainParticipantQos participant_qos; @@ -4888,7 +5798,8 @@ void dds_transport_examples () DomainParticipantQos qos; // Create a descriptor for the new transport. - std::shared_ptr shm_transport = std::make_shared(); + std::shared_ptr shm_transport = + std::make_shared(); // [OPTIONAL] ThreadSettings configuration shm_transport->default_reception_threads(eprosima::fastdds::rtps::ThreadSettings{-1, 0, 0, -1}); @@ -4905,7 +5816,8 @@ void dds_transport_examples () DomainParticipantQos qos; // Create a descriptor for the new transport. - std::shared_ptr shm_transport = std::make_shared(); + std::shared_ptr shm_transport = + std::make_shared(); // Link the Transport Layer to the Participant. qos.transport().user_transports.push_back(shm_transport); @@ -5467,7 +6379,7 @@ void dds_usecase_examples() //CONF_QOS_TUNING_RELIABLE_WRITER DataWriterQos qos; qos.reliable_writer_qos().times.heartbeatPeriod.seconds = 0; - qos.reliable_writer_qos().times.heartbeatPeriod.nanosec = 500000000; //500 ms + qos.reliable_writer_qos().times.heartbeatPeriod.nanosec = 500000000; //500 ms //!-- } @@ -5753,28 +6665,38 @@ void dds_persistence_examples() ********************************************************************************************************/ // Create a struct builder for a type with name "persistence_topic_type" const std::string topic_type_name = "persistence_topic_type"; - eprosima::fastrtps::types::DynamicTypeBuilder_ptr struct_type_builder( - eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_struct_builder()); - struct_type_builder->set_name(topic_type_name); + + TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; + struct_type_descriptor->kind(TK_STRUCTURE); + struct_type_descriptor->name(topic_type_name); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(struct_type_descriptor)}; // The type consists of two members, and index and a message. Add members to the struct. - struct_type_builder->add_member(0, "index", - eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_uint32_type()); - struct_type_builder->add_member(1, "message", - eprosima::fastrtps::types::DynamicTypeBuilderFactory::get_instance()->create_string_type()); + MemberDescriptor::_ref_type index_member_descriptor {traits::make_shared()}; + index_member_descriptor->name("index"); + index_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_UINT32)); + struct_builder->add_member(index_member_descriptor); + + MemberDescriptor::_ref_type message_member_descriptor {traits::make_shared()}; + message_member_descriptor->name("message"); + message_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_string_type(static_cast(LENGTH_UNLIMITED))->build()); + struct_builder->add_member(message_member_descriptor); // Build the type - eprosima::fastrtps::types::DynamicType_ptr dyn_type_ptr = struct_type_builder->build(); + DynamicType::_ref_type struct_type {struct_builder->build()}; // Create type support and register the type - TypeSupport type_support(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type_ptr)); + TypeSupport type_support(new DynamicPubSubType(struct_type)); type_support.register_type(participant); // Create data sample a populate data. This is to be used when calling `writer->write()` - eprosima::fastrtps::types::DynamicData* dyn_helloworld; - dyn_helloworld = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dyn_type_ptr); + DynamicData::_ref_type dyn_helloworld {DynamicDataFactory::get_instance()->create_data(struct_type)}; + dyn_helloworld->set_uint32_value(0, 0); - dyn_helloworld->set_string_value("HelloWorld", 1); + dyn_helloworld->set_string_value(1, "HelloWorld"); /******************************************************************************************************** * END CREATE TYPE AND TYPE SUPPORT ********************************************************************************************************/ @@ -5813,21 +6735,21 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp } bool serialize( - void* /*data*/, - eprosima::fastrtps::rtps::SerializedPayload_t* /*payload*/) override + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override { return true; } bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* /*payload*/, - void* /*data*/) override + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override { return true; } std::function getSerializedSizeProvider( - void* /*data*/) override + void* data) override { return std::function(); } @@ -5838,14 +6760,14 @@ class LoanableHelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataTyp } void deleteData( - void* /*data*/) override + void* data) override { } bool getKey( - void* /*data*/, - eprosima::fastrtps::rtps::InstanceHandle_t* /*ihandle*/, - bool /*force_md5*/) override + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5) override { return true; } @@ -5928,7 +6850,7 @@ void dds_zero_copy_example() // Always call loan_sample() before writing a new sample. // This function will provide the user with a pointer to an internal buffer where the data type can be // prepared for sending. - if (ReturnCode_t::RETCODE_OK == writer->loan_sample(sample)) + if (RETCODE_OK == writer->loan_sample(sample)) { // Modify the sample data LoanableHelloWorld* data = static_cast(sample); @@ -5965,7 +6887,7 @@ void dds_zero_copy_example() DataSeq data; SampleInfoSeq infos; // Access to the collection of data-samples and its corresponding collection of SampleInfo structures - while (ReturnCode_t::RETCODE_OK == reader->take(data, infos)) + while (RETCODE_OK == reader->take(data, infos)) { // Iterate over each LoanableCollection in the SampleInfo sequence for (LoanableCollection::size_type i = 0; i < infos.length(); ++i) @@ -6074,7 +6996,8 @@ void dds_request_reply_example_client() eprosima::fastdds::dds::DomainParticipantQos participant_qos; eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->get_default_participant_qos(participant_qos); - DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, participant_qos); + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, participant_qos); TypeSupport request_type; TypeSupport reply_type; @@ -6089,7 +7012,8 @@ void dds_request_reply_example_client() Topic* request_topic = participant->create_topic("CalculatorRequest", request_type.get_type_name(), TOPIC_QOS_DEFAULT); - Topic* reply_topic = participant->create_topic("CalculatorReply", reply_type.get_type_name(), TOPIC_QOS_DEFAULT); + Topic* reply_topic = + participant->create_topic("CalculatorReply", reply_type.get_type_name(), TOPIC_QOS_DEFAULT); DataWriter* request_writer = publisher->create_datawriter(request_topic, DATAWRITER_QOS_DEFAULT); @@ -6140,7 +7064,8 @@ void dds_request_reply_example_server() eprosima::fastdds::dds::DomainParticipantQos participant_qos; eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->get_default_participant_qos(participant_qos); - DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, participant_qos); + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, participant_qos); TypeSupport request_type; TypeSupport reply_type; @@ -6156,7 +7081,8 @@ void dds_request_reply_example_server() Topic* request_topic = participant->create_topic("CalculatorRequest", request_type.get_type_name(), TOPIC_QOS_DEFAULT); - Topic* reply_topic = participant->create_topic("CalculatorReply", reply_type.get_type_name(), TOPIC_QOS_DEFAULT); + Topic* reply_topic = + participant->create_topic("CalculatorReply", reply_type.get_type_name(), TOPIC_QOS_DEFAULT); DataWriter* reply_writer = publisher->create_datawriter(reply_topic, DATAWRITER_QOS_DEFAULT); @@ -6180,7 +7106,7 @@ void dds_waitset_example() { auto create_dds_application = [](std::vector&, std::vector&) -> ReturnCode_t { - return ReturnCode_t::RETCODE_OK; + return RETCODE_OK; }; auto destroy_dds_application = []() -> void @@ -6203,7 +7129,7 @@ void dds_waitset_example() ReturnCode_t ret_code; ConditionSeq triggered_conditions; ret_code = wait_set_.wait(triggered_conditions, eprosima::fastrtps::c_TimeInfinite); - if (ReturnCode_t::RETCODE_OK != ret_code) + if (RETCODE_OK != ret_code) { // ... handle error continue; @@ -6221,7 +7147,8 @@ void dds_waitset_example() // Process status. Liveliness changed and data available are depicted as an example if (changed_statuses.is_active(StatusMask::liveliness_changed())) { - std::cout << "Liveliness changed reported for entity " << entity->get_instance_handle() << + std::cout << "Liveliness changed reported for entity " << + entity->get_instance_handle() << std::endl; } @@ -6234,7 +7161,7 @@ void dds_waitset_example() DataReader* reader = static_cast(entity); // Process all the samples until no one is returned - while (ReturnCode_t::RETCODE_OK == reader->take(data_seq, info_seq, + while (RETCODE_OK == reader->take(data_seq, info_seq, LENGTH_UNLIMITED, ANY_SAMPLE_STATE, ANY_VIEW_STATE, ANY_INSTANCE_STATE)) { @@ -6242,7 +7169,8 @@ void dds_waitset_example() for (FooSeq::size_type n = 0; n < info_seq.length(); ++n) { // Only samples with valid data should be accessed - if (info_seq[n].valid_data && reader->is_sample_valid(&data_seq[n], &info_seq[n])) + if (info_seq[n].valid_data && + reader->is_sample_valid(&data_seq[n], &info_seq[n])) { // Process sample on data_seq[n] } @@ -6296,7 +7224,7 @@ void dds_waitset_example() // Create the participant, topics, readers, and writers. ret_code = create_dds_application(application_readers, application_writers); - if (ReturnCode_t::RETCODE_OK != ret_code) + if (RETCODE_OK != ret_code) { // ... handle error return; @@ -6543,9 +7471,9 @@ void pubsub_api_example_create_entities() //!-- //PUBSUB_API_WRITE_SAMPLE - HelloWorld sample; //Auto-generated container class for topic data from Fast DDS-Gen - sample.msg("Hello there!"); // Add contents to the message - data_writer->write(&sample); //Publish + HelloWorld sample; //Auto-generated container class for topic data from Fast DDS-Gen + sample.msg("Hello there!"); // Add contents to the message + data_writer->write(&sample); //Publish //!-- //PUBSUB_API_CREATE_SUBSCRIBER @@ -6577,7 +7505,7 @@ int main( { std::string file = argv[1]; DomainParticipantFactory* factory = DomainParticipantFactory::get_instance(); - if (ReturnCode_t::RETCODE_OK != factory->check_xml_static_discovery(file)) + if (RETCODE_OK != factory->check_xml_static_discovery(file)) { printf("Error parsing xml file %s\n", argv[1]); exit_code = -1; @@ -6595,7 +7523,7 @@ int main( "" \ "" \ ""; - if (ReturnCode_t::RETCODE_OK != factory->check_xml_static_discovery(fileData)) + if (RETCODE_OK != factory->check_xml_static_discovery(fileData)) { printf("Error parsing xml file %s\n", argv[1]); exit_code = -1; @@ -6603,8 +7531,7 @@ int main( } else { - if (ReturnCode_t::RETCODE_OK != - DomainParticipantFactory::get_instance()->load_XML_profiles_file(argv[1])) + if (RETCODE_OK != DomainParticipantFactory::get_instance()->load_XML_profiles_file(argv[1])) { printf("Error parsing xml file %s\n", argv[1]); exit_code = -1; diff --git a/code/DynamicTypesIDLExamples.idl b/code/DynamicTypesIDLExamples.idl new file mode 100644 index 000000000..1c8336c82 --- /dev/null +++ b/code/DynamicTypesIDLExamples.idl @@ -0,0 +1,204 @@ +//!--TYPEINFORMATION +@extensibility(APPENDABLE) @nested +struct TypeIdentfierWithSize +{ + TypeIdentifier type_id; + unsigned long typeobject_serialized_size; +}; + +@extensibility(APPENDABLE) @nested +struct TypeIdentifierWithDependencies +{ + TypeIdentfierWithSize typeid_with_size; + long dependent_type_id_count; + sequence dependent_typeids; +}; + +@extensibility(MUTABLE) @nested +struct TypeInformation +{ + @id(0x1001) TypeIdentifierWithDependencies minimal; + @id(0x1002) TypeIdentifierWithDependencies complete; +}; +//!-- + +//!--TYPEOBJECT +@extensibility(APPENDABLE) @nested +union TypeObject switch(octet) +{ + case EK_COMPLETE: + CompleteTypeObject complete; + case EK_MINIMAL: + MinimalTypeObject minimal; +}; +//!-- + +//!--IDL_PRIMITIVES +struct PrimitivesStruct +{ + boolean my_bool; + octet my_octet; + char my_char; + wchar my_wchar; + long my_long; + unsigned long my_ulong; + int8 my_int8; + uint8 my_uint8; + short my_short; + unsigned short my_ushort; + long long my_longlong; + unsigned long long my_ulonglong; + float my_float; + double my_double; + long double my_longdouble; +}; +//!-- + +//!--IDL_STRINGS +struct StringsStruct +{ + string my_string; + wstring my_wstring; + string<41925> my_bounded_string; + wstring<20925> my_bounded_wstring; +}; +//!-- + +//!--IDL_ENUM +enum MyEnum +{ + A, + B, + C +}; + +struct EnumStruct +{ + MyEnum my_enum; +}; +//!-- + +//!--IDL_BITMASK +@bit_bound(8) +bitmask MyBitMask +{ + @position(0) flag0, + flag1, + flag2, + @position(5) flag5 +}; + +struct BitmaskStruct +{ + MyBitMask my_bitmask; +}; +//!-- + +//!--IDL_TYPEDEF +typedef MyEnum MyAliasedEnum; +typedef string<100> MyAliasedBoundedString; +typedef MyAliasedEnum MyRecursiveAlias; + +struct AliasStruct +{ + MyAliasedEnum my_aliased_enum; + MyAliasedBoundedString my_aliased_bounded_string; + MyRecursiveAlias my_recursive_alias; +}; +//!-- + +//!--IDL_SEQUENCES +struct SequenceStruct +{ + sequence bitmask_sequence; + sequence short_sequence; +}; +//!-- + +//!--IDL_ARRAYS +struct ArrayStruct +{ + long long_array[2][3][4]; +}; +//!-- + +//!--IDL_MAPS +struct MapStruct +{ + map string_alias_unbounded_map; + map short_long_map; +}; +//!-- + +//!--IDL_STRUCT +struct InnerStruct +{ + @id(0x10) long first; +}; + +struct ParentStruct +{ + float first; + long long second; +}; + +struct ComplexStruct : ParentStruct +{ + InnerStruct complex_member; +}; +//!-- + +//!--IDL_UNION +union InnerUnion switch (short) +{ + case 0: + @id(0x10) PrimitivesStruct first; + case 1: + default: + long long second; +}; + +union ComplexUnion switch (long) +{ + case 0: + case 1: + long third; + default: + InnerUnion fourth; +}; +//!-- + +//!--IDL_BITSET +bitset ParentBitSet +{ + bitfield<3> a; + bitfield<1> b; + bitfield<4>; + bitfield<10> c; + bitfield<12, short> d; +}; + +bitset ChildBitSet : ParentBitSet +{ + bitfield<1> e; + bitfield<20, unsigned long> f; +}; + +struct BitsetStruct +{ + ChildBitSet my_bitset; +}; +//!-- + +//!--IDL_CUSTOM_ANNOTATION +@annotation MyAnnotation +{ + short length; +}; + +@MyAnnotation(length = 5) +struct AnnotatedStruct +{ + @MyAnnotation(length = 10) string string_var; +}; +//!-- diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx b/code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx deleted file mode 100644 index 4b415d677..000000000 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -HelloWorld::HelloWorld() -{ -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void HelloWorld::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.h b/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp similarity index 69% rename from code/Examples/C++/DDSHelloWorld/src/HelloWorld.h rename to code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp index 5cd0ddba5..971fea8d9 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.h +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "HelloWorldv1.h" +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -86,73 +62,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +180,40 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _message); + const std::string& _message) + { + m_message = _message; + } /*! * @brief This function moves the value in member message * @param _message New value to be moved in member message */ eProsima_user_DllExport void message( - std::string&& _message); + std::string&& _message) + { + m_message = std::move(_message); + } /*! * @brief This function returns a constant reference to member message * @return Constant reference to member message */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -188,8 +222,6 @@ class HelloWorld }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.hpp b/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.hpp index 9f346d306..6feb8a9da 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.hpp +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#include "HelloWorld.h" +#include "HelloWorld.hpp" constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.ipp b/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.ipp index 42e91f3cc..97df3fe9d 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.ipp +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx index 85cb47789..db018e697 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx @@ -19,18 +19,18 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.h" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); @@ -219,3 +219,11 @@ bool HelloWorldPubSubType::getKey( return true; } +void HelloWorldPubSubType::register_type_object_representation() const +{ + register_HelloWorld_type_objects(); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.h b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.h index 545c68b12..a9b4ac119 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.h +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.h @@ -29,7 +29,7 @@ #include #include -#include "HelloWorld.h" +#include "HelloWorld.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -90,6 +88,9 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() const override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldSubscriber.cpp b/code/Examples/C++/DDSHelloWorld/src/HelloWorldSubscriber.cpp index 3fdf6d13a..af659b555 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldSubscriber.cpp +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldSubscriber.cpp @@ -75,7 +75,7 @@ class HelloWorldSubscriber else { std::cout << info.current_count_change - << " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl; + << " is not a valid value for SubscriptionMatchedStatus current count change" << std::endl; } } @@ -83,13 +83,13 @@ class HelloWorldSubscriber DataReader* reader) override { SampleInfo info; - if (reader->take_next_sample(&hello_, &info) == ReturnCode_t::RETCODE_OK) + if (reader->take_next_sample(&hello_, &info) == eprosima::fastdds::dds::RETCODE_OK) { if (info.valid_data) { samples_++; std::cout << "Message: " << hello_.message() << " with index: " << hello_.index() - << " RECEIVED." << std::endl; + << " RECEIVED." << std::endl; } } } @@ -98,7 +98,8 @@ class HelloWorldSubscriber std::atomic_int samples_; - } listener_; + } + listener_; public: @@ -172,13 +173,14 @@ class HelloWorldSubscriber //!Run the Subscriber void run( - uint32_t samples) + uint32_t samples) { - while(listener_.samples_ < samples) + while (listener_.samples_ < samples) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } + }; int main( @@ -189,7 +191,7 @@ int main( uint32_t samples = 10; HelloWorldSubscriber* mysub = new HelloWorldSubscriber(); - if(mysub->init()) + if (mysub->init()) { mysub->run(samples); } diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.cxx b/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 000000000..bfae95694 --- /dev/null +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,248 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +void register_HelloWorld_type_objects() +{ + static std::once_flag once_flag; + std::call_once(once_flag, []() + { + register_HelloWorld_type_identifier(); + + }); +} + +void register_HelloWorld_type_identifier() +{ + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::NOT_APPLIED, + false, false); + ReturnCode_t return_code_HelloWorld; + TypeIdentifierPair type_ids_HelloWorld; + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_HelloWorld); + + if (return_code_HelloWorld != eprosima::fastdds::dds::RETCODE_OK) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + 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()))) + { + 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."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + 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) + { + 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); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded")) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "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."); + return; + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructKind::NOT_APPLIED, + 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 + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + 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())) + { + 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."); + return; + } + } +} + diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.hpp b/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 000000000..235326d5e --- /dev/null +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,54 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#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 + +/** + * @brief Register HelloWorld 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. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier(); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.cxx b/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.cxx deleted file mode 100644 index 90e82ea88..000000000 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.cxx +++ /dev/null @@ -1,286 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { namespace internal { - -enum class Size { - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size(int s) { - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH { - using type = std::uint8_t; -}; - -template<> -struct FindTypeH { - using type = std::uint16_t; -}; - -template<> -struct FindTypeH { - using type = std::uint32_t; -}; - -template<> -struct FindTypeH { - using type = std::uint64_t; -}; -} - -template -struct FindType { - using type = typename internal::FindTypeH::type; -}; -} - -#define HelloWorld_max_cdr_typesize 268ULL; - - - - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // /type_d() m_message - - -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - return current_alignment - initial_alignment; -} - - -void HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message.c_str(); - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::message( - const std::string& _message) -{ - m_message = _message; -} - -/*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ -void HelloWorld::message( - std::string&& _message) -{ - m_message = std::move(_message); -} - -/*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ -const std::string& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.h b/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.h deleted file mode 100644 index 9f6f726e0..000000000 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldv1.h +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/*! - * @file HelloWorld.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - - -#include - -#include -#include -#include -#include -#include -#include -#include - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#define eProsima_user_DllExport __declspec( dllexport ) -#else -#define eProsima_user_DllExport -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define eProsima_user_DllExport -#endif // _WIN32 - -#if defined(_WIN32) -#if defined(EPROSIMA_USER_DLL_EXPORT) -#if defined(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index); - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const; - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index(); - - - /*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ - eProsima_user_DllExport void message( - const std::string& _message); - - /*! - * @brief This function moves the value in member message - * @param _message New value to be moved in member message - */ - eProsima_user_DllExport void message( - std::string&& _message); - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::string& message() const; - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message(); - - - /*! - * @brief This function returns the maximum serialized size of an object - * depending on the buffer alignment. - * @param current_alignment Buffer alignment. - * @return Maximum serialized size. - */ - eProsima_user_DllExport static size_t getMaxCdrSerializedSize( - size_t current_alignment = 0); - - /*! - * @brief This function returns the serialized size of a data depending on the buffer alignment. - * @param data Data which is calculated its serialized size. - * @param current_alignment Buffer alignment. - * @return Serialized size. - */ - eProsima_user_DllExport static size_t getCdrSerializedSize( - const HelloWorld& data, - size_t current_alignment = 0); - - - - /*! - * @brief This function serializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& cdr) const; - - /*! - * @brief This function deserializes an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr); - - - - - /*! - * @brief This function tells you if the Key has been defined for this type - */ - eProsima_user_DllExport static bool isKeyDefined(); - - /*! - * @brief This function serializes the key members of an object using CDR serialization. - * @param cdr CDR serialization object. - */ - eProsima_user_DllExport void serializeKey( - eprosima::fastcdr::Cdr& cdr) const; - - -private: - - uint32_t m_index; - std::string m_message; - -}; - - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 62fe84c7e..de3183646 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -1465,6 +1465,13 @@ -1 + + -1 + 0 + 0 + -1 + + -1 0 @@ -1643,10 +1650,6 @@ 55 - - true - true - <--> @@ -3893,19 +3896,6 @@ <--> -XML_TYPELOOKUP_SERVICE_ENABLING<--> - - - - - true - true - - - - -<--> - @@ -4309,51 +4299,135 @@ -XML-DYN-ENUM<--> + +XML_PRIMITIVES<--> + + + + + + + + + + + + + + + + + +<--> + +XML_STRINGS<--> + + + + + + +<--> + +XML_ENUM<--> + + + + <--> -XML-TYPEDEF<--> - - - - - - +XML_BITMASK<--> + + + + + + + + + + +<--> + + +XML_TYPEDEF<--> + + + + + + + + + - - - - +<--> + +XML_SEQUENCES<--> + + + + +<--> + +XML_ARRAYS<--> + + <--> -XML-STRUCT<--> - +XML_MAPS<--> + + + + +<--> + +XML_STRUCT<--> + + + + + + <--> -XML-UNION<--> - - +XML_UNION<--> + + + + + - + + + + + - - + + + - + <--> @@ -4405,44 +4479,30 @@ <--> -XML-BITSET<--> - +XML_BITSET<--> + -<--> -XML-BITMASK<--> - - - - - - -<--> -XML-BITSET-INHERIT<--> - - - - - - - + + <--> -XML-STRUCT-INHERIT<--> - - - - - - - - + +XML_CUSTOM_ANNOTATION<--> + <--> + diff --git a/code/XMLTesterExample.xml b/code/XMLTesterExample.xml index b9f6e1248..805cb84f4 100644 --- a/code/XMLTesterExample.xml +++ b/code/XMLTesterExample.xml @@ -385,10 +385,6 @@ 512 512 55 - - true - true - @@ -477,6 +473,13 @@ -1 + + -1 + 0 + 0 + -1 + + -1 0 @@ -988,10 +991,11 @@ - + + @@ -1016,10 +1020,11 @@ - + + diff --git a/docs/01-figures/listeners_inheritance_diagram.svg b/docs/01-figures/listeners_inheritance_diagram.svg index b8c3a6bc3..30d1fa2fd 100644 --- a/docs/01-figures/listeners_inheritance_diagram.svg +++ b/docs/01-figures/listeners_inheritance_diagram.svg @@ -1,4 +1,802 @@ - + - -SubscriberListeneron_data_on_readers()DataReaderListeneron_sample_rejected()on_liveliness_changed()on_requested_deadline_missed()on_requested_incompatible_qos()on_data_available()on_subscription_matched()on_sample_lost()PublisherListenerDataWriterListeneron_offered_incompatible_qos()on_offered_deadline_missed()on_liveliness_lost()on_publication_matched()on_unackowledged_sample_removed()DomainParticipantListeneron_participant_discovery()onParticipantAuthentication()on_subscriber_discovery()on_publisher_discovery()on_type_discovery()on_type_dependencies_reply()on_type_information_received()TopicListeneron_inconsistent_topic() \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SubscriberListener + + + + on_data_on_readers() + + + + + + DataReaderListener + + + + on_sample_rejected() + + + on_liveliness_changed() + + + on_requested_deadline_missed() + + + on_requested_incompatible_qos() + + + on_data_available() + + + on_subscription_matched() + + + on_sample_lost() + + + + + + + + PublisherListener + + + + + + + DataWriterListener + + + + on_offered_incompatible_qos() + + + on_offered_deadline_missed() + + + on_liveliness_lost() + + + on_publication_matched() + + + on_unackowledged_sample_removed() + + + + + + + + DomainParticipantListener + + + + on_participant_discovery() + + + onParticipantAuthentication() + + + on_data_reader_discovery() + + + on_data_writer_discovery() + + + + + + + + + + + TopicListener + + + + on_inconsistent_topic() + + + + + diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 2a50974b6..01db0ec72 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -128,6 +128,7 @@ .. |DomainParticipant::delete_subscriber-api| replace:: :cpp:func:`delete_subscriber()` .. |DomainParticipant::delete_topic-api| replace:: :cpp:func:`delete_topic()` .. |DomainParticipant::delete_contentfilteredtopic-api| replace:: :cpp:func:`delete_contentfilteredtopic()` +.. |DomainParticipant::register_type-api| replace:: :cpp:func:`register_type()` .. |DomainParticipant::register_content_filter_factory-api| replace:: :cpp:func:`register_content_filter_factory()` .. |DomainParticipant::lookup_content_filter_factory-api| replace:: :cpp:func:`lookup_content_filter_factory()` .. |DomainParticipant::unregister_content_filter_factory-api| replace:: :cpp:func:`unregister_content_filter_factory()` @@ -149,19 +150,20 @@ .. |DomainParticipant::enable-monitor-service-api| replace:: :cpp:func:`enable_monitor_service()` .. |DomainParticipant::disable-monitor-service-api| replace:: :cpp:func:`disable_monitor_service()` +.. |DomainParticipant::get_participant_qos_from_profile| replace:: :cpp:func:`get_participant_qos_from_profile()` .. |DomainParticipantFactory-api| replace:: :cpp:class:`DomainParticipantFactory` +.. |DomainParticipantFactory::check_xml_static_discovery-api| replace:: :cpp:func:`DomainParticipantFactory::check_xml_static_discovery()` .. |DomainParticipantFactory::create_participant_with_default_profile-api| replace:: :cpp:func:`create_participant_with_default_profile()` .. |DomainParticipantFactory::create_participant_with_profile-api| replace:: :cpp:func:`create_participant_with_profile()` .. |DomainParticipantFactory::create_participant-api| replace:: :cpp:func:`create_participant()` .. |DomainParticipantFactory::delete_participant-api| replace:: :cpp:func:`delete_participant()` .. |DomainParticipantFactory::get_default_participant_qos-api| replace:: :cpp:func:`get_default_participant_qos()` -.. |DomainParticipant::get_participant_qos_from_profile| replace:: :cpp:func:`get_participant_qos_from_profile()` +.. |DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name-api| replace:: :cpp:func:`DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name()` .. |DomainParticipantFactory::get_instance-api| replace:: :cpp:func:`get_instance()` .. |DomainParticipantFactory::load_XML_profiles_file-api| replace:: :cpp:func:`load_XML_profiles_file()` .. |DomainParticipantFactory::load_XML_profiles_string-api| replace:: :cpp:func:`load_XML_profiles_string()` .. |DomainParticipantFactory::set_default_participant_qos-api| replace:: :cpp:func:`set_default_participant_qos()` .. |DomainParticipantFactory::set_qos-api| replace:: :cpp:func:`DomainParticipantFactory::set_qos()` -.. |DomainParticipantFactory::check_xml_static_discovery-api| replace:: :cpp:func:`DomainParticipantFactory::check_xml_static_discovery()` .. |DomainParticipantFactoryQos-api| replace:: :cpp:class:`DomainParticipantFactoryQos` .. |DomainParticipantFactoryQos::entity_factory-api| replace:: :cpp:func:`entity_factory()` @@ -170,11 +172,8 @@ .. |DomainParticipantListener-api| replace:: :cpp:class:`DomainParticipantListener` .. |DomainParticipantListener::on_participant_discovery-api| replace:: :cpp:func:`on_participant_discovery()` -.. |DomainParticipantListener::on_subscriber_discovery-api| replace:: :cpp:func:`on_subscriber_discovery()` -.. |DomainParticipantListener::on_publisher_discovery-api| replace:: :cpp:func:`on_publisher_discovery()` -.. |DomainParticipantListener::on_type_discovery-api| replace:: :cpp:func:`on_type_discovery()` -.. |DomainParticipantListener::on_type_dependencies_reply-api| replace:: :cpp:func:`on_type_dependencies_reply()` -.. |DomainParticipantListener::on_type_information_received-api| replace:: :cpp:func:`on_type_information_received()` +.. |DomainParticipantListener::on_data_reader_discovery-api| replace:: :cpp:func:`on_data_reader_discovery()` +.. |DomainParticipantListener::on_data_writer_discovery-api| replace:: :cpp:func:`on_data_writer_discovery()` .. |DomainParticipantListener::onParticipantAuthentication-api| replace:: :cpp:func:`onParticipantAuthentication()` .. |DomainParticipantQos-api| replace:: :cpp:class:`DomainParticipantQos` @@ -189,6 +188,7 @@ .. |DomainParticipantQos::builtin_controllers_sender_thread-api| replace:: :cpp:func:`builtin_controllers_sender_thread()` .. |DomainParticipantQos::timed_events_thread-api| replace:: :cpp:func:`timed_events_thread()` .. |DomainParticipantQos::discovery_server_thread-api| replace:: :cpp:func:`discovery_server_thread()` +.. |DomainParticipantQos::typelookup_service_threads-api| replace:: :cpp:func:`typelookup_service_thread()` .. |DomainParticipantQos::security_log_thread-api| replace:: :cpp:func:`security_log_thread()` .. |DomainParticipantQoS::setup_transports-api| replace:: :cpp:func:`setup_transports()` .. |DomainParticipants-api| replace:: :cpp:class:`DomainParticipants ` @@ -285,9 +285,6 @@ .. |TopicQos::topic_data-api| replace:: :cpp:func:`topic_data()` .. |TopicQos::TopicQos-api| replace:: :cpp:func:`TopicQos() ` .. |TopicQos::transport_priority-api| replace:: :cpp:func:`transport_priority()` -.. |TypeInformation-api| replace:: :cpp:class:`TypeInformation ` -.. |TypeObject-api| replace:: :cpp:class:`TypeObject ` -.. |TypeObjectFactory-api| replace:: :cpp:class:`TypeObjectFactory ` .. |TypeSupport-api| replace:: :cpp:class:`TypeSupport` .. |TypeSupport::is_plain-api| replace:: :cpp:func:`TypeSupport::is_plain() ` .. |TypeSupport::register_type-api| replace:: :cpp:func:`register_type() ` @@ -956,18 +953,48 @@ .. |EDPStatic| replace:: :cpp:class:`EDPStatic ` -.. |DynamicPubSubType-api| replace:: :cpp:class:`DynamicPubSubType ` -.. |DynamicPubSubTypes-api| replace:: :cpp:class:`DynamicPubSubTypes ` -.. |DynamicType-api| replace:: :cpp:class:`DynamicType ` -.. |DynamicTypes-api| replace:: :cpp:class:`DynamicTypes ` - -.. |TypeObjectV1-api| replace:: :cpp:class:`TypeObject` -.. |TypeIdV1-api| replace:: :cpp:class:`TypeIdentifier` - -.. |TopicDataType::auto_fill_type_object-api| replace:: :cpp:func:`auto_fill_type_object` -.. |TopicDataType::auto_fill_type_information-api| replace:: :cpp:func:`auto_fill_type_information` - -.. |DomainParticipant::register_remote_type-api| replace:: :cpp:func:`register_remote_type` +.. {{{ X-Types API +.. |AnnotationDescriptor-api| replace:: :cpp:class:`AnnotationDescriptor ` +.. |AnnotationDescriptor::set_value-api| replace:: :cpp:func:`AnnotationDescriptor::set_value() ` +.. |DynamicData-api| replace:: :cpp:class:`DynamicData ` +.. |DynamicData::get_boolean_value| replace:: :cpp:func:`DynamicData::get_boolean_value ` +.. |DynamicData::get_complex_value| replace:: :cpp:func:`DynamicData::get_complex_value ` +.. |DynamicData::get_member_id_by_name| replace:: :cpp:func:`DynamicData::get_member_id_by_name ` +.. |DynamicData::get_string_value| replace:: :cpp:func:`DynamicData::get_string_value ` +.. |DynamicData::get_wstring_value| replace:: :cpp:func:`DynamicData::get_wstring_value ` +.. |DynamicData::loan_value| replace:: :cpp:func:`DynamicData::loan_value ` +.. |DynamicData::return_loaned_value| replace:: :cpp:func:`DynamicData::return_loaned_value ` +.. |DynamicData::set_boolean_value| replace:: :cpp:func:`DynamicData::set_boolean_value ` +.. |DynamicData::set_complex_value| replace:: :cpp:func:`DynamicData::set_complex_value ` +.. |DynamicData::set_string_value| replace:: :cpp:func:`DynamicData::set_string_value ` +.. |DynamicData::set_wstring_value| replace:: :cpp:func:`DynamicData::set_wstring_value ` +.. |DynamicDataFactory-api| replace:: :cpp:class:`DynamicDataFactory ` +.. |DynamicPubSubType-api| replace:: :cpp:class:`DynamicPubSubType ` +.. |DynamicType-api| replace:: :cpp:class:`DynamicType ` +.. |DynamicTypeBuilder-api| replace:: :cpp:class:`DynamicTypeBuilder ` +.. |DynamicTypeBuilder::add_member| replace:: :cpp:func:`DynamicTypeBuilder::add_member ` +.. |DynamicTypeBuilder::apply_annotation_to_member| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation_to_member ` +.. |DynamicTypeBuilder::apply_annotation| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation ` +.. |DynamicTypeBuilder::build| replace:: :cpp:func:`DynamicTypeBuilder::build ` +.. |DynamicTypeBuilderFactory-api| replace:: :cpp:class:`DynamicTypeBuilderFactory ` +.. |DynamicTypeBuilderFactory::create_array_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_array_type ` +.. |DynamicTypeBuilderFactory::create_bitmask_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_bitmask_type ` +.. |DynamicTypeBuilderFactory::create_map_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_map_type ` +.. |DynamicTypeBuilderFactory::create_sequence_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_sequence_type ` +.. |DynamicTypeBuilderFactory::create_string_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_string_type ` +.. |DynamicTypeBuilderFactory::create_type_w_type_object| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type_w_type_object ` +.. |DynamicTypeBuilderFactory::create_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type ` +.. |DynamicTypeBuilderFactory::create_wstring_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_wstring_type ` +.. |DynamicTypeBuilderFactory::get_primitive_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::get_primitive_type ` +.. |DynamicTypeMember-api| replace:: :cpp:class:`DynamicTypeMember ` +.. |MemberDescriptor-api| replace:: :cpp:class:`MemberDescriptor ` +.. |TypeDescriptor-api| replace:: :cpp:class:`TypeDescriptor ` +.. |VerbatimTextDescriptor-api| replace:: :cpp:class:`VerbatimTextDescriptor ` + +.. |ITypeObjectRegistry-api| replace:: :cpp:class:`ITypeObjectRegistry ` +.. |ITypeObjectRegistry::get_type_object| replace:: :cpp:func:`ITypeObjectRegistry::get_type_object ` +.. |TypeObjectUtils-api| replace:: :cpp:class:`TypeObjectUtils ` +.. }}} .. |DomainParticipant::set_listener-api| replace:: :cpp:func:`DomainParticipant::set_listener()` .. |Publisher::set_listener-api| replace:: :cpp:func:`Publisher::set_listener()` @@ -1003,7 +1030,6 @@ .. |STATISTICS_DATAREADER_QOS-api| replace:: :cpp:member:`STATISTICS_DATAREADER_QOS ` .. |STATISTICS_DATAWRITER_QOS-api| replace:: :cpp:member:`STATISTICS_DATAWRITER_QOS ` -.. |DDSEntityStatus-api| replace:: :cpp:class:`DDSEntityStatus ` .. |MonitorServiceDataReaderQos-api| replace:: :cpp:class:`MonitorServiceDataReaderQos ` .. |RTPSMessageGroup| replace:: :cpp:class:`RTPSMessageGroup ` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index eed1b2adb..219fea8a2 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -16,14 +16,17 @@ .. |domain| replace:: :ref:`domain` .. |DomainParticipant| replace:: :ref:`DomainParticipant` .. |DomainParticipantFactory| replace:: :ref:`DomainParticipantFactory` +.. |DomainParticipantListener| replace:: :ref:`DomainParticipantListener` .. |DomainParticipantQos| replace:: :ref:`DomainParticipantQos` .. |DomainParticipants| replace:: :ref:`DomainParticipants` .. |domains| replace:: :ref:`domains` .. |DurabilityQosPolicy| replace:: :ref:`DurabilityQosPolicy` .. |DurabilityServiceQosPolicy| replace:: :ref:`DurabilityServiceQosPolicy` +.. |DynamicTypes| replace:: :ref:`Dynamic Language Binding` .. |Entities| replace:: :ref:`Entities` .. |Entity| replace:: :ref:`Entity` .. |EntityFactoryQosPolicy| replace:: :ref:`EntityFactoryQosPolicy` +.. |Fast DDS-Gen| replace:: :ref:`Fast DDS-Gen` .. |FlowControllersQos| replace:: :ref:`FlowControllersQos` .. |GroupDataQosPolicy| replace:: :ref:`GroupDataQosPolicy` .. |HistoryQosPolicy| replace:: :ref:`HistoryQosPolicy` @@ -33,6 +36,7 @@ .. |LivelinessChangedStatus| replace:: :ref:`LivelinessChangedStatus` .. |LivelinessLostStatus| replace:: :ref:`LivelinessLostStatus` .. |LivelinessQosPolicy| replace:: :ref:`LivelinessQosPolicy` +.. |MemoryManagementPolicy| replace:: :ref:`MemoryManagementPolicy` .. |OfferedDeadlineMissedStatus| replace:: :ref:`OfferedDeadlineMissedStatus` .. |OfferedIncompatibleQosStatus| replace:: :ref:`OfferedIncompatibleQosStatus` .. |OwnershipQosPolicy| replace:: :ref:`OwnershipQosPolicy` @@ -59,14 +63,19 @@ .. |SampleInfo| replace:: :ref:`SampleInfo` .. |SampleLostStatus| replace:: :ref:`SampleLostStatus` .. |SampleRejectedStatus| replace:: :ref:`SampleRejectedStatus` +.. |StatisticsDomainParticipant| replace:: :ref:`Statistics Domain Participant` +.. |StatisticsQosTroubleshooting| replace:: :ref:`Statistics QoS Troubleshooting` .. |Subscriber| replace:: :ref:`Subscriber` .. |SubscriberListener| replace:: :ref:`SubscriberListener` .. |SubscriberQos| replace:: :ref:`SubscriberQos` .. |Subscribers| replace:: :ref:`Subscribers` .. |SubscriptionMatchedStatus| replace:: :ref:`SubscriptionMatchedStatus` +.. |ThreadSettings| replace:: :ref:`ThreadSettings` .. |TimeBasedFilterQosPolicy| replace:: :ref:`RTPSEndpointTimeBasedFilterQosPolicy` .. |Topic| replace:: :ref:`Topic` .. |TopicDataQosPolicy| replace:: :ref:`TopicDataQosPolicy` +.. |TopicDataType| replace:: :ref:`TopicDataType` +.. |TopicDataTypes| replace:: :ref:`TopicDataTypes` .. |TopicListener| replace:: :ref:`TopicListener` .. |TopicQos| replace:: :ref:`TopicQos` .. |Topics| replace:: :ref:`Topics` @@ -74,58 +83,10 @@ .. |TransportPriorityQosPolicy| replace:: :ref:`TransportPriorityQosPolicy` .. |TypeConsistencyEnforcementQosPolicy| replace:: :ref:`TypeConsistencyEnforcementQosPolicy` .. |TypeConsistencyQos| replace:: :ref:`TypeConsistencyQos` +.. |TypeInformation| replace:: :ref:`TypeInformation` +.. |TypeObject| replace:: :ref:`TypeObject representation` .. |UserDataQosPolicy| replace:: :ref:`UserDataQosPolicy` +.. |whitelist| replace:: :ref:`Whitelist ` .. |WireProtocolConfigQos| replace:: :ref:`WireProtocolConfigQos` .. |WriterDataLifecycleQosPolicy| replace:: :ref:`WriterDataLifecycleQosPolicy` .. |WriterResourceLimitsQos| replace:: :ref:`WriterResourceLimitsQos` -.. |DomainParticipantListener| replace:: :ref:`DomainParticipantListener` -.. |whitelist| replace:: :ref:`Whitelist ` -.. |MemoryManagementPolicy| replace:: :ref:`MemoryManagementPolicy` - -.. |DynamicType| replace:: :ref:`dynamictypes_overview_dynamictype` -.. |DynamicTypes| replace:: :ref:`dynamictypes_overview_dynamictype` -.. |DynamicTypeBuilderFactory| replace:: :ref:`dynamictypes_overview_dynamictypebuilderfactory` -.. |DynamicTypeBuilder| replace:: :ref:`dynamictypes_overview_dynamictypebuilder` -.. |TypeDescriptor| replace:: :ref:`dynamictypes_overview_typedescriptor` -.. |DynamicTypeMember| replace:: :ref:`dynamictypes_overview_dynamictypemember` -.. |MemberDescriptor| replace:: :ref:`dynamictypes_overview_memberdescriptor` -.. |DynamicData| replace:: :ref:`dynamictypes_overview_dynamicdata` -.. |DynamicDataFactory| replace:: :ref:`dynamictypes_overview_dynamicdatafactory` -.. |DynamicPubSubType| replace:: :ref:`dynamictypes_overview_dynamicpubsubtype` - -.. |Supported Types| replace:: :ref:`dynamictypes_supportedtypes` -.. |Primitive Types| replace:: :ref:`dynamictypes_supportedtypes_primitive` -.. |String and WString| replace:: :ref:`dynamictypes_supportedtypes_string` -.. |Alias| replace:: :ref:`dynamictypes_supportedtypes_alias` -.. |Enumeration| replace:: :ref:`dynamictypes_supportedtypes_enumeration` -.. |Bitmask| replace:: :ref:`dynamictypes_supportedtypes_bitmask` -.. |Structure| replace:: :ref:`dynamictypes_supportedtypes_structure` -.. |Bitset| replace:: :ref:`dynamictypes_supportedtypes_bitset` -.. |Union| replace:: :ref:`dynamictypes_supportedtypes_union` -.. |Sequence| replace:: :ref:`dynamictypes_supportedtypes_sequence` -.. |Array| replace:: :ref:`dynamictypes_supportedtypes_array` -.. |Map| replace:: :ref:`dynamictypes_supportedtypes_map` - -.. |Memory management| replace:: :ref:`dynamictypes_memorymanagement` - -.. |Complex Types| replace:: :ref:`dynamictypes_complextypes` - -.. |Nested structures| replace:: :ref:`dynamictypes_complextypes_nestedstructures` -.. |Structure inheritance| replace:: :ref:`dynamictypes_complextypes_inheritance` -.. |Alias of an alias| replace:: :ref:`dynamictypes_complextypes_aliasalias` -.. |Unions with complex types| replace:: :ref:`dynamictypes_complextypes_complexunions` - -.. |TypeObject| replace:: :ref:`dynamictypes_discovery_typeobject` -.. |TypeInformation| replace:: :ref:`dynamictypes_discovery_typeinformation` -.. |TypeIdentifier| replace:: :ref:`dynamictypes_discovery_typeidentifier` -.. |TypeObjectFactory| replace:: :ref:`dynamictypes_discovery_typeobjectfactory` - -.. |TopicDataType| replace:: :ref:`TopicDataType` -.. |TopicDataTypes| replace:: :ref:`TopicDataTypes` - -.. |Fast DDS-Gen| replace:: :ref:`Fast DDS-Gen` - -.. |StatisticsDomainParticipant| replace:: :ref:`Statistics Domain Participant` -.. |StatisticsQosTroubleshooting| replace:: :ref:`Statistics QoS Troubleshooting` - -.. |ThreadSettings| replace:: :ref:`ThreadSettings` diff --git a/docs/fastdds/api_reference/dds_pim/dds_pim.rst b/docs/fastdds/api_reference/dds_pim/dds_pim.rst index a2aab192f..d5c54eaa5 100644 --- a/docs/fastdds/api_reference/dds_pim/dds_pim.rst +++ b/docs/fastdds/api_reference/dds_pim/dds_pim.rst @@ -12,3 +12,4 @@ Data Distribution Service (DDS) Data-Centric Publish-Subscribe (DCPS) Platform I /fastdds/api_reference/dds_pim/publisher/publisher.rst /fastdds/api_reference/dds_pim/subscriber/subscriber.rst /fastdds/api_reference/dds_pim/topic/topic.rst + /fastdds/api_reference/dds_pim/xtypes/xtypes.rst diff --git a/docs/fastdds/api_reference/dds_pim/topic/topic.rst b/docs/fastdds/api_reference/dds_pim/topic/topic.rst index 572856bb2..47be1cca3 100644 --- a/docs/fastdds/api_reference/dds_pim/topic/topic.rst +++ b/docs/fastdds/api_reference/dds_pim/topic/topic.rst @@ -12,6 +12,4 @@ Topic /fastdds/api_reference/dds_pim/topic/icontentfilterfactory.rst /fastdds/api_reference/dds_pim/topic/topiclistener.rst /fastdds/api_reference/dds_pim/topic/topicqos.rst - /fastdds/api_reference/dds_pim/topic/typeidv1.rst /fastdds/api_reference/dds_pim/topic/typeinformation.rst - /fastdds/api_reference/dds_pim/topic/typeobjectv1.rst diff --git a/docs/fastdds/api_reference/dds_pim/topic/typeidv1.rst b/docs/fastdds/api_reference/dds_pim/topic/typeidv1.rst deleted file mode 100644 index 2655ed432..000000000 --- a/docs/fastdds/api_reference/dds_pim/topic/typeidv1.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _api_pim_typeidv1: - -.. rst-class:: api-ref - -TypeIdV1 --------- - -.. doxygenclass:: eprosima::fastdds::dds::TypeIdV1 - :project: FastDDS - :members: - diff --git a/docs/fastdds/api_reference/dds_pim/topic/typeinformation.rst b/docs/fastdds/api_reference/dds_pim/topic/typeinformation.rst index 03510e602..6abd01d44 100644 --- a/docs/fastdds/api_reference/dds_pim/topic/typeinformation.rst +++ b/docs/fastdds/api_reference/dds_pim/topic/typeinformation.rst @@ -1,10 +1,10 @@ -.. _api_pim_typeinformation: +.. _api_pim_typeinformationparameter: .. rst-class:: api-ref -TypeInformation ---------------- +TypeInformationParameter +------------------------ -.. doxygenclass:: eprosima::fastdds::dds::xtypes::TypeInformation +.. doxygenclass:: eprosima::fastdds::dds::xtypes::TypeInformationParameter :project: FastDDS :members: diff --git a/docs/fastdds/api_reference/dds_pim/topic/typeobjectv1.rst b/docs/fastdds/api_reference/dds_pim/topic/typeobjectv1.rst deleted file mode 100644 index 5f7915b70..000000000 --- a/docs/fastdds/api_reference/dds_pim/topic/typeobjectv1.rst +++ /dev/null @@ -1,11 +0,0 @@ -.. _api_pim_typeobjectv1: - -.. rst-class:: api-ref - -TypeObjectV1 ------------- - -.. doxygenclass:: eprosima::fastdds::dds::TypeObjectV1 - :project: FastDDS - :members: - diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/annotationdescriptor.rst b/docs/fastdds/api_reference/dds_pim/xtypes/annotationdescriptor.rst new file mode 100644 index 000000000..64f66e71f --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/annotationdescriptor.rst @@ -0,0 +1,10 @@ +.. _api_pim_annotationdescriptor: + +.. rst-class:: api-ref + +AnnotationDescriptor +-------------------- + +.. doxygenclass:: eprosima::fastdds::dds::AnnotationDescriptor + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst new file mode 100644 index 000000000..7288a4e8d --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst @@ -0,0 +1,18 @@ +.. _dynamic_language_binding_api: + +Dynamic Language Binding +======================== + +.. toctree:: + + /fastdds/api_reference/dds_pim/xtypes/annotationdescriptor.rst + /fastdds/api_reference/dds_pim/xtypes/dynamicdata.rst + /fastdds/api_reference/dds_pim/xtypes/dynamicdatafactory.rst + /fastdds/api_reference/dds_pim/xtypes/dynamicpubsubtype.rst + /fastdds/api_reference/dds_pim/xtypes/dynamictype.rst + /fastdds/api_reference/dds_pim/xtypes/dynamictypebuilder.rst + /fastdds/api_reference/dds_pim/xtypes/dynamictypebuilderfactory.rst + /fastdds/api_reference/dds_pim/xtypes/dynamictypemember.rst + /fastdds/api_reference/dds_pim/xtypes/memberdescriptor.rst + /fastdds/api_reference/dds_pim/xtypes/typedescriptor.rst + /fastdds/api_reference/dds_pim/xtypes/verbatimtextdescriptor.rst diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdata.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdata.rst new file mode 100644 index 000000000..64d3d702c --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdata.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamicdata: + +.. rst-class:: api-ref + +DynamicData +----------- + +.. doxygenclass:: eprosima::fastdds::dds::DynamicData + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdatafactory.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdatafactory.rst new file mode 100644 index 000000000..e0408be62 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicdatafactory.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamicdatafactory: + +.. rst-class:: api-ref + +DynamicDataFactory +------------------ + +.. doxygenclass:: eprosima::fastdds::dds::DynamicDataFactory + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamicpubsubtype.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicpubsubtype.rst new file mode 100644 index 000000000..5ebf38037 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamicpubsubtype.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamicpubsubtype: + +.. rst-class:: api-ref + +DynamicPubSubType +----------------- + +.. doxygenclass:: eprosima::fastdds::dds::DynamicPubSubType + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamictype.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictype.rst new file mode 100644 index 000000000..e3d2372fe --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictype.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamictype: + +.. rst-class:: api-ref + +DynamicType +----------- + +.. doxygenclass:: eprosima::fastdds::dds::DynamicType + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilder.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilder.rst new file mode 100644 index 000000000..15a1e81f8 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilder.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamictypebuilder: + +.. rst-class:: api-ref + +DynamicTypeBuilder +------------------ + +.. doxygenclass:: eprosima::fastdds::dds::DynamicTypeBuilder + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilderfactory.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilderfactory.rst new file mode 100644 index 000000000..6154157ab --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypebuilderfactory.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamictypebuilderfactory: + +.. rst-class:: api-ref + +DynamicTypeBuilderFactory +------------------------- + +.. doxygenclass:: eprosima::fastdds::dds::DynamicTypeBuilderFactory + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypemember.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypemember.rst new file mode 100644 index 000000000..8420d99d4 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamictypemember.rst @@ -0,0 +1,10 @@ +.. _api_pim_dynamictypemember: + +.. rst-class:: api-ref + +DynamicTypeMember +----------------- + +.. doxygenclass:: eprosima::fastdds::dds::DynamicTypeMember + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst b/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst new file mode 100644 index 000000000..a34d10c67 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst @@ -0,0 +1,10 @@ +.. _api_pim_xtypes_exception: + +.. rst-class:: api-ref + +InvalidArgumentError +-------------------- + +.. doxygenclass:: eprosima::fastdds::dds::xtypes::InvalidArgumentError + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/memberdescriptor.rst b/docs/fastdds/api_reference/dds_pim/xtypes/memberdescriptor.rst new file mode 100644 index 000000000..fb3f00386 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/memberdescriptor.rst @@ -0,0 +1,10 @@ +.. _api_pim_memberdescriptor: + +.. rst-class:: api-ref + +MemberDescriptor +---------------- + +.. doxygenclass:: eprosima::fastdds::dds::MemberDescriptor + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/type_representation.rst b/docs/fastdds/api_reference/dds_pim/xtypes/type_representation.rst new file mode 100644 index 000000000..18299eaf9 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/type_representation.rst @@ -0,0 +1,7 @@ +Type Representation +=================== + +.. toctree:: + + /fastdds/api_reference/dds_pim/xtypes/typeobjectregistry.rst + /fastdds/api_reference/dds_pim/xtypes/typeobjectutils.rst diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/typedescriptor.rst b/docs/fastdds/api_reference/dds_pim/xtypes/typedescriptor.rst new file mode 100644 index 000000000..f50a520b5 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/typedescriptor.rst @@ -0,0 +1,10 @@ +.. _api_pim_typedescriptor: + +.. rst-class:: api-ref + +TypeDescriptor +-------------- + +.. doxygenclass:: eprosima::fastdds::dds::TypeDescriptor + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectregistry.rst b/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectregistry.rst new file mode 100644 index 000000000..dd1524712 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectregistry.rst @@ -0,0 +1,10 @@ +.. _api_pim_typeobjectregistry: + +.. rst-class:: api-ref + +TypeObjectRegistry +------------------ + +.. doxygenclass:: eprosima::fastdds::dds::xtypes::ITypeObjectRegistry + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectutils.rst b/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectutils.rst new file mode 100644 index 000000000..abae4cbe1 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/typeobjectutils.rst @@ -0,0 +1,10 @@ +.. _api_pim_typeobjectutils: + +.. rst-class:: api-ref + +TypeObjectUtils +--------------- + +.. doxygenclass:: eprosima::fastdds::dds::xtypes::TypeObjectUtils + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/verbatimtextdescriptor.rst b/docs/fastdds/api_reference/dds_pim/xtypes/verbatimtextdescriptor.rst new file mode 100644 index 000000000..711a590bd --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/verbatimtextdescriptor.rst @@ -0,0 +1,10 @@ +.. _api_pim_verbatimtextdescriptor: + +.. rst-class:: api-ref + +VerbatimTextDescriptor +---------------------- + +.. doxygenclass:: eprosima::fastdds::dds::VerbatimTextDescriptor + :project: FastDDS + :members: diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/xtypes.rst b/docs/fastdds/api_reference/dds_pim/xtypes/xtypes.rst new file mode 100644 index 000000000..60a0b16ad --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/xtypes.rst @@ -0,0 +1,8 @@ +XTypes +====== + +.. toctree:: + + /fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst + /fastdds/api_reference/dds_pim/xtypes/exception.rst + /fastdds/api_reference/dds_pim/xtypes/type_representation.rst diff --git a/docs/fastdds/api_reference/rtps/attributes/TypeLookupSettings.rst b/docs/fastdds/api_reference/rtps/attributes/TypeLookupSettings.rst deleted file mode 100644 index 0db57bf99..000000000 --- a/docs/fastdds/api_reference/rtps/attributes/TypeLookupSettings.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. rst-class:: api-ref - -TypeLookupSettings --------------------------------- - -.. doxygenclass:: eprosima::fastrtps::rtps::TypeLookupSettings - :project: FastDDS - :members: diff --git a/docs/fastdds/api_reference/rtps/attributes/attributes.rst b/docs/fastdds/api_reference/rtps/attributes/attributes.rst index 0b1349c7a..8f23a1541 100644 --- a/docs/fastdds/api_reference/rtps/attributes/attributes.rst +++ b/docs/fastdds/api_reference/rtps/attributes/attributes.rst @@ -27,7 +27,6 @@ Attributes /fastdds/api_reference/rtps/attributes/SendBuffersAllocationAttributes /fastdds/api_reference/rtps/attributes/SimpleEDPAttributes /fastdds/api_reference/rtps/attributes/ThreadSettings - /fastdds/api_reference/rtps/attributes/TypeLookupSettings /fastdds/api_reference/rtps/attributes/VariableLengthDataLimits /fastdds/api_reference/rtps/attributes/WriterAttributes /fastdds/api_reference/rtps/attributes/WriterTimes diff --git a/docs/fastdds/api_reference/spelling_wordlist.txt b/docs/fastdds/api_reference/spelling_wordlist.txt index fa6995d47..fc16cfa82 100644 --- a/docs/fastdds/api_reference/spelling_wordlist.txt +++ b/docs/fastdds/api_reference/spelling_wordlist.txt @@ -4,17 +4,70 @@ addReaderLocator addReaderProxy addWriterProxy allowlist +AppliedAnnotationPubSubType +AppliedAnnotationParameterPubSubType +AppliedBuiltinMemberAnnotationsPubSubType +AppliedBuiltinTypeAnnotationsPubSubType +AppliedVerbatimAnnotationPubSubType assignability autodispose autoenable autopurge behaviour +bitcount +bitfields +bitflag +Bitflag blocklist booleans bytesPerPeriod cacheChange CacheChange changeKind +CommonAliasBodyPubSubType +CommonAnnotationParameterPubSubType +CommonArrayHeaderPubSubType +CommonBitfieldPubSubType +CommonBitflagPubSubType +CommonBitmaskHeaderPubSubType +CommonCollectionElementPubSubType +CommonCollectionHeaderPubSubType +CommonDiscriminatorMemberPubSubType +CommonEnumeratedHeaderPubSubType +CommonEnumeratedLiteralPubSubType +CommonStructMemberPubSubType +CommonUnionMemberPubSubType +CompleteAliasBodyPubSubType +CompleteAliasHeaderPubSubType +CompleteAliasTypePubSubType +CompleteAnnotationHeaderPubSubType +CompleteAnnotationParameterPubSubType +CompleteAnnotationTypePubSubType +CompleteArrayHeaderPubSubType +CompleteArrayTypePubSubType +CompleteBitfieldPubSubType +CompleteBitflagPubSubType +CompleteBitmaskTypePubSubType +CompleteBitsetHeaderPubSubType +CompleteBitsetTypePubSubType +CompleteCollectionElementPubSubType +CompleteCollectionHeaderPubSubType +CompleteDiscriminatorMemberPubSubType +CompleteElementDetailPubSubType +CompleteEnumeratedHeaderPubSubType +CompleteEnumeratedLiteralPubSubType +CompleteEnumeratedTypePubSubType +CompleteExtendedTypePubSubType +CompleteMapTypePubSubType +CompleteMemberDetailPubSubType +CompleteSequenceTypePubSubType +CompleteStructHeaderPubSubType +CompleteStructMemberPubSubType +CompleteStructTypePubSubType +CompleteTypeDetailPubSubType +CompleteUnionHeaderPubSubType +CompleteUnionMemberPubSubType +CompleteUnionTypePubSubType cond config const @@ -51,6 +104,8 @@ entityId Enum eprosima expectsInlineQos +ExtendedAnnotationParameterValuePubSubType +ExtendedTypeDefnPubSubType fastdds fastrtps filteredX @@ -62,10 +117,13 @@ getTypeDependencies getTypes guid GuidPrefix +hashid +Hashid heartbeatPeriod heartbeatResponseDelay HistoryQosPolicy InconsistentTopicStatus +Implementers infos initialAcknackDelay initialHeartbeatDelay @@ -74,6 +132,7 @@ instanceHandle InstanceHandle intraprocess LatencyBudgetQosPolicy +LBound lifecycle LifespanQosPolicy LivelinessChangedStatus @@ -90,6 +149,36 @@ logWarning maxInitialPeersRange maxMessageSize md +MinimalAliasBodyPubSubType +MinimalAliasHeaderPubSubType +MinimalAliasTypePubSubType +MinimalAnnotationHeaderPubSubType +MinimalAnnotationParameterPubSubType +MinimalAnnotationTypePubSubType +MinimalArrayHeaderPubSubType +MinimalArrayTypePubSubType +MinimalBitfieldPubSubType +MinimalBitflagPubSubType +MinimalBitmaskTypePubSubType +MinimalBitsetHeaderPubSubType +MinimalBitsetTypePubSubType +MinimalCollectionElementPubSubType +MinimalCollectionHeaderPubSubType +MinimalDiscriminatorMemberPubSubType +MinimalEnumeratedHeaderPubSubType +MinimalEnumeratedLiteralPubSubType +MinimalEnumeratedTypePubSubType +MinimalExtendedTypePubSubType +MinimalMapTypePubSubType +MinimalMemberDetailPubSubType +MinimalSequenceTypePubSubType +MinimalStructHeaderPubSubType +MinimalStructMemberPubSubType +MinimalStructTypePubSubType +MinimalTypeDetailPubSubType +MinimalUnionHeaderPubSubType +MinimalUnionMemberPubSubType +MinimalUnionTypePubSubType msg mutex mutexes @@ -114,10 +203,18 @@ PartitionQosPolicy PDPListener periodMillisecs Pid +PlainArrayLElemDefnPubSubType +PlainArraySElemDefnPubSubType +PlainCollectionHeaderPubSubType +PlainMapLTypeDefnPubSubType +PlainMapSTypeDefnPubSubType +PlainSequenceLElemDefnPubSubType +PlainSequenceSElemDefnPubSubType PortBasedTransportDescriptor pos preallocate PresentationQosPolicy +promotable ptr PublicationMatchedStatus PublisherListener @@ -138,6 +235,7 @@ retransmit RTPSParticipantAllocationAttributes SampleLostStatus SampleRejectedStatus +SBound SecurityException sequenceNumber serializedPaylaod @@ -150,11 +248,15 @@ StatelessWriter StatusCondition statusmask stdout +StringLTypeDefnPubSubType +StringSTypeDefnPubSubType +StronglyConnectedComponentIdPubSubType Struct Subclassed subclasses subentities subnetwork +subsequence SubscriberListener SubscriptionMatchedStatus synchronism @@ -171,13 +273,20 @@ TransportPriorityQosPolicy TypeConsistencyEnforcementQosPolicy TypeConsistencyQos typedef +typeid +TypeIdentfierWithSizePubSubType TypeIdentifier +TypeIdentifierPairPubSubType +TypeIdentifierTypeObjectPairPubSubType +TypeIdentifierWithDependenciesPubSubType TypeIdV TypeInformation +TypeInformationPubSubType typelookup TypeLookup TypeLookupReplyListener TypeLookupRequestListener +TypeObjectRegistry TypeObjectV UDPv Unary @@ -188,9 +297,11 @@ unregistering unregistration untaken untyped +url UserAllocatedSequence wakeup wdata WLPListener +wstring xml xtypes diff --git a/docs/fastdds/dds_layer/core/entity/entity.rst b/docs/fastdds/dds_layer/core/entity/entity.rst index fccd3ddd7..b23edb57d 100644 --- a/docs/fastdds/dds_layer/core/entity/entity.rst +++ b/docs/fastdds/dds_layer/core/entity/entity.rst @@ -132,11 +132,8 @@ diagram: * |DomainParticipantListener::on_participant_discovery-api| * |DomainParticipantListener::onParticipantAuthentication-api| - * |DomainParticipantListener::on_subscriber_discovery-api| - * |DomainParticipantListener::on_publisher_discovery-api| - * |DomainParticipantListener::on_type_discovery-api| - * |DomainParticipantListener::on_type_dependencies_reply-api| - * |DomainParticipantListener::on_type_information_received-api| + * |DomainParticipantListener::on_data_reader_discovery-api| + * |DomainParticipantListener::on_data_writer_discovery-api| * |DataWriterListener::on_unacknowledged_sample_removed-api| .. warning:: diff --git a/docs/fastdds/dds_layer/core/policy/xtypesExtensions.rst b/docs/fastdds/dds_layer/core/policy/xtypesExtensions.rst index 28bda2765..42d1ac5eb 100644 --- a/docs/fastdds/dds_layer/core/policy/xtypesExtensions.rst +++ b/docs/fastdds/dds_layer/core/policy/xtypesExtensions.rst @@ -76,11 +76,13 @@ This QoS Policy cannot be configured using XML for the moment. TypeConsistencyEnforcementQosPolicy ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. warning:: + This QoS Policy will be implemented in future releases. + This XTypes QoS Policy extension defines the rules for determining whether the data type used in the |DataWriter| is consistent with the one used in the |DataReader|. See |TypeConsistencyEnforcementQosPolicy-api|. - List of QoS Policy data members: .. list-table:: diff --git a/docs/fastdds/dds_layer/domain/domainParticipant/domainParticipant.rst b/docs/fastdds/dds_layer/domain/domainParticipant/domainParticipant.rst index cb4d36df8..34e199efa 100644 --- a/docs/fastdds/dds_layer/domain/domainParticipant/domainParticipant.rst +++ b/docs/fastdds/dds_layer/domain/domainParticipant/domainParticipant.rst @@ -67,6 +67,9 @@ Internally it contains the following |QosPolicy-api| objects: * - |ThreadSettings| - |DomainParticipantQos::discovery_server_thread-api| - No + * - |ThreadSettings| + - |DomainParticipantQos::typelookup_service_threads-api| + - No * - |ThreadSettings| - |DomainParticipantQos::security_log_thread-api| - No diff --git a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst index ae4495aef..fc6c753d1 100644 --- a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst +++ b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst @@ -34,22 +34,11 @@ Additionally, DomainParticipantListener adds the following non-standard callback If both callbacks are implemented, the discovery callback with the ``should_be_ignored`` boolean flag takes precedence. The second discovery callback is only executed if the discovered DomainParticipant is not ignored in the first callback (``should_be_ignored`` parameter returns ``false``). - * |DomainParticipantListener::on_subscriber_discovery-api|: A new :ref:`dds_layer_subscriber_subscriber` is discovered in the same domain, - a previously known Subscriber has been removed, - or some Subscriber has changed its QoS. + * |DomainParticipantListener::on_data_reader_discovery-api|: A new :ref:`dds_layer_subscriber_dataReader` is discovered in the same domain, + a previously known DataReader has been removed, or some DataReader has changed its QoS. - * |DomainParticipantListener::on_publisher_discovery-api|: A new :ref:`dds_layer_publisher_publisher` is discovered in the same domain, - a previously known Publisher has been removed, - or some Publisher has changed its QoS. - - * |DomainParticipantListener::on_type_discovery-api|: A new data Type is discovered in the same domain. - - * |DomainParticipantListener::on_type_dependencies_reply-api|: The Type lookup client received a replay to a :func:`getTypeDependencies` request. - This callback can be used to retrieve the new type using the :func:`getTypes` request and create a new - dynamic type using the retrieved type object. - - * |DomainParticipantListener::on_type_information_received-api|: A new |TypeInformation-api| has been received from a newly discovered - DomainParticipant. + * |DomainParticipantListener::on_data_writer_discovery-api|: A new :ref:`dds_layer_publisher_dataWriter` is discovered in the same domain, + a previously known DataWriter has been removed, or some DataWriter has changed its QoS. * |DomainParticipantListener::onParticipantAuthentication-api|: Informs about the result of the authentication process of a remote DomainParticipant (either on failure or success). diff --git a/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst b/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst index 696498cd9..f13dbe14d 100644 --- a/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst +++ b/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst @@ -51,8 +51,8 @@ It is advisable to check that the returned value is a valid pointer. Different filter classes may impose different requirements on the related Topic, the expression, or the parameters. The default filter class, in particular, requires that a TypeObject for the related Topic's type has been registered. - When using :ref:`fastddsgen ` to generate your type support code, remember to include - the ``-typeobject`` option so the TypeObject registration code is generated. + When using :ref:`fastddsgen ` the TypeObject registration code is generated by default. + .. literalinclude:: /../code/DDSCodeTester.cpp :language: c++ diff --git a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index dad230036..b11d9031e 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -16,7 +16,7 @@ Basic usage ^^^^^^^^^^^ *Fast DDS* can be executed by calling *fastddsgen* on Linux or *fastddsgen.bat* on Windows. -The IDL file containing the data type definition is given with the ```` argument. +The IDL file containing the data type definition is given with the :code:`` argument. +----------------------------------------------------------------------------------------------------------------------+ | **Linux** | @@ -35,12 +35,11 @@ The IDL file containing the data type definition is given with the ```` Among the available arguments defined in :ref:`fastddsgen_usage`, the main *Fast DDS-Gen* options for data type source code generation are the following: -* ``-replace``: It replaces existing files in case the data type files have been previously generated. -* ``-help``: It lists the currently supported platforms and Visual Studio versions. -* ``-typeobject``: It builds additional files for |TypeObject-api| generation and management (see - :ref:`dynamictypes_discovery_typeobject`). -* ``-example``: It generates a basic example of a DDS application and the files to build it for - the given ``platform``. +* :code:`-replace`: It replaces existing files in case the data type files have been previously generated. +* :code:`-help`: It lists the currently supported platforms and Visual Studio versions. +* :code:`-no-typeobjectsupport`: It disables the automatic generation of the |TypeObject| registration code. +* :code:`-example`: It generates a basic example of a DDS application and the files to build it for + the given :code:`platform`. Thus, *Fast DDS-Gen* tool can generate a sample application using the provided data type, together with a `Makefile`, to compile it on Linux distributions, and a Visual Studio project for Windows. To see an example of this please refer to tutorial :ref:`fastddsgen_pubsub_app`. @@ -51,12 +50,9 @@ Output files *Fast DDS-Gen* outputs several files. Assuming the IDL file had the name *“Mytype”*, and none of the above options have been defined, these files are: -* MyType.cxx/.h: Type definition. +* MyType.hpp: Type definition. * MyTypePubSubType.cxx/.h: Serialization and deserialization source code for the data type. It also defines the |TopicDataType::getKey-api| member function of the :class:`MyTypePubSubType` class in case the topic implements keys (see :ref:`dds_layer_topic_keyed_data_types`). - -If the ``-typeobject`` argument was used, `MyType.cxx` is modified to register the |TypeObject-api| representation in -the |TypeObjectFactory-api|, and these files will also be generated: - -* MyTypeTypeObject.cxx/.h: TypeObject representation for `MyType` IDL. +* MyTypeCdrAux.hpp/.ipp: Auxiliary methods required by Fast CDR for type encoding and decoding. +* MyTypeTypeObjectSupport.cxx/.hpp: Auxiliary code required for |TypeObject| generation and registration. diff --git a/docs/fastdds/discovery/disc_callbacks.rst b/docs/fastdds/discovery/disc_callbacks.rst index 11968c1bc..b3de0194c 100644 --- a/docs/fastdds/discovery/disc_callbacks.rst +++ b/docs/fastdds/discovery/disc_callbacks.rst @@ -9,11 +9,10 @@ DomainParticipantListener Discovery Callbacks As stated in :ref:`dds_layer_domainParticipantListener`, the |DomainParticipantListener-api| is an abstract class defining the callbacks that will be triggered in response to state changes on the DomainParticipant. -Fast DDS defines four callbacks attached to events that may occur during discovery: +Fast DDS defines three callbacks attached to events that may occur during discovery: |DomainParticipantListener::on_participant_discovery-api|, -|DomainParticipantListener::on_subscriber_discovery-api|, -|DomainParticipantListener::on_publisher_discovery-api|, -|DomainParticipantListener::on_type_discovery-api|. +|DomainParticipantListener::on_data_reader_discovery-api|, +|DomainParticipantListener::on_data_writer_discovery-api|. Further information about the DomainParticipantListener is provided in the :ref:`dds_layer_domainParticipantListener` section. The following is an example of the implementation of DomainParticipantListener discovery callbacks. diff --git a/docs/fastdds/dynamic_types/annotations.rst b/docs/fastdds/dynamic_types/annotations.rst deleted file mode 100644 index bbd4f7660..000000000 --- a/docs/fastdds/dynamic_types/annotations.rst +++ /dev/null @@ -1,63 +0,0 @@ -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_annotations: - -Annotations -=========== - - -|DynamicTypeBuilder| allows applying an annotation -to both current type and inner members with the functions: - -- :func:`apply_annotation` - -- :func:`apply_annotation_to_member` - -Both functions take the name, the key and the value of the annotation. -:func:`apply_annotation_to_member` additionally receives the ``MemberId`` of the inner member. - -For example, if we define an annotation like: - -.. code-block:: omg-idl - - @annotation MyAnnotation - { - long value; - string name; - }; - -And then we apply it through IDL to a struct: - -.. code-block:: omg-idl - - @MyAnnotation(5, "length") - struct MyStruct - { - // ... - } - -The equivalent code using |DynamicTypes| will be: - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_ANNOTATION - :end-before: //!-- - :dedent: 8 - -Builtin annotations -------------------- - -The following annotations modifies the behavior of DynamicTypes: - -- | ``@position``: When applied to |Bitmask|, sets the position of the flag, - | as expected in the IDL annotation. - | If applied to |Bitset|, sets the base position of the bitfield, - | useful to identify unassigned bits. - -- | ``@bit_bound``: Applies to |Bitset|. Sets the size in bits of the bitfield. - -- | ``@key``: Alias for ``@Key``. See :ref:`dds_layer_topic_keyed_data_types` section for more details. - -- | ``@default``: Sets a default value for the member. - -- | ``@non_serialized``: Excludes a member from being serialized. diff --git a/docs/fastdds/dynamic_types/complex_types.rst b/docs/fastdds/dynamic_types/complex_types.rst deleted file mode 100644 index ea33bbca2..000000000 --- a/docs/fastdds/dynamic_types/complex_types.rst +++ /dev/null @@ -1,85 +0,0 @@ -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_complextypes: - -Complex Types -============= - -If the application's data model is complex, it is possible to combine the -:ref:`basic types` to create complex types, -including nested composed types (structures within structures within unions). -Types can also be extended using inheritance, improving the flexibility of the definition -of the data types to fit the model. - -The following subsections describe these *complex types* and their use. - -.. contents:: - :local: - :backlinks: none - :depth: 2 - - -.. _dynamictypes_complextypes_nestedstructures: - -Nested structures ------------------ - -Structures can contain other structures as members. -The access to these compound members is restricted and managed by the |DynamicData| instance. -Users must request access calling ``loan_value`` before using them, and release -them with ``return_loaned_value`` once they finished. -The loan operation will fail if the member is already loaned and has not been released yet. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_NESTED_STRUCTS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_complextypes_inheritance: - -Structure inheritance ---------------------- - -To inherit a structure from another one, use the ``create_child_struct_type`` function from -|DynamicTypeBuilderFactory|. -The resultant type contains all members from the base class and the new ones added to the child. - -Structures support several levels of inheritance, so the base class can be another derived type itself. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_INHERITANCE_STRUCTS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_complextypes_aliasalias: - -Alias of an alias ------------------ - -Alias types support recursion, simply use an alias name as base type for :func:`create_alias_type`. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_NESTED_ALIAS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_complextypes_complexunions: - -Unions with complex types -------------------------- - -Unions support complex type fields. -The access to these complex type fields is restricted and managed by the |DynamicData| instance. -Users must request access calling ``loan_value`` before using them, and release -them with ``return_loaned_value`` once they finished. -The loan operation will fail if the fields is already loaned and has not been released yet. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_NESTED_UNIONS - :end-before: //!-- - :dedent: 8 - diff --git a/docs/fastdds/dynamic_types/concepts.rst b/docs/fastdds/dynamic_types/concepts.rst deleted file mode 100644 index ca3790967..000000000 --- a/docs/fastdds/dynamic_types/concepts.rst +++ /dev/null @@ -1,188 +0,0 @@ -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_overview: - -Overview of Dynamic Types -========================= - -This section describes the classes related to dynamic types that are used through the rest of the documentation. -At the bottom of the section you can also find a short example using the functionality. - -Involved classes ----------------- - -The following class diagram describes the relationship among the classes related to dynamic types. -Please, refer to the description of each class to find its purpose and the nature of the relationship -with the rest of the classes. - -.. figure:: /01-figures/dynamic_types_class_diagram.svg - :align: center - - Dynamic types class diagram - -.. contents:: - :local: - :backlinks: none - :depth: 2 - -.. _dynamictypes_overview_dynamictype: - -DynamicType -^^^^^^^^^^^^ - -Base class of all types declared dynamically. -It represents a dynamic data type that can be used to create -|DynamicData| values. -By design, the structure of a dynamic type (its member fields) cannot -be modified once the type is created. - - -.. _dynamictypes_overview_dynamictypebuilderfactory: - -DynamicTypeBuilderFactory -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -*Singleton* class that is in charge of the creation and the management of every -DynamicType and |DynamicTypeBuilder|. -It declares functions to create builders for each kind of supported types. -Given a builder for a specific type, it can also create the corresponding -DynamicType. -Some simpler types can be created directly, avoiding the step of creating a -DynamicTypeBuilder. -Please, refer to the |Supported Types| documentation for details about -which ones support this option. - -Every object created by the factory must be deleted to avoid memory leaking. -Refer to the |Memory management| section for details. - - -.. _dynamictypes_overview_dynamictypebuilder: - -DynamicTypeBuilder -^^^^^^^^^^^^^^^^^^^^ - -Intermediate class used to configure a DynamicType -before it is created. -By design, the structure of a DynamicType (its member fields) cannot -be modified once the object is created. -Therefore, all its structure must be defined prior to its creation. -The builder is the object used to set up this structure. - -Once defined, the DynamicTypeBuilderFactory is used to create -the DynamicType from the information contained in the builder. -As a shortcut, the builder exposes a function :func:`build` that internally uses the -DynamicTypeBuilderFactory to return a fully constructed -DynamicType. -The types created with :func:`build` are still subject to the |Memory management| -restrictions, and must be deleted by the DynamicTypeBuilderFactory. - -Builders can be reused after the creation of a DynamicType, as -the changes applied to the builder do not affect to types created previously. - - -.. _dynamictypes_overview_typedescriptor: - -TypeDescriptor -^^^^^^^^^^^^^^^ - -Stores the information about one type with its relationships and restrictions. -This is the class that describes the inner structure of a -DynamicType. -The DynamicTypeBuilder has an internal instance of -TypeDescriptor that modifies during the type building process. -When the DynamicType is created, the -DynamicTypeBuilderFactory uses the information -of the TypeDescriptor in the builder to create the DynamicType. -During the creation, the TypeDescriptor is copied to the DynamicType, -so that it becomes independent from the DynamicTypeBuilder, -and the builder can be reused for another type. - - -.. _dynamictypes_overview_dynamictypemember: - -DynamicTypeMember -^^^^^^^^^^^^^^^^^^^ - -Represents a data member of a DynamicType that is also a -DynamicType. -Compound types (dynamic types that are composed of other dynamic types) have a -DynamicTypeMember for every child DynamicType added to it. - - -.. _dynamictypes_overview_memberdescriptor: - -MemberDescriptor -^^^^^^^^^^^^^^^^^ - -Just as a TypeDescriptor describes the inner structure of a -DynamicType, -a MemberDescriptor stores all the information needed to manage a -DynamicTypeMember, like their name, their unique ID, or -the default value after the creation. -This information is copied to the |DynamicData| on its creation. - - -.. _dynamictypes_overview_dynamicdata: - -DynamicData -^^^^^^^^^^^^ - -While a DynamicType *describes* a type, -DynamicData represents a data instance of a DynamicType. -It provides functions to access and modify the data values in the instance. - -There are two ways to work with DynamicData: - -* Activating the macro ``DYNAMIC_TYPES_CHECKING``, which creates a variable for - each primitive kind to help the debug process. -* Without this macro, the size of the DynamicData is reduced, using only the minimum needed - internal values, but it makes the code harder to debug. - - -.. _dynamictypes_overview_dynamicdatafactory: - -DynamicDataFactory -^^^^^^^^^^^^^^^^^^^^ - -*Singleton* class that is in charge of the creation and the management of every -DynamicData. -It can take a DynamicType and create an instance of a -corresponding DynamicData. -Every data object created by the factory must be deleted to avoid memory leaking. -Refer to the |Memory management| section for details. - -It also allows to create a :class:`TypeIdentifier` and a (Minimal and Complete) :class:`TypeObject` from a -:class:`TypeDescriptor`. - - -.. _dynamictypes_overview_dynamicpubsubtype: - -DynamicPubSubType -^^^^^^^^^^^^^^^^^^ - -This class is an adapter that allows using DynamicData on Fast DDS. -It inherits from ``TopicDataType`` and implements the functions needed to communicate the -DynamicData between Publishers and Subscribers. - - -.. _dynamictypes_overview_example: - -Minimum example ---------------- - -This is a short example to illustrate the use of the dynamic types and how the classes describe above interact -with each other. -While the code snippet can be used as a quick reference for code building, the sequence diagram below provides a -visual interpretation of the actions. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_QUICK_EXAMPLE - :end-before: //! - :dedent: 8 - -.. figure:: /01-figures/dynamic_types_sequence_diagram.svg - :align: center - - Sequence diagram of the code above - diff --git a/docs/fastdds/dynamic_types/discovery.rst b/docs/fastdds/dynamic_types/discovery.rst deleted file mode 100644 index d6c45daf9..000000000 --- a/docs/fastdds/dynamic_types/discovery.rst +++ /dev/null @@ -1,183 +0,0 @@ -.. include:: ../../03-exports/aliases-api.include -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_discovery: - -Dynamic Types Discovery and Endpoint Matching -============================================= - -.. _DDS-XTypes V1.2: http://www.omg.org/spec/DDS-XTypes/1.2 - -When using |DynamicTypes| support, *Fast DDS* checks the optional |TypeObject| -and |TypeIdentifier| values during endpoint matching. -Currently, the matching only verifies that both endpoints are using the same topic data type, -but will not negotiate about it. - -The process of checking the types is as follows: - -* It checks :class:`CompleteTypeObject` on TypeObject first. -* If one or both endpoints do not define the :class:`CompleteTypeObject`, it tries with :class:`MinimalTypeObject`. -* If one or both endpoints do not define :class:`MinimalTypeObject` either, - it compares the TypeIdentifier. -* If none is defined, then just the type name is checked. - -If one of the endpoints transmits a :class:`CompleteTypeObject`, :ref:`discovery-time-data-typing` can be performed. - -.. _dynamictypes_discovery_typeobject: - -TypeObject ----------- - -|TypeObjectV1-api| fully describes a data type, the same way as the IDL representation does. -There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`MinimalTypeObject` . - - - :class:`CompleteTypeObject` fully describes the type, the same way as the IDL representation does. - - :class:`MinimalTypeObject` is a compact representation of the data type, that contains only the information relevant - for the remote Endpoint to be able to interpret the data. - -TypeObject is an IDL union with both *Minimal* and *Complete* representation. -Both are described in the annexes of `DDS-XTypes V1.2`_ document, -please refer to this document for details. - - -.. _dynamictypes_discovery_typeinformation: - -TypeInformation ---------------- - -|TypeInformation-api| is an extension of *XTypes 1.2* that allow Endpoints to -share information about data types without sending the TypeObject. -Endpoints instead share a TypeInformation containing the -TypeIdentifier of the data type. -Then each Endpoint can request the complete TypeObject for the data -types it is interested in. -This avoids sending the complete data type to Endpoints that may not be interested. - -|TypeInformation-api| is described in the annexes of `DDS-XTypes V1.2`_ document, -please refer to this document for details. - - -.. _dynamictypes_discovery_typeidentifier: - -TypeIdentifier --------------- - -|TypeIdV1-api| provides a unique way to identify each type. -For basic types, the information contained in the TypeIdentifier -completely describes the type, while for complex ones, it serves as a search key to -retrieve the complete TypeObject. - -|TypeIdV1-api| is described in the annexes of `DDS-XTypes V1.2`_ document, -please refer to this document for details. - - -.. _dynamictypes_discovery_typeobjectfactory: - -TypeObjectFactory ------------------ - -*Singleton* class that manages the creation and access for every registered TypeObject -and TypeIdentifier. -It can generate a full :ref:`dynamictypes_overview_dynamictype` from a basic -TypeIdentifier (i.e., one whose discriminator is not :class:`EK_MINIMAL` -or :class:`EK_COMPLETE`). - -.. _dynamictypes_discovery_ddsgen: - -Fast DDS-Gen ------------- - -*Fast DDS-Gen* supports the generation of `XXXTypeObject.h` and `XXXTypeObject.cxx` files, -taking :class:`XXX` as our IDL type. -These files provide a small Type Factory for the type :class:`XXX`. -Generally, these files are not used directly, as now the type :class:`XXX` will register itself through its factory to -TypeObjectFactory in its constructor, making it very easy to use static types -with dynamic types. - -.. _discovery-time-data-typing: - -Discovery-Time Data Typing --------------------------- - -Using the Fast DDS API, when a participant discovers a remote endpoint that sends a complete -TypeObject or a simple TypeIdentifier describing a type -that the participant does not know, the participant listener's function -:cpp:func:`on_type_discovery` -is called with the received TypeObject or TypeIdentifier, -and, when possible, a pointer to a :ref:`dynamictypes_overview_dynamictype` ready to be used. - -Discovery-Time Data Typing allows the discovering of simple DynamicTypes. -A TypeObject that depends on other TypeObjects, cannot be built locally using -Discovery-Time Data Typing and should use :ref:`TypeLookup-Service` instead. - -To ease the sharing of the TypeObject and TypeIdentifier -used by Discovery-Time Data Typing, -:ref:`TopicDataType` contains a function member named -|TopicDataType::auto_fill_type_object-api|. -If set to true, the local participant will send the TypeObject and -TypeIdentifier to the remote endpoint during discovery. - - -.. _typelookup-service: - -TypeLookup Service ------------------- - -Using the Fast DDS API, when a participant discovers an endpoint that sends a type information -describing a type that the participant doesn't know, the participant listener's function -|DomainParticipantListener::on_type_information_received-api| -is called with the received TypeInformation. -The user can then try to retrieve the full TypeObject hierarchy to build the remote type locally, using the -TypeLookup Service. - -To enable this builtin TypeLookup Service, the user must enable it in the -:ref:`QoS` of the :ref:`dds_layer_domainParticipant`: - -.. tabs:: - - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //DDS_TYPELOOKUP_SERVICE_ENABLING - :end-before: //!-- - :dedent: 8 - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_TYPELOOKUP_SERVICE_ENABLING - :end-before: <--> - -A participant can be enabled to act as a TypeLookup server, client, or both. - -The process of retrieving the remote type from its TypeInformation, and then registering it, can be simplified -using the |DomainParticipant::register_remote_type-api| -function on the :ref:`dds_layer_domainParticipant`. -This function takes the name of the type, the type information, and a callback function. -Internally it uses the TypeLookup Service to retrieve the full TypeObject, -and, if successful, it will call the callback. - -This callback has the following signature: - -.. code-block:: c - - void(std::string& type_name, const DynamicType_ptr type) - -* **type_name**: Is the name given to the type when calling - |DomainParticipant::register_remote_type-api|, - to allow the same callback to be used across different calls. - -* **type**: If the |DomainParticipant::register_remote_type-api| - was able to build and register a :ref:`dynamictypes_overview_dynamictype`, this parameter contains - a pointer to the type. - Otherwise it contains ``nullptr``. - In the latter case, the user can still try to build the type manually using the factories, but it is very - likely that the build process will fail. - -:ref:`TopicDataType` contains a data member named -|TopicDataType::auto_fill_type_information-api|. -If set to true, the local participant will send the type information to the remote endpoint during discovery. - - diff --git a/docs/fastdds/dynamic_types/dynamic_types.rst b/docs/fastdds/dynamic_types/dynamic_types.rst deleted file mode 100644 index 158df34af..000000000 --- a/docs/fastdds/dynamic_types/dynamic_types.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _dynamic-types: - -Dynamic Topic Types -=================== - -.. _DDS-XTypes V1.2: http://www.omg.org/spec/DDS-XTypes/1.2 - -eProsima Fast DDS provides a dynamic way to define and use topic types and topic data. -Our implementation follows the *OMG Extensible and Dynamic Topic Types for DDS interface*. -For more information, you can read the specification for `DDS-XTypes V1.2`_. - -The dynamic topic types offer the possibility to work over RTPS without the restrictions related to the IDLs. -Using them, the users can declare the different types that they need and manage the information directly, -avoiding the additional step of updating the IDL file and the generation of *C++* classes. - -.. toctree:: - :maxdepth: 3 - - /fastdds/dynamic_types/concepts.rst - /fastdds/dynamic_types/supported_types.rst - /fastdds/dynamic_types/complex_types.rst - /fastdds/dynamic_types/annotations.rst - /fastdds/dynamic_types/discovery.rst - /fastdds/dynamic_types/serialization.rst - /fastdds/dynamic_types/xml_profiles.rst - /fastdds/dynamic_types/memory_management.rst - /fastdds/dynamic_types/examples.rst diff --git a/docs/fastdds/dynamic_types/examples.rst b/docs/fastdds/dynamic_types/examples.rst deleted file mode 100644 index 3affb5648..000000000 --- a/docs/fastdds/dynamic_types/examples.rst +++ /dev/null @@ -1,51 +0,0 @@ -.. include:: ../../03-exports/aliases.include -.. include:: ../../03-exports/aliases-api.include - -.. _dynamictypes_examples: - -Dynamic HelloWorld Examples -=========================== - -.. _Fast DDS GitHub repository: https://github.com/eProsima/Fast-DDS - -These are complete working examples that make use of dynamic types. -You can explore them to find how this feature connects to the rest of *Fast DDS*, -and learn how to integrate it in your own application. - -DynamicHelloWorldExample ------------------------- - -This example is in folder -`examples/cpp/dds/DynamicHelloWorldExample `_ -of the `Fast DDS GitHub repository`_. -It shows the use of DynamicType generation to provide the |TopicDataType|. -This example is compatible with the classic HelloWorldExample. - -As a quick reference, the following piece of code shows how the HelloWorld type is created using DynamicTypes: - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_HELLO_WORLD_API - :end-before: //!-- - :dedent: 8 - - -DDSDynamicHelloWorldExample ---------------------------- - -This example uses the DDS API, and can be retrieve from folder -`examples/cpp/dds/DynamicHelloWorldExample `_ -of the `Fast DDS GitHub repository`_. -It shows a publisher that loads a type from an XML file, and shares it during discovery. -The subscriber discovers the type using :ref:`discovery-time-data-typing`, and registers the -discovered type on the |DomainParticipantListener::on_type_discovery-api| listener function. - -TypeLookupService ------------------ - -This example uses the DDS API, and it is located in folder -`examples/cpp/dds/TypeLookupService `_ -of the `Fast DDS GitHub repository`_. -It is very similar to DDSDynamicHelloWorldExample, but the shared type is complex enough to require the -TypeLookup Service due to the dependency of inner struct types. -Specifically, it uses the |DomainParticipant::register_remote_type-api| approach with a callback. diff --git a/docs/fastdds/dynamic_types/memory_management.rst b/docs/fastdds/dynamic_types/memory_management.rst deleted file mode 100644 index bdc6caf64..000000000 --- a/docs/fastdds/dynamic_types/memory_management.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_memorymanagement: - -Memory management -================= - -Memory management is critical for dynamic types since -every dynamic type and dynamic data is managed with pointers. -Every object stored inside of a dynamic object is managed by its owner, and users -must delete every object they create using the factories. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_NOTES_1 - :end-before: //!-- - :dedent: 8 - -To ease this management, the library defines smart pointers (``DynamicTypeBuilder_ptr``, -``DynamicType`` and ``DynamicData_ptr``) that will delete the objects automatically when they are not -needed anymore. -``DynamicType`` will always be returned as ``DynamicType_ptr`` because there is no internal management of its memory. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_NOTES_2 - :end-before: //!-- - :dedent: 8 - -The only case where these smart pointers cannot be used is with functions ``loan_value`` and ``return_loaned_value``. -Raw pointers should be used with these functions, because the returned value should not be deleted, and using -a smart pointer with them will cause a crash. - - diff --git a/docs/fastdds/dynamic_types/serialization.rst b/docs/fastdds/dynamic_types/serialization.rst deleted file mode 100644 index adefa82e6..000000000 --- a/docs/fastdds/dynamic_types/serialization.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. _dynamictypes_serialization: - -Serialization -============= - -Dynamic Types have their own :class:`pubsub` type like any class generated with an IDL, and -their management is pretty similar to them. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_SERIALIZATION - :end-before: //!-- - :dedent: 8 - -A member can be marked to be ignored by serialization with the annotation ``@non_serialized``. - diff --git a/docs/fastdds/dynamic_types/supported_types.rst b/docs/fastdds/dynamic_types/supported_types.rst deleted file mode 100644 index 026a1fdd9..000000000 --- a/docs/fastdds/dynamic_types/supported_types.rst +++ /dev/null @@ -1,321 +0,0 @@ -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_supportedtypes: - -Supported Types -=============== - -In order to provide maximum flexibility and capability to the defined dynamic types, -eProsima Fast DDS supports several member types, ranging from simple primitives to nested structures. - -This section describes the basic (not nested) supported types. For more complex structures and -examples, please, refer to :ref:`dynamictypes_complextypes`. - - -.. contents:: - :local: - :backlinks: none - :depth: 2 - -.. _dynamictypes_supportedtypes_primitive: - -Primitive Types ---------------- - -This section includes every simple kind: - -+--------------------------+--------------------------+ -| ``BOOLEAN`` | ``INT64`` | -+--------------------------+--------------------------+ -| ``BYTE`` | ``UINT16`` | -+--------------------------+--------------------------+ -| ``CHAR8`` | ``UINT32`` | -+--------------------------+--------------------------+ -| ``CHAR16`` | ``UINT64`` | -+--------------------------+--------------------------+ -| ``INT16`` | ``FLOAT32`` | -+--------------------------+--------------------------+ -| ``INT32`` | ``FLOAT64`` | -+--------------------------+--------------------------+ -| ``FLOAT128`` | | -+--------------------------+--------------------------+ - -By definition, primitive types are self-described and can be created without configuration parameters. -Therefore, |DynamicTypeBuilderFactory| exposes several functions to allow users create -the dynamic type avoiding the |DynamicTypeBuilder| step. -The DynamicTypeBuilder can still be used to create dynamic data of primitive types, -as shown on the example below. -The DynamicData class has a specific :func:`get` and :func:`set` functions for each primitive -type of the list. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_PRIMITIVES - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_string: - -String and WString ------------------- - -Strings are pretty similar to primitive types, the main difference being -that they need to set the size of the ``buffer`` that they can manage. -By default this size is set to 255 characters. - -DynamicTypeBuilderFactory exposes the functions :func:`create_string_type` and :func:`create_wstring_type` -to allow users create the DynamicTypes avoiding the DynamicTypeBuilder step. -The DynamicTypeBuilder can still be used to create String type dynamic data, -as shown on the example below. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_STRINGS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_alias: - -Alias ------ - -Alias types provide an alternative name to an already existing type. -Once the DynamicData is created, users can access its information as if -they were working with the base type. - -DynamicTypeBuilderFactory exposes the function :func:`create_alias_type` to allow users -create the Alias types avoiding the DynamicTypeBuilder step. -The DynamicTypeBuilder can still be used to create Alias, -as shown on the example below. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_ALIAS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_enumeration: - -Enumeration ------------ - -An enumeration contains a set of supported values and a selected value among those supported. -The supported values must be configured using the DynamicTypeBuilder, using the :func:`add_member` function -for each supported value. -The input to this function is the index and the name of the value we want to add. - -The DynamicData class has functions :func:`get_enum_value` and :func:`set_enum_value` to work -with value index or value name name strings. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_ENUMERATIONS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_bitmask: - -Bitmask -------- - -Bitmasks are similar to `enumeration` types, but their members work as bit flags that can be individually turned on and -off. Bit operations can be applied when testing or setting a bitmask value. -DynamicData has the special functions :func:`get_bitmask_value` and :func:`set_bitmask_value` which allow to retrieve or -modify the full value instead of accessing each bit. - -Bitmasks can be bound to any number of bits up to 64. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_BITMASKS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_structure: - -Structure ---------- - -Structures are the common complex types, they allow to add any kind of members inside them. -They do not have any value, they are only used to contain other types. - -To manage the types inside the structure, users can call the :func:`get` and :func:`set` functions -according to the kind of the type inside the structure using their ``ids``. -If the structure contains a complex value, it should be used with ``loan_value`` to -access to it and ``return_loaned_value`` to release that pointer. -DynamicData manages the counter of loaned values and users can not loan a value that -has been loaned previously without calling ``return_loaned_value`` before. - -The ``ids`` must be consecutive starting by zero, and the DynamicType will change that -Id if it doesn't match with the next value. -If two members have the same Id, after adding the second one, the previous -will change its Id to the next value. -To get the Id of a member by name, DynamicData exposes the function :func:`get_member_id_by_name`. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_STRUCTS - :end-before: //!-- - :dedent: 8 - -Structures allow inheritance, exactly with the same OOP meaning. To inherit from another structure, we must create the -structure calling the :func:`create_child_struct_builder` of the factory. This function is shared with bitsets and will -deduce our type depending on the parent's type. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_STRUCTS-INHERIT - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_bitset: - -Bitset ------- - -Bitset types are similar to `structure` types, but their members are merely `bitfields`, which are stored optimally. -In the static version of bitsets, each bit uses just one bit in memory (with platform limitations) without alignment -considerations. A bitfield can be anonymous (cannot be addressed) to skip unused bits within a bitset. - -Each bitfield in a bitset can be modified through their minimal needed primitive representation. - -+--------------------------+--------------------------+ -| Number of bits | Primitive | -+--------------------------+--------------------------+ -| ``1`` | ``BOOLEAN`` | -+--------------------------+--------------------------+ -| ``2-8`` | ``UINT8`` | -+--------------------------+--------------------------+ -| ``9-16`` | ``UINT16`` | -+--------------------------+--------------------------+ -| ``17-32`` | ``UINT32`` | -+--------------------------+--------------------------+ -| ``33-64`` | ``UINT64`` | -+--------------------------+--------------------------+ - -Each bitfield (or member) works like its primitive type with the only difference that the internal storage only -modifies the involved bits instead of the full primitive value. - -Bit_bound and position of the bitfield can be set using annotations (useful when converting between static and dynamic -bitsets). - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_BITSETS - :end-before: //!-- - :dedent: 8 - -Bitsets allows inheritance, exactly with the same OOP meaning. To inherit from another bitset, we must create the -bitset calling the ``create_child_struct_builder`` of the factory. This function is shared with structures and will -deduce our type depending on the parent's type. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_BITSETS-INHERIT - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_union: - -Union ------ - -Unions are a special kind of structures where only one of the members is active -at the same time. -To control these members, users must set the ``discriminator`` type that is going to be used -to select the current member calling the ``create_union_builder`` function. -The ``discriminator`` itself is a DynamicType of any primitive type, string type or union type. - -Every member that is going to be added needs at least one ``union_case_index`` to set -how it is going to be selected and, optionally, if it is the default value of the union. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_UNIONS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_sequence: - -Sequence --------- - -A complex type that manages its members as a list of items allowing users to -insert, remove or access to a member of the list. To create this type users -need to specify the type that it is going to store and optionally the size -limit of the list. - -To ease the memory management of this type, DynamicData has these functions: - - - :func:`insert_sequence_data`: Creates a new element at the end of the list and returns - the ``id`` of the new element. - - :func:`remove_sequence_data`: Removes the element of the given index and refreshes the ``ids`` - to keep the consistency of the list. - - :func:`clear_data`: Removes all the elements of the list. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_SEQUENCES - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_array: - -Array ------ - -Arrays are pretty similar to sequences with two main differences: -they can have multiple dimensions and they do not need their elements -to be stored consecutively. - -An array needs to know the number of dimensions it is managing. -For that, users must provide a vector with as many elements as dimensions in the array. -Each element in the vector represents the size of the given dimension. -If the value of an element is set to zero, the default value applies (``100``). - -Id values on the :func:`set` and :func:`get` functions of DynamicData correspond to the array index. -To ease the management of array elements, every :func:`set` function in DynamicData class creates -the item if the given index is empty. - -To ease the memory management of this type, DynamicData has these functions: - - * :func:`insert_array_data`: Creates a new element at the end of the array and returns - the ``id`` of the new element. - * :func:`remove_array_data`: Clears the element of the given index. - * :func:`clear_data`: Removes all the elements of the array. - * :func:`get_array_index`: Returns the position id giving a vector of indexes on every dimension - that the arrays support, which is useful in multidimensional arrays. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_ARRAYS - :end-before: //!-- - :dedent: 8 - -.. _dynamictypes_supportedtypes_map: - -Map ---- - -Maps contain a list of 'key-value' pair types, allowing users to insert, remove or -modify the element types of the map. -The main difference with sequences is that the map works with pairs of elements and -creates copies of the key element to block the access to these elements. - -To create a map, users must set the types of the key and the value elements, and, -optionally, the size limit of the map. - -To ease the memory management of this type, `DynamicData` has these functions: - - * :func:`insert_map_data`: Inserts a new key value pair and returns the ids of the newly - created key and value elements. - * :func:`remove_map_data`: Uses the given id to find the key element and removes the key - and the value elements from the map. - * :func:`clear_data`: Removes all the elements from the map. - -.. literalinclude:: /../code/CodeTester.cpp - :language: c++ - :start-after: //DYNAMIC_TYPES_CREATE_MAPS - :end-before: //!-- - :dedent: 8 - diff --git a/docs/fastdds/dynamic_types/xml_profiles.rst b/docs/fastdds/dynamic_types/xml_profiles.rst deleted file mode 100644 index 90b53e8dd..000000000 --- a/docs/fastdds/dynamic_types/xml_profiles.rst +++ /dev/null @@ -1,17 +0,0 @@ -.. include:: ../../03-exports/aliases-api.include -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_xmlprofiles: - - -XML profiles ------------- - -:ref:`XMLDynamicTypes` allows *eProsima Fast DDS* to create DynamicTypes directly defining them through XML. -This allows any application to change |TopicDataTypes| without the need to change its source code. - -Please, refer to :ref:`XMLDynamicTypes` for further information about how to use this feature. - - - - diff --git a/docs/fastdds/getting_started/simple_app/includes/dataType.rst b/docs/fastdds/getting_started/simple_app/includes/dataType.rst index eb054adbb..a9ddada72 100644 --- a/docs/fastdds/getting_started/simple_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_app/includes/dataType.rst @@ -41,12 +41,13 @@ To do this, run the following command from the ``src`` directory. This must have generated the following files: - * HelloWorld.cxx: HelloWorld type definition. - * HelloWorld.h: Header file for HelloWorld.cxx. + * HelloWorld.hpp: HelloWorld type definition. * HelloWorldPubSubTypes.cxx: Interface used by Fast DDS to support HelloWorld type. * HelloWorldPubSubTypes.h: Header file for HelloWorldPubSubTypes.cxx. * HelloWorldCdrAux.ipp: Serialization and Deserialization code for the HelloWorld type. * HelloWorldCdrAux.hpp: Header file for HelloWorldCdrAux.ipp. + * HelloWorldTypeObjectSupport.cxx: |TypeObject| registration code. + * HelloWorldTypeObjectSupport.hpp: Header file for HelloWorldTypeObjectSupport.cxx. CMakeLists.txt """""""""""""" diff --git a/docs/fastdds/getting_started/simple_app/includes/workspace.rst b/docs/fastdds/getting_started/simple_app/includes/workspace.rst index 2cfd0e60b..6a92c8380 100644 --- a/docs/fastdds/getting_started/simple_app/includes/workspace.rst +++ b/docs/fastdds/getting_started/simple_app/includes/workspace.rst @@ -18,15 +18,16 @@ Subscriber application respectively. │   └── Makefile ├── CMakeLists.txt └── src - ├── HelloWorld.cxx - ├── HelloWorld.h + ├── HelloWorld.hpp ├── HelloWorld.idl ├── HelloWorldCdrAux.hpp ├── HelloWorldCdrAux.ipp ├── HelloWorldPublisher.cpp ├── HelloWorldPubSubTypes.cxx ├── HelloWorldPubSubTypes.h - └── HelloWorldSubscriber.cpp + ├── HelloWorldSubscriber.cpp + ├── HelloWorldTypeObjectSupport.cxx + └── HelloWorldTypeObjectSupport.hpp Let's create the directory tree first. diff --git a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst index 9c03a5f1b..28ae08515 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst @@ -42,14 +42,15 @@ To do this, run the following command. This must have generated the following files: - * HelloWorld.cxx: HelloWorld C++ type definition. - * HelloWorld.h: C++ header file for HelloWorld.cxx. + * HelloWorld.hpp: HelloWorld C++ type definition. * HelloWorld.i: `SWIG`_ interface file for HelloWorld C++ type definition. * HelloWorldPubSubTypes.cxx: C++ interface used by Fast DDS to support HelloWorld type. * HelloWorldPubSubTypes.h: C++ header file for HelloWorldPubSubTypes.cxx. * HelloWorldPubSubTypes.i: `SWIG`_ interface file for C++ Serialization and Deserialization code. * HelloWorldCdrAux.ipp: C++ serialization and deserialization code for the HelloWorld type. * HelloWorldCdrAux.hpp: C++ header file for HelloWorldCdrAux.ipp. + * HelloWorldTypeObjectSupport.cxx: |TypeObject| registration code. + * HelloWorldTypeObjectSupport.hpp: Header file for HelloWorldTypeObjectSupport.cxx. * CMakeLists.txt: CMake file to generate C++ source code and Python module from the `SWIG`_ interface files, compile and generate C++ libraries. diff --git a/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst b/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst index 916941211..6569ee0b6 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst @@ -11,8 +11,7 @@ Subscriber application respectively. ├── CMakeCache.txt ├── CMakeFiles ├── CMakeLists.txt - ├── HelloWorld.cxx - ├── HelloWorld.h + ├── HelloWorld.hpp ├── HelloWorld.i ├── HelloWorld.idl ├── HelloWorld.py @@ -23,6 +22,8 @@ Subscriber application respectively. ├── HelloWorldPubSubTypes.i ├── HelloWorldPublisher.py ├── HelloWorldSubscriber.py + ├── HelloWorldTypeObjectSupport.cxx + ├── HelloWorldTypeObjectSupport.hpp ├── Makefile ├── _HelloWorldWrapper.so ├── cmake_install.cmake diff --git a/docs/fastdds/getting_started/simple_python_app/simple_python_app.rst b/docs/fastdds/getting_started/simple_python_app/simple_python_app.rst index abe8641f7..9c12f0fbb 100644 --- a/docs/fastdds/getting_started/simple_python_app/simple_python_app.rst +++ b/docs/fastdds/getting_started/simple_python_app/simple_python_app.rst @@ -1,3 +1,4 @@ +.. include:: ../../../03-exports/aliases.include .. include:: ../../../03-exports/aliases-python.include .. _writing_pubsub_python_app: diff --git a/docs/fastdds/library_overview/includes/exec_model.rst b/docs/fastdds/library_overview/includes/exec_model.rst index 15107b2c5..2a4491937 100644 --- a/docs/fastdds/library_overview/includes/exec_model.rst +++ b/docs/fastdds/library_overview/includes/exec_model.rst @@ -33,96 +33,103 @@ Transport related threads (marked as UDP, TCP and SHM types) are only created wh * - Event - General - One per DomainParticipant - - ``dds.ev.`` + - :code:`dds.ev.` - Processes periodic and triggered time events. |br| See :ref:`dds_layer_domainParticipantQos`. * - Discovery Server Event - General - One per DomainParticipant - - ``dds.ds_ev.`` + - :code:`dds.ds_ev.` - Synchronizes access to the Discovery Server |br| Database. |br| See :ref:`dds_layer_domainParticipantQos`. * - Asynchronous Writer - General - One per enabled asynchronous |br| flow controller. Minimum 1. - - ``dds.asyn..`` |br| - ```` + - :code:`dds.asyn..` |br| + :code:`` - Manages asynchronous writes. Even for synchronous writers, some forms of |br| communication must be initiated in the |br| background. |br| See :ref:`dds_layer_domainParticipantQos` and :ref:`flowcontrollersqos`. * - Datasharing Listener - General - One per |br| DataReader - - ``dds.dsha.`` + - :code:`dds.dsha.` - Listener thread that processes messages |br| received via Datasharing. |br| See :ref:`dds_layer_subscriber_dataReaderQos`. * - Reception - UDP - One per port - - ``dds.udp.`` + - :code:`dds.udp.` - Listener thread that processes incoming |br| UDP messages. |br| See :ref:`transportconfigqos` and :ref:`transport_udp_transportDescriptor`. * - Reception - TCP - One per TCP connection - - ``dds.tcp.`` + - :code:`dds.tcp.` - Listener thread that processes incoming |br| TCP messages. |br| See :ref:`transport_tcp_transportDescriptor`. * - Accept - TCP - One per TCP transport - - ``dds.tcp_accept`` + - :code:`dds.tcp_accept` - Thread that processes incoming TCP connection requests. |br| See :ref:`transport_tcp_transportDescriptor`. * - Keep Alive - TCP - One per TCP transport - - ``dds.tcp_keep`` + - :code:`dds.tcp_keep` - Keep alive thread for TCP connections. |br| See :ref:`transport_tcp_transportDescriptor`. * - Reception - SHM - One per port - - ``dds.shm.`` + - :code:`dds.shm.` - Listener thread that processes incoming |br| messages via SHM segments. |br| See :ref:`transportconfigqos` and :ref:`transport_sharedMemory_transportDescriptor`. * - Logging - SHM - One per port - - ``dds.shmd.`` + - :code:`dds.shmd.` - Stores and dumps transferred packets to a file. |br| See :ref:`transportconfigqos` and :ref:`transport_sharedMemory_transportDescriptor`. * - Watchdog - SHM - One - - ``dds.shm.wdog`` + - :code:`dds.shm.wdog` - Monitors health of open shared memory |br| segments. |br| See :ref:`transportconfigqos` and :ref:`transport_sharedMemory_transportDescriptor`. * - General Logging - Log - One - - ``dds.log`` + - :code:`dds.log` - Accumulates and writes to the appropriate |br| consumer log entries. |br| See :ref:`dds_layer_log_thread`. * - Security Logging - Log - One per |br| DomainParticipant - - ``dds.slog.`` + - :code:`dds.slog.` - Accumulates and writes security log entries. |br| See :ref:`dds_layer_domainParticipantQos`. * - Watchdog - Filewatch - One - - ``dds.fwatch`` + - :code:`dds.fwatch` - Tracks the status of the watched file for |br| modifications. |br| See :ref:`dds_layer_domainParticipantFactoryQos`. * - Callback - Filewatch - One - - ``dds.fwatch.cb`` + - :code:`dds.fwatch.cb` - Runs the registered callback when the |br| watched file changes. |br| See :ref:`dds_layer_domainParticipantFactoryQos`. + * - Reception + - TypeLookup Service + - Two per DomainParticipant + - :code:`dds.tls.replies.` |br| + :code:`dds.tls.requests.` + - Runs when remote endpoint discovery information has been received |br| + with unknown data type. Some of these threads are only spawned when certain conditions are met: diff --git a/docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst b/docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst new file mode 100644 index 000000000..77dc253dd --- /dev/null +++ b/docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst @@ -0,0 +1,69 @@ +.. include:: ../../../03-exports/aliases.include +.. include:: ../../../03-exports/aliases-api.include + +.. _use-case-remote-type-discovery-and-matching: + +Remote type discovery and endpoint matching +=========================================== + +This section explains how to create an endpoint using a remotely discovered data type that was previously unknown to the +local participant. + +Prerequisites +------------- + +This use case focuses on the strategy to follow in order to create an endpoint at runtime in a previously unknown topic +using the information provided by the remote endpoint discovery information. +Therefore, the prerequisites are: + +.. TODO: third prerequiste will be obsolete once the DynamicTypes defined using the Dynamic Language Binding are + able to be registered into TypeObjectRegistry. + +* Two participants, A and B, running in different process (type information is shared within the same + DomainParticipantFactory). +* Participant A must not know the data type registered in participant B. +* Participant B data type must be registered using the code generated by + :ref:`eProsima Fast DDS-Gen` without disabling the TypeObjectSupport code generation. +* Participant B must create an endpoint using the data type unknown by participant A. +* Participant A must be attached to a :ref:`dds_layer_domainParticipantListener`. + +Remote type discovery +--------------------- + +Following the :ref:`participant discovery phase `, the endpoint information is exchanged. +The appropriate |DomainParticipantListener::on_data_reader_discovery-api| or +|DomainParticipantListener::on_data_writer_discovery-api| callback is called, depending on the kind of endpoint +created on the remote participant. +The endpoint discovery callback provides access to the remotely discovered information including the |TypeInformation|. + +Provided the :code:`TypeInformation`, |ITypeObjectRegistry-api| singleton can be queried for the corresponding +|TypeObject| calling |ITypeObjectRegistry::get_type_object| API. + +Register remote type +-------------------- + +|DynamicTypeBuilderFactory-api| provides a specific API that given a |TypeObject| returns the corresponding +|DynamicTypeBuilder-api|: |DynamicTypeBuilderFactory::create_type_w_type_object|. +The |DynamicType-api| can then be obtained and registered using |DynamicPubSubType-api|. + +Create local endpoint +--------------------- + +Once the remote type has been locally registered, a :ref:`Topic` can be created within the +DomainParticipant and endpoints using this Topic might be also created. + +.. note:: + + Endpoint matching takes into consideration QoS consistency. + Consequently, for the local endpoint to match, the remote QoS has to be taken into account. + The remote endpoint discovery information provided by the discovery callback includes also this data. + +Example +------- + +The following snippet shows the previously explained steps: + +.. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--REMOTE_TYPE_MATCHING + :end-before: //!-- diff --git a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst index adce32741..dbf6424f4 100644 --- a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst +++ b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst @@ -147,14 +147,19 @@ For the IDL being used in this example the data type name would be "fastdds_reco Create a new workspace different from the ROS 2 one used previously. Copy inside the same IDL file and run Fast DDS-Gen to generate -the TypeSupport and the example source files: +the TypeSupport and the example source files. + +.. note:: + + Fast DDS-Gen :code:`-no-typeobjectsupport` option is advisable to be enabled as this feature does not ensure vendor + interoperability for the moment. .. code-block:: bash mkdir HelloWorldExample cd HelloWorldExample cp /fastdds_record_typesupport/idl/HelloWorld.idl . - fastddsgen -example CMake -typeros2 HelloWorld.idl + fastddsgen -example CMake -typeros2 -no-typeobjectsupport HelloWorld.idl This command will populate the current folder with the required header and source files to build the TypeSupport, and the Publisher and Subscriber applications. @@ -163,8 +168,9 @@ and the Publisher and Subscriber applications. └── HelloWorldExample    ├── CMakeLists.txt -    ├── HelloWorld.cxx -    ├── HelloWorld.h +    ├── HelloWorldCdrAux.hpp +    ├── HelloWorldCdrAux.ipp +    ├── HelloWorld.hpp    ├── HelloWorld.idl    ├── HelloWorldPublisher.cxx    ├── HelloWorldPublisher.h diff --git a/docs/fastdds/use_cases/use_cases.rst b/docs/fastdds/use_cases/use_cases.rst index 207296f90..a55848155 100644 --- a/docs/fastdds/use_cases/use_cases.rst +++ b/docs/fastdds/use_cases/use_cases.rst @@ -98,6 +98,10 @@ with distributed systems: *Request-Reply* communications. This use case explains how to use the APIs to communicate two application using *Request-Reply*. ++ :ref:`use-case-remote-type-discovery-and-matching`. + This use case leverages the :ref:`xtypes_discovery_matching` to create endpoints and start communicating with remote + discovered endpoints with previously unknown data types. + .. toctree:: :maxdepth: 2 :hidden: @@ -115,3 +119,4 @@ with distributed systems: /fastdds/use_cases/dynamic_network_interfaces/dynamic_network_interfaces.rst /fastdds/use_cases/rosbag_capture/rosbag_capture.rst /fastdds/use_cases/request_reply/request_reply.rst + /fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst diff --git a/docs/fastdds/xml_configuration/domainparticipant.rst b/docs/fastdds/xml_configuration/domainparticipant.rst index 1e2a74042..b6aadbd44 100644 --- a/docs/fastdds/xml_configuration/domainparticipant.rst +++ b/docs/fastdds/xml_configuration/domainparticipant.rst @@ -202,6 +202,12 @@ These elements allow the user to define the DomainParticipant configuration. - |ThreadSettings| for the discovery server thread. - |ThreadSettings| - + * - ```` + - |ThreadSettings| for the threads used by the builtin TypeLookup service |br| + to discover unknown remote types. |br| + See :ref:`xtypes_discovery_matching`. + - |ThreadSettings| + - * - ```` - |ThreadSettings| for the builtin transports reception threads. - |ThreadSettings| @@ -323,12 +329,6 @@ This section specifies the available XML members for the configuration of this port is already in use. - ``uint32_t`` - 100 - * - ``typelookup_config`` - - TypeLookup Service settings. |br| - See :ref:`typelookup-service`. - - :ref:`typelookup_config` - - - **Example** @@ -520,28 +520,6 @@ Initial Announcements | ```` | The period for the DomainParticipant to send its discovery messages. | :ref:`DurationType` | 100 ms | +--------------+-----------------------------------------------------------------------+---------------------+---------+ -.. _typelookup_config: - -TypeLookup Service Configuration -################################ - -.. list-table:: - :header-rows: 1 - :align: left - - * - Name - - Description - - Values - - Default - * - ``use_client`` - - Create TypeLookup Service client builtin endpoints. - - ``bool`` - - ``false`` - * - ``use_server`` - - Create TypeLookup Service server builtin endpoints. - - ``bool`` - - ``false`` - .. _Port: Port Configuration diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index df1cc6f4e..860428577 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -8,15 +8,14 @@ Dynamic Types profiles ---------------------- *Fast DDS* supports the implementation of |DynamicTypes| by defining them through XML files. -Thus the :ref:`Dynamic Types ` can be modified without the need to modify the source code of the DDS -application. +Thus the topic data types can be modified without the need to modify the source code of the DDS application. XML Structure ^^^^^^^^^^^^^ -The definition of type profiles in the XML file is done with the ```` tag. -Each ```` element can contain one or more :ref:`Type definitions `. -Defining several types within a ```` element or a single type for each ```` element has the same +The definition of data type profiles in the XML file is done with the :code:`types` tag. +Each :code:`types` element can contain one or more :ref:`Type definitions `. +Defining several types within a :code:`types` element or a single type for each :code:`types` element has the same result. Below, an example of a stand-alone types definition via XML is shown. @@ -34,31 +33,29 @@ Below, an example of a stand-alone types definition via XML is shown. Type definition ^^^^^^^^^^^^^^^ -Below, the types supported by *Fast DDS* are presented . -For further information about the supported |DynamicTypes|, please, refer to :ref:`dynamictypes_supportedtypes`. -For each of the types detailed below, an example of how to build the type's XML profile is provided. - -* `Member types`_ - - - `Primitive types`_ - - `Bounded strings`_ - - `Sequences`_ - - `Arrays`_ - - `Maps`_ - -* `Enumerations`_ -* `Typedef`_ -* `Struct`_ -* `Union`_ -* `Bitset`_ -* `Bitmask`_ -* `Complex types`_ +Below, the types supported by *eProsima Fast DDS* are presented. +For further information about the supported |DynamicTypes|, please, refer to :ref:`xtypes_supportedtypes`. +For each type listed below, an example of how to build the type's XML profile is provided. + +* `Primitive types`_ +* :ref:`xmldynamictypes_strings` +* :ref:`xmldynamictypes_enums` +* :ref:`xmldynamictypes_bitmask` +* :ref:`xmldynamictypes_typedef` +* :ref:`xmldynamictypes_sequence` +* :ref:`xmldynamictypes_array` +* :ref:`xmldynamictypes_map` +* :ref:`xmldynamictypes_struct` +* :ref:`xmldynamictypes_union` +* :ref:`xmldynamictypes_bitset` + +.. _xmldynamictypes_member: Member types """""""""""" -Member types are defined as any type that can belong to a `Struct`_ or a `Union`_, or be aliased by a -`Typedef`_. +Member types are defined as any type that can belong to a :ref:`Struct` or a +:ref:`Union `, or be aliased by a :ref:`Alias `. These can be defined by the ```` XML tag. A member can be annotated as ``key`` (equivalent of the IDL's ``@key``) by setting the ``key`` attribute to ``"true"``. @@ -67,248 +64,384 @@ A member can be annotated as ``key`` (equivalent of the IDL's ``@key``) by setti :start-after: XML-MEMBER_WITH_KEY<--> :end-before: <--> +.. _xmldynamictypes_primivites: + Primitive types -*************** +""""""""""""""" -The identifiers of the available basic types are listed in the table below. -Please, refer to :ref:`dynamictypes_supportedtypes_primitive` for more information on the primitive types. +Primitive types are built-in types and they should be declared as members of an aggregated type +(:ref:`xmldynamictypes_struct` or :ref:`xmldynamictypes_union`). +Primitive types are declared by attribute :code:`type` and the possible values are listed in the table below. +Please, refer to :ref:`xtypes_supportedtypes_primitive` for more information on primitive types. .. list-table:: * - ``boolean`` + - ``byte`` - ``char8`` - ``char16`` - * - ``byte`` - - ``octet`` + - ``int32`` + * - ``uint32`` + - ``int8`` - ``uint8`` - * - ``int8`` - ``int16`` - - ``int32`` - * - ``uint16`` - - ``uint32`` - - ``int64`` - * - ``uint64`` + - ``uint16`` + * - ``int64`` + - ``uint64`` - ``float32`` - ``float64`` - * - ``float128`` - - ``string`` - - ``wstring`` + - ``float128`` -All of them are defined as follows: +All of them are declared as follows: -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-GENERIC<--> - :end-before: <--> +.. tabs:: -Bounded strings -*************** + .. tab:: XML -Bounded strings are defined as any other ``string`` or ``wstring`` but adding the attribute ``stringMaxLength`` with the -maximum length available for that specific string. -Please, refer to :ref:`dynamictypes_supportedtypes_string` for more information on string type. + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_PRIMITIVES<--> + :end-before: <--> -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BOUNDEDSTRINGS<--> - :end-before: <--> + .. tab:: IDL -Sequences -********* + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_PRIMITIVES + :end-before: //!-- -The sequence type is implemented by setting three attributes: ``name``, ``type``, and the -``sequenceMaxLength``. -The type of its content should be defined by the ``type`` attribute. -Please, refer to :ref:`dynamictypes_supportedtypes_sequence` section for more information on sequence type. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-SEQUENCES<--> - :end-before: <--> +.. _xmldynamictypes_strings: -Arrays -****** +String Types +"""""""""""" -Arrays are defined in the same way as any other member type but they add the attribute ``arrayDimensions``. -The format of the ``arrayDimensions`` attribute value is the size of each dimension separated by commas. -Please, refer to :ref:`dynamictypes_supportedtypes_array` explanation for more information on array type. +String types should be defined as members of an aggregated type (:ref:`xmldynamictypes_struct` or +:ref:`xmldynamictypes_union`). +String types are defined with attribute :code:`type` set to :code:`string` or :code:`wstring`. +An optional attribute :code:`stringMaxLength` might used to set a maximum length for the string collection. +Please, refer to :ref:`xtypes_supportedtypes_string` for more information on string types. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-ARRAYS<--> - :end-before: <--> +.. tabs:: -Maps -**** + .. tab:: XML -Maps are similar to sequences, but they need to define two content types. -The ``key_type`` defines the type of the map key, while the ``type`` defines the map value type. -See section :ref:`dynamictypes_supportedtypes_map` for more information on map type. + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRINGS<--> + :end-before: <--> -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-MAPS<--> - :end-before: <--> + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_STRINGS + :end-before: //!-- + +.. _xmldynamictypes_enums: + +Enumeration Types +""""""""""""""""" + +Enumeration types are defined using the :code:`` tag. +Attribute :code:`name` and at least one :code:`` child element are mandatory. +Enumeration literals are defined using the :code:`` tag with mandatory attribute :code:`name`. +Optionally, unsigned integer attribute :code:`value` might be added to set a specific value for the enumeration literal. + +.. note:: + + :code:`value` attribute is equivalent to :code:`@value` builtin annotation which is not still supported in neither + the plain (IDL) nor |DynamicTypes|. + +Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information on enumeration types. + +.. tabs:: + + .. tab:: XML -Complex types + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ENUM<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_ENUM + :end-before: //!-- + +.. _xmldynamictypes_bitmask: + +Bitmask Types """"""""""""" -The complex types are a combination of the aforementioned types. -Complex types can be defined using the ```` element in the same way a basic or an array type would be. -The ``type`` in this case is ``nonBasic`` (not a `Primitive types`_) and the name of the previously defined type is -given in the ``nonBasicTypeName`` attribute. -Please, refer to :ref:`dynamictypes_complextypes` section for more information on complex types. +Bitmask types are defined using the :code:`` tag. +Attribute :code:`name` and at least on :code:`` child element are mandatory. +Optionally, :code:`bit_bound` attribute might be set to specify the bitmask bound (by default 32 bits). +Bitflag elements are defined using the :code:`` tag with mandatory attribute :code:`name`. +Optionally, :code:`position` attribute might be defined to set the bitflag position within the bitmask. +Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on bitmask types. -The following example shows a new structure with the ``primitive_types_example`` struct defined in `Primitive types`_ -example. +.. tabs:: -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-COMPLEX<--> - :end-before: <--> + .. tab:: XML -Complex types attributes -************************ + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITMASK<--> + :end-before: <--> -The attributes of a complex type element can be highly varied depending on the type being defined. -Since the attributes that can be defined for each of the types have already been listed, -these attributes are then defined in the following table. + .. tab:: IDL -.. list-table:: - :header-rows: 1 - - * - Name - - Description - * - ``type`` - - Data type. - This can be a `Primitive types`_ or a ``nonBasic`` type. |br| - The latter is used to denote that a complex type is defined. - * - ``nonBasicTypeName`` - - Name of the complex type. Only applies if the ``type`` attribute is set to ``nonBasic``. - * - ``stringMaxLength`` - - Maximum length of a string. - * - ``sequenceMaxLength`` - - Maximum length of a `Sequences`_. - * - ``arrayDimensions`` - - Dimensions of an array. - * - ``key_type`` - - Data type of a map key. - * - ``mapMaxLength`` - - Maximum length of a `Maps`_. - -Typedef -""""""" - -The ```` XML element is defined by a ``name`` and a ``type`` mandatory attributes, and any of the optional -attributes presented in `Complex types attributes`_ section. -This element allows for defining complex types without the need to define them previously as members. -Maps, arrays and sequences can be elements within another container using ````. -The ```` element corresponds to :ref:`dynamictypes_supportedtypes_alias` in :ref:`dynamictypes_supportedtypes` -section. + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_BITMASK + :end-before: //!-- -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-TYPEDEF<--> - :end-before: <--> +.. _xmldynamictypes_typedef: -Enumerations -"""""""""""" +Alias Types +""""""""""" -The ```` type is defined by its attribute ``name`` and a set of ```` child elements. -Each ```` is defined by two attributes: a mandatory ``name`` and an optional unsigned integer ``value``. -Please, refer to :ref:`dynamictypes_supportedtypes_enumeration` for more information on the ```` type. +Alias types are defined using the :code:`` tag. +Attributes :code:`name` and :code:`type` are mandatory. +Depending on the aliased type, some other mandatory and/or optional attributes might be necessary or available. +Non-primitive types must define the :code:`type` attribute as :code:`nonBasic` and include the :code:`nonBasicTypeName` +attribute with the name of the aliased type. +Please, refer to :ref:`xtypes_supportedtypes_alias` for more information on alias types. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-DYN-ENUM<--> - :end-before: <--> +.. tabs:: -Struct -"""""" + .. tab:: XML -The ```` element is defined by its ``name`` attribute and its ```` child elements. -Please, refer to :ref:`dynamictypes_supportedtypes_structure` for more information on the ```` type. + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_TYPEDEF<--> + :end-before: <--> -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-STRUCT<--> - :end-before: <--> + .. tab:: IDL -Structs can inherit from another struct. -This is implemented by defining the value of the ``baseType`` attribute, on the child ```` element to be the -value of the ``name`` attribute of the parent ```` element. -This is exemplified by the code snippet below. + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_TYPEDEF + :end-before: //!-- -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-STRUCT-INHERIT<--> - :end-before: <--> +.. _xmldynamictypes_sequence: -Union -""""" +Sequence Types +"""""""""""""" -The ```` type is defined by a ``name`` attribute, a ```` child element and a set of ```` -child elements. -The ```` must define its ``type`` -Each ```` element has one or more ```` elements, which type must be consistent with the -```` type, and a unique ```` element. -Please, refer to :ref:`dynamictypes_supportedtypes_union` for more information on the ```` type. +Sequence types should be defined as members of an aggregated type (:ref:`xmldynamictypes_struct` or +:ref:`xmldynamictypes_union`). +Sequence types are defined with mandatory attributes :code:`type` set to the collection's element type, and +:code:`sequenceMaxLength` used to set the maximum collection's length. +Unbounded sequences should set :code:`sequenceMaxLength` attribute to :code:`-1`. +Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on sequence types. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-UNION<--> - :end-before: <--> +.. tabs:: -Bitset -"""""" + .. tab:: XML -The ```` element defines the :ref:`dynamictypes_supportedtypes_bitset` type. -It is comprised by a ``name`` attribute and a set of ```` child elements. -In turn, the ```` element has the mandatory ``bit_bound`` attribute, which cannot be higher than 64, and -two optional attributes: ``name`` and ``type``. -A ```` without ``name`` attribute is an inaccessible set of bits. -Its management ``type`` can ease the ```` modification and access. -Please, refer to :ref:`dynamictypes_supportedtypes_bitset` for more information about the ```` type. + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_SEQUENCES<--> + :end-before: <--> -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BITSET<--> - :end-before: <--> + .. tab:: IDL -Moreover, bitsets can inherit from another bitsets: + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_SEQUENCES + :end-before: //!-- -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BITSET-INHERIT<--> - :end-before: <--> +.. _xmldynamictypes_array: -Bitmask -""""""" +Array Types +""""""""""" -The ```` element, which corresponds to the :ref:`dynamictypes_supportedtypes_bitmask` type, is defined by -a mandatory ``name`` attribute, an optional ``bit_bound`` attribute, and several ```` child elements. -The ``bit_bound`` attribute specifies the number of bits that the bitmask type will manage. -The maximum value allowed for the ``bit_bound`` is 64. -The ```` element must define the ``name`` attribute and it might define its position in the bitmask setting -the ``positition`` attribute. -Please, refer to :ref:`dynamictypes_supportedtypes_bitmask` for more information on the ```` type. +Array types should be defined as members of an aggregated type (:ref:`xmldynamictypes_struct` or +:ref:`xmldynamictypes_union`). +Array types are defined with mandatory attributes :code:`type` set to the collection's element type, and +:code:`arrayDimensions` used to set the collection's dimensions. +The format of :code:`arrayDimensions` attribute value is the size of each dimension separated by commas. +Please, refer to :ref:`xtypes_supportedtypes_array` for more information on array types. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BITMASK<--> - :end-before: <--> +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ARRAYS<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_ARRAYS + :end-before: //!-- + +.. _xmldynamictypes_map: + +Map Types +""""""""" + +Map types should be defined as members of an aggregated type (:ref:`xmldynamictypes_struct` or +:ref:`xmldynamictypes_union`). +Map types are defined with mandatory attributes :code:`type` set to the map's value type, :code:`key_type` set to the +map's key type, and :code:`mapMaxLength` used to set the maximum map's number of key-value pairs. +Unbounded maps should set :code:`mapMaxLength` attribute to :code:`-1`. +Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map types. + +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_MAPS<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_MAPS + :end-before: //!-- + +.. _xmldynamictypes_struct: + +Structure Types +""""""""""""""" + +Structure types are defined using the :code:`` tag with mandatory attribute :code:`name`. +Structure inheritance may be configured setting optional attribute :code:`baseType`. +XML Structure Types require at least one member defined. + +.. note:: + + `IDL specification `__ introduced in version 4.1 the possibility of void + content structures. + Empty structures are not supported in XML Types profiles yet. + +Structure members are defined using the :code:`` tag with mandatory attributes :code:`name` and :code:`type`. +Depending on the member type, some other mandatory and/or optional attributes might be necessary or available. +Non-primitive types must define the :code:`type` attribute as :code:`nonBasic` and include the :code:`nonBasicTypeName` +attribute with the name of the member type. + +.. note:: + + Currently, XML Types profiles does not support setting the member ID or marking a member as key. + +Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on structure types. + +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRUCT<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_STRUCT + :end-before: //!-- + +.. _xmldynamictypes_union: + +Union Types +""""""""""" + +Union types are defined using the :code:`` tag with mandatory attribute :code:`name`. +A mandatory discriminator child must be defined using :code:`` tag. +Discriminator element requires :code:`` as mandatory attribute. + +Union types also require at least one case child defined using the :code:`` tag. +Each case child requires at least one label child using the :code:`` tag. +:code:`value` attribute is mandatory and defines the label value. +Several labels might be defined using several :code:`` elements. +Each case child must have exclusively one union member defined. + +Union members are defined using the :code:`` tag with mandatory attributes :code:`name` and :code:`type`. +Depending on the member type, some other mandatory and/or optional attributes might be necessary or available. +Non-primitive types must define the :code:`type` attribute as :code:`nonBasic` and include the :code:`nonBasicTypeName` +attribute with the name of the member type. +At least one union member must be defined for the union type to be consistent. + +.. note:: + + Currently, XML Types profiles does not support setting the member ID or marking a member as key. + +Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the union types. + +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_UNION<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_UNION + :end-before: //!-- + +.. _xmldynamictypes_bitset: + +Bitset Types +"""""""""""" + +Bitset types are defined using the :code:`` tag with mandatory attribute :code:`name`. +Bitset inheritance may be configured setting optional attribute :code:`baseType`. +At least one bitfield child must be defined using :code:`bitfield` tag. + +Bitfield elements require mandatory attribute :code:`bit_bound` with the number of bits managed by the bitfield (maximum +64 bits). +Optionally, attributes :code:`name` and :code:`type` might be defined. +An anonymous bitfield (attribute :code:`name` not set) is not accessible and serves as padding between named bitfields. +The :code:`type` attribute can ease bitfield management explicitly setting an integer type that handles the bitfield. + +Please, refer to :ref:`xtypes_supportedtypes_bitset` for more information about the bitset types. + +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITSET<--> + :end-before: <--> + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_BITSET + :end-before: //!-- .. _Usage: -Loading dynamic types in a *Fast DDS* application -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Loading XML Types profile in *Fast DDS* application +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -In the *Fast DDS* application that will make use of the *XML Types*, the XML files that -define the types must be loaded before trying to instantiate |DynamicPubSubType| objects of these types. +*Fast DDS* application can use types defined in XML configuration files once those files have been loaded into the +|DomainParticipantFactory-api| using |DomainParticipantFactory::load_XML_profiles_file-api|. +Types might be retrieved using |DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name-api|. +After getting the DynamicType, objects of |DynamicPubSubType-api| class might be instantiated and used to write/read +data. .. literalinclude:: /../code/DDSCodeTester.cpp :language: c++ :start-after: //XML-USAGE :end-before: //!-- :dedent: 8 - diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst new file mode 100644 index 000000000..9ae697942 --- /dev/null +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -0,0 +1,81 @@ +.. include:: ../../03-exports/aliases-api.include + +.. _xtypes_discovery_matching: + +Remote Data Types Discovery +=========================== + +.. _DDS-XTypes specification: https://www.omg.org/spec/DDS-XTypes/1.3 + +`DDS-XTypes specification`_ defines an internal mechanism to discover the remote data types at runtime and match +depending on the extensible types compatibility rules configured using the :ref:`typeconsistencyenforcementqospolicy`. + +.. note:: + + *eProsima Fast DDS* does not support XTypes compatibility check yet. + +The remote data type discovery mechanism is based on the exchange of the data type information optimized in order to +reduce the required bandwidth. +On the one hand, :code:`TypeInformation` structure defined in the IDL below (extracted from Annex B of the +`DDS-XTypes specification`_), is used to communicate the Topic Data Type and its dependencies. + +.. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--TYPEINFORMATION + :end-before: //!-- + +:code:`TypeInformation` includes the :code:`TypeIdentifier`, the data type information hashed which identifies almost +univocally the data type. +The data type information is contained in the :code:`TypeObject` union: + +.. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--TYPEOBJECT + :end-before: //!-- + +The :code:`CompleteTypeObject` includes the data type full description. +On the other hand, :code:`MinimalTypeObject` only includes the minimum required information in order to check type +compatibility. + +.. important:: + + Current TypeObject representation implementation does not support forward declarations or recursive data types + defined using the :code:`@external` annotation. + Please, remember to disable TypeObject generation code using :code:`-no-typeobjectsupport` option when generating + the code using Fast DDS-Gen. + +Prerequisites +------------- + +The remote data type discovery feature only works if some requisites are met: + +1. The local data types must be registered into the |ITypeObjectRegistry-api|. + The types are automatically registered when calling |DomainParticipant::register_type-api| / + |TypeSupport::register_type-api| if the code required for registration has been generated using + :ref:`eProsima Fast DDS-Gen`. + Fast DDS-Gen generates the required files (*TypeObjectSupport.cxx/.hpp*) by default. + + .. note:: + + :code:`-no-typeobjectsupport` option disables the generation of these files and effectively disables the + discovery of remote types. + + .. note:: + + Currently there is no support to register the TypeObject when the data type is defined using the + :ref:`xtypes_language_binding`. + Consequently, local types defined using the dynamic language binding API, are not going to be discovered by remote + DomainParticipants. + +2. :code:`TypeInformation` should be received with the DomainParticipant's endpoint discovery information. + A DomainParticipant that does not inform about its :code:`TypeInformation` would not trigger the remote data type + discovery mechanism. + +If the prerequisites are not met, endpoint matching relies on type name and topic name in order to match the discovered +endpoints. + +Remote types discovery example +------------------------------ + +Please, refer to :ref:`use-case-remote-type-discovery-and-matching` for more information about how to leverage this +feature. diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst new file mode 100644 index 000000000..2ea446579 --- /dev/null +++ b/docs/fastdds/xtypes/language_binding.rst @@ -0,0 +1,1010 @@ +.. include:: ../../03-exports/aliases.include +.. include:: ../../03-exports/aliases-api.include +.. include:: ../../03-exports/roles.include + +.. _xtypes_language_binding: + +Dynamic Language Binding +======================== + +The Dynamic Language Binding API allows to define data types at runtime instead of having the types predefined as it is +required by the Plain Language Binding. +This API includes both the type definition and, the getters and setters required to use the defined types. +Type definition can also be done using a XML configuration file as explained in :ref:`xmldynamictypes` section. + +This section presents first the Dynamic Language Binding API, and then the supported types and specific examples +defining and using those types. + +.. _xtypes_interfaces: + +Dynamic Language Binding Interfaces +----------------------------------- + +This section briefly presents the Dynamic Language Binding API. +For more information, please refer both to the `DDS-XTypes specification `__ +and the :ref:`API reference`. + +TypeDescriptor +^^^^^^^^^^^^^^ + +|TypeDescriptor-api| is in charge of describing the state of a type. +Objects of this interface have value semantics allowing the TypeDescriptor data to be deeply copied and compared. + +AnnotationDescriptor +^^^^^^^^^^^^^^^^^^^^ + +|AnnotationDescriptor-api| is in charge of describing the user-defined applied annotation to a specific element. +Objects of this interface have value semantics allowing the AnnotationDescriptor data to be deeply copied and compared. + +MemberDescriptor +^^^^^^^^^^^^^^^^ + +|MemberDescriptor-api| is in charge of describing the state of a specific member of a type. +Objects of this interface have value semantics allowing the MemberDescriptor data to be deeply copied and compared. + +VerbatimTextDescriptor +^^^^^^^^^^^^^^^^^^^^^^ + +|VerbatimTextDescriptor-api| is in charge of describing the :code:`@verbatim` builtin annotation application. +Objects of this interface have value semantics allowing the VerbatimTextDescriptor data to be deeply copied and +compared. + +DynamicTypeBuilderFactory +^^^^^^^^^^^^^^^^^^^^^^^^^ + +The |DynamicTypeBuilderFactory-api| serves as a singleton which instance is responsible for both creating and deleting +|DynamicTypeBuilder-api| objects. +This class provides the generic |DynamicTypeBuilderFactory::create_type| API, and also specific APIs to define other +basic types such as strings, sequences, etc. +More information can be found in :ref:`xtypes_supportedtypes` section. + +DynamicType +^^^^^^^^^^^ + +|DynamicType-api| objects represents a specific type definition. +Once the DynamicType has been built, it cannot be modified. +Objects of this interface have reference semantics, so the API receives a nil-reference which is then returned pointing +to the correct DynamicType address. + +DynamicTypeMember +^^^^^^^^^^^^^^^^^ + +|DynamicTypeMember-api| represents a data member of a DynamicType. +Objects of this interface have reference semantics, so the API receives a nil-reference which is then returned pointing +to the correct DynamicTypeMember address. + +DynamicTypeBuilder +^^^^^^^^^^^^^^^^^^ + +|DynamicTypeBuilder-api| interface allows the instantiation of concrete DynamicType objects and serves as a transitional +state for configuring the DynamicType before its creation. +Upon definition, DynamicTypeBuilderFactory leverages the information contained in the builder to create +the DynamicType. +|DynamicTypeBuilder::build| allows for creating the fully constructed DynamicType. +Builders remain reusable after DynamicType creation, ensuring changes to the builder do not affect previously +created types. + +DynamicDataFactory +^^^^^^^^^^^^^^^^^^ + +|DynamicDataFactory-api| serves as a singleton which instance is responsible for both creating and deleting +|DynamicData-api| objects from a given DynamicType instance. + +DynamicData +^^^^^^^^^^^ + +|DynamicData-api| represents a data instance of a DynamicType, providing functionalities to access +and modify data values. +Each DynamicData object corresponds to an object of the type represented by its DynamicType. +Offering reflective getters and setters, DynamicData enables manipulation of individual data samples. + +.. _xtypes_supportedtypes: + +Supported Types +--------------- + +This section describes the supported Type System including examples of how to instantiate those specific types using the +Dynamic Language Binding API and the XML configuration file. +The C++ examples also include instantiating the corresponding DynamicData sample, and setting and reading a value. + +.. _xtypes_supportedtypes_primitive: + +Primitive Types +^^^^^^^^^^^^^^^ + +Primitive types are self-describing and can be created without configuration parameters. +The |DynamicTypeBuilderFactory-api| interface exposes the method |DynamicTypeBuilderFactory::get_primitive_type| +to allow users to directly get the corresponding primitive DynamicType. +The |DynamicData-api| class provides specific getters and setters for each primitive data type. + +The following table shows the supported primitive types and their corresponding :code:`TypeKind`. +The :code:`TypeKind` is used to query the DynamicTypeBuilderFactory for the specific primitive DynamicType. + +.. list-table:: + :header-rows: 1 + :align: left + + * - C++ Type + - TypeKind + * - :code:`bool` + - :code:`TK_BOOLEAN` + * - :code:`char` + - :code:`TK_CHAR8` + * - :code:`wchar_t` + - :code:`TK_CHAR16` + * - :code:`uint8_t` + - :code:`TK_BYTE` / :code:`TK_UINT8` + * - :code:`int8_t` + - :code:`TK_INT8` + * - :code:`int16_t` + - :code:`TK_INT16` + * - :code:`uint16_t` + - :code:`TK_UINT16` + * - :code:`int32_t` + - :code:`TK_INT32` + * - :code:`uint32_t` + - :code:`TK_UINT32` + * - :code:`int64_t` + - :code:`TK_INT64` + * - :code:`uint64_t` + - :code:`TK_UINT64` + * - :code:`float` + - :code:`TK_FLOAT32` + * - :code:`double` + - :code:`TK_FLOAT64` + * - :code:`long double` + - :code:`TK_FLOAT128` + +The example below shows how to create an structure with primitive members. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_PRIMITIVES + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_PRIMITIVES<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_PRIMITIVES + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, +please refer to :ref:`XML Primitive Types `. + +Type promotions +""""""""""""""" + +The Dynamic Language Binding also supports type promotion, enabling implicit promotion of types during both :func:`get` +and :func:`set` operations. +This means that a smaller type can be implicitly promoted to a larger type, but not the other way around. + +The following promotions are supported: + +.. list-table:: + :header-rows: 1 + :align: left + + * - TypeKind + - Allowed promotions + * - :code:`TK_INT8` + - :code:`TK_INT16`, :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_INT16` + - :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_INT32` + - :code:`TK_INT64`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_INT64` + - :code:`TK_FLOAT128` + * - :code:`TK_UINT8` + - :code:`TK_INT16`, :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_UINT16`, :code:`TK_UINT32`, :code:`TK_UINT64`, + :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_UINT16` + - :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_UINT32`, :code:`TK_UINT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, + :code:`TK_FLOAT128` + * - :code:`TK_UINT32` + - :code:`TK_INT64`, :code:`TK_UINT64`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_UINT64` + - :code:`TK_FLOAT128` + * - :code:`TK_FLOAT32` + - :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_FLOAT64` + - :code:`TK_FLOAT128` + * - :code:`TK_FLOAT128` + - (none) + * - :code:`TK_CHAR8` + - :code:`TK_CHAR16`, :code:`TK_INT16`, :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, + :code:`TK_FLOAT128` + * - :code:`TK_CHAR16` + - :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_BYTE` + - (any) + * - :code:`TK_BOOLEAN` + - :code:`TK_INT8`, :code:`TK_INT16`, :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_UINT8`, :code:`TK_UINT16`, + :code:`TK_UINT32`, :code:`TK_UINT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + + +.. _xtypes_supportedtypes_string: + +String Types +^^^^^^^^^^^^ + +String types are one-dimensional collections of characters (:code:`TK_CHAR8` or :code:`TK_CHAR16`. +The latest are also known as wide strings or :code:`wstring`). +The :code:`TypeKinds` used to identify string types are :code:`TK_STRING8` and :code:`TK_STRING16`. +The string may be bounded, setting a maximum length, or unbounded. +This is configured using |TypeDescriptor-api| :code:`bound` property. + +|DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and +|DynamicTypeBuilderFactory::create_wstring_type| that eases string creation providing the corresponding maximum length +parameter (:code:`LENGTH_UNLIMITED` is used for unbounded strings). + +|DynamicData-api| class provides also with specific getters and setters: |DynamicData::get_string_value|, +|DynamicData::get_wstring_value|, |DynamicData::set_string_value|, and |DynamicData::set_wstring_value|. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_STRINGS + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRINGS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_STRINGS + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML String Types `. + + +.. _xtypes_supportedtypes_enumeration: + +Enumeration Types +^^^^^^^^^^^^^^^^^ + +An enumeration contains a set of supported values (enumeration literals) and a selected value among those supported. +The :code:`TypeKind` used to identify enumeration types is :code:`TK_ENUM`. + +The enumeration literals must be configured using the |DynamicTypeBuilder-api| by calling the +|DynamicTypeBuilder::add_member| function for the respective supported values. +The |MemberDescriptor-api| passed to the previous function must determine the enumeration literal name by using +:code:`name` property. +The underlying primitive type related to the enumeration is configured using |MemberDescriptor-api| :code:`type` +property. +This primitive type is determined when adding the first enumeration literal. +For the enumeration type to be consistent, the remaining enumeration literals must be of the same primitive type. +Additionally, the enumeration literal value might be set using |MemberDescriptor-api| :code:`default_value` property. +The behavior is the same as setting the :code:`@value` :ref:`builtin annotation`. + +.. note:: + + Currently, Fast DDS-Gen does not support :code:`@value` builtin annotation. + +As the enumeration type is basically a primitive type which might take only some specific values defined with the +enumeration literals, the corresponding DynamicData getters and setters are the ones corresponding to the underlying +primitive type (and any other method promotable to that specific primitive type). + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_ENUM + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ENUM<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_ENUM + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Enumeration Types `. + + +.. _xtypes_supportedtypes_bitmask: + +Bitmask Types +^^^^^^^^^^^^^ + +Bitmask types are a collection of boolean flags (bitflags) that can be set individually. +The :code:`TypeKind` used to identify bitmask types is :code:`TK_BITMASK`. +The bitmasks bound, maximum number of bits, must be set using the |TypeDescriptor-api| :code:`bound` property. +The maximum bound allowed is 64 bits. + +The bitflags must be configured using the |DynamicTypeBuilder-api| by calling the |DynamicTypeBuilder::add_member| +function. +Each bitflag is described using a |MemberDescriptor-api| defining the bitflag name using the :code:`name` property. +The underlying primitive type related to bitflags must be of kind :code:`TK_BOOLEAN` and must be set in +|MemberDescriptor-api| :code:`type` property. +The |MemberDescriptor-api| :code:`id` property might be used to indicate the bitflag position within the bitmask. +This behavior is the same as setting the :code:`@position` :ref:`builtin annotation`. +If the position is not specified, sequential order is followed. + +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to +facilitate the creation of bitmask types. + +Bitmask types can be manipulated either using the |DynamicData::get_boolean_value|/|DynamicData::set_boolean_value| in +order to set a specific bitflag, or by using the unsigned integer setter/getter corresponding to the bitmask bound. +In this latest case, only bitflags are going to be set (bits not named are always unset). + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_BITMASK + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITMASK<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_BITMASK + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Bitmask Types`. + + +.. _xtypes_supportedtypes_alias: + +Alias Types +^^^^^^^^^^^ + +Alias types provide an alternative name to an already existing type. +The :code:`TypeKind` used to identify aliases is :code:`TK_ALIAS`. +Besides defining the alias name, the underlying type must be set using |TypeDescriptor-api| :code:`base_type` property. +Alias recursion is supported by defining another alias type as the base type. + +Once the |DynamicData-api| is created, information can be accessed as if working with the base type. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_TYPEDEF + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_TYPEDEF<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_TYPEDEF + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Alias Types`. + +.. _xtypes_supportedtypes_sequence: + +Sequence types +^^^^^^^^^^^^^^ + +Sequence types are one-dimensional collections of any type. +The :code:`TypeKind` used to identify sequences is :code:`TK_SEQUENCE`. +|TypeDescriptor-api| :code:`element_type` property must be set with the collection's type. +Additionally, :code:`bound` property must also be configured with the sequence's maximum length, or +:code:`LENGTH_UNLIMITED` in case of unbounded sequences. + +|DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to +facilitate the creation of this type. +This API requires the type stored in the collection and the collection's bound, using :code:`LENGTH_UNLIMITED` in case +of unbounded sequences. + +|DynamicData-api| class provides specific :func:`get_values` and :func:`set_values` functions for each primitive +type, allowing users to easily work with sequences of primitive types. +Primitive type promotion is also applicable for these methods. +For sequences of more complex types, please refer to :ref:`xtypes_complextypes`. + +If a specific range of values within the sequence are to be modified, passing the starting index to +:func:`get_values` / :func:`set_values` would only manage data from that element forward until the length of the given +input. +Specific collection's element can be also be modified using the :func:`get_value` / :func:`set_value` passing the index +of the element to be modified. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_SEQUENCES + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_SEQUENCES<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_SEQUENCES + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Sequence Types `. + +.. _xtypes_supportedtypes_array: + +Array types +^^^^^^^^^^^ + +Array types are multi-dimensional collections of any type. +The :code:`TypeKind` used to identify arrays is :code:`TK_ARRAY`. +|TypeDescriptor-api| :code:`element_type` property must be set with the collection's type. +Additionally, :code:`bound` property must be configured with the sequence containing the size of each dimension. +Bound sequence must have at least one dimension and it is not allowed for any dimension to have size :code:`0`. + +|DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to +facilitate the creation of this type. +This API requires the type stored in the collection and the sequence with the collection's dimensions. + +|DynamicData-api| class provides specific :func:`get_values` and :func:`set_values` functions for each primitive +type, allowing users to easily work with arrays of primitives types. +For arrays of more complex types, please refer to :ref:`xtypes_complextypes`. + +.. note:: + + Multi-dimensional arrays *flatten* every dimension into a single-dimension array. + +Primitive type promotion is also applicable for these methods. + +If a specific range of values within the array are to be modified, passing the starting index to +:func:`get_values` / :func:`set_values` would only manage data from that element forward until the length of the given +input. +Specific collection's element can be also be modified using the :func:`get_value` / :func:`set_value` passing the index +of the element to be modified. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_ARRAYS + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ARRAYS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_ARRAYS + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Array Types`. + +.. _xtypes_supportedtypes_map: + +Map Types +^^^^^^^^^ + +Map types are a collection of key/value pair types. +Access to the value element is done through the key which is unique within the map type. +The :code:`TypeKind` used to identify maps is :code:`TK_MAP`. +|TypeDescriptor-api| :code:`element_type` property must be set with the map value type. +|TypeDescriptor-api| :code:`key_type` property must be set with the map key type. +Allowed key types are signed and unsigned integer types and string types. + +.. note:: + + Currently, wide string keys are not supported as map keys. + +Additionally, :code:`bound` property must also be configured with the map's maximum length, or :code:`LENGTH_UNLIMITED` +in case of unbounded maps. + +|DynamicTypeBuilderFactory-api| exposes the |DynamicTypeBuilderFactory::create_map_type| function to +facilitate the creation of this type. +This API requires the type of both the key and the value stored in the collection, and the collection's bound, using +:code:`LENGTH_UNLIMITED` in case of unbounded maps. + +Manipulating map types data is more complex. +First the :code:`MemberId` corresponding to a specific :code:`key` must be retrieved using +|DynamicData::get_member_id_by_name| API. +This API either returns the :code:`MemberId` corresponding to the existing :code:`key` or, if the :code:`key` does not +exist yet, it creates the :code:`key` and returns the :code:`memberId` associated to the just created :code:`key`. +In order to call this method, the correct :code:`string` representation of the key value must be passed. +The map value can now be set using the API corresponding to the map value type. +For complex map values, please refer to :ref:`xtypes_complextypes`. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_MAPS + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_MAPS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_MAPS + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Map Types`. + +.. _xtypes_supportedtypes_structure: + +Structure Types +^^^^^^^^^^^^^^^ + +Structure types are an aggregation of members of different types. +The :code:`TypeKind` used to identify structures is :code:`TK_STRUCTURE`. +Structure types have single inheritance support, so a structure type might extend one other already defined structure. +The structure type which is extended should be configured in the |TypeDescriptor-api| :code:`base_type` property. +:ref:`Structure extensibility` might be configured using |TypeDescriptor-api| :code:`extensibility_kind` +property. + +.. note:: + + Currently, :code:`@nested` builtin annotation is not supported. + +Structure members must be configured using the |DynamicTypeBuilder-api| by calling the |DynamicTypeBuilder::add_member| +function with the corresponding |MemberDescriptor-api|. + +.. note:: + + Empty structures, with no members, are allowed. + +Member name is configured using |MemberDescriptor-api| :code:`name` property and the member type is set using +:code:`type` property. +Structure members might be keyed to create :ref:`topic instances` by setting the +|MemberDescriptor-api| :code:`is_key` property. +The behavior is the same as setting the :code:`@key` :ref:`builtin annotation`. +Additionally, |MemberDescriptor-api| :code:`default_value` property might be set to configure the member default value, +and |MemberDescriptor-api| :code:`id` property sets explicitly the member ID. +This behavior is the same as setting the :code:`@default` and :code:`@id` +:ref:`builtin annotations`. + +.. note:: + + Currently, Fast DDS-Gen does not support :code:`@default` builtin annotation. + +.. note:: + + Currently, Dynamic Language Binding API implementation does not support the following builtin annotations: + + * :code:`@optional` + * :code:`@must_understand` + * :code:`@external` + * :code:`@try_construct` + +Member data can be managed using the corresponding accessors for the underlying member type. +Member ID might be retrieved using |DynamicData::get_member_id_by_name| API. +For managing complex type members, please refer to :ref:`xtypes_complextypes`. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_STRUCT + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRUCT<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_STRUCT + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Structure Types`. + +.. _xtypes_supportedtypes_union: + +Union Types +^^^^^^^^^^^ + +Union types are a special type of structure type where only one member exists. +The :code:`TypeKind` used to identify unions is :code:`TK_UNION`. +Member selection is performed by setting another special member called discriminator. +The discriminator type must be defined using |TypeDescriptor-api| :code:`discriminator_type` property. +Supported discriminator :code:`TypeKind` are the following: + +* :code:`TK_BOOLEAN` +* :code:`TK_BYTE` +* :code:`TK_CHAR8` +* :code:`TK_CHAR16` +* :code:`TK_INT8` +* :code:`TK_UINT8` +* :code:`TK_INT16` +* :code:`TK_UINT16` +* :code:`TK_INT32` +* :code:`TK_UINT32` +* :code:`TK_INT64` +* :code:`TK_UINT64` +* :code:`TK_ENUM` +* :code:`TK_ALIAS` that resolves, directly or indirectly to one of the aforementioned types. + +:ref:`Union extensibility` might be configured using |TypeDescriptor-api| :code:`extensibility_kind` +property. + +.. note:: + + Currently, :code:`@nested` builtin annotation is not supported. + +Union members must be configured using the |DynamicTypeBuilder-api| by calling the |DynamicTypeBuilder::add_member| +function with the corresponding |MemberDescriptor-api|. +At least one union member must be added to the union type. +Union member name is configured using |MemberDescriptor-api| :code:`name` property and the member type is set using +:code:`type` property. +It is also mandatory to either set |MemberDescriptor-api| :code:`is_default_label` property or configure the +:code:`label` property. +This latest property indicates the discriminator values that select this specific member. +If no labels are configured, then the flag indicating the member to be the default one, must be set. +Only one union member must be configured as default. + +Additionally, |MemberDescriptor-api| :code:`default_value` property might be set to configure the member default value, +and |MemberDescriptor-api| :code:`id` property sets explicitly the member ID. +This behavior is the same as setting the :code:`@default` and :code:`@id` +:ref:`builtin annotations`. + +.. note:: + + Currently, Fast DDS-Gen does not support :code:`@default` builtin annotation. + +.. note:: + + Currently, Dynamic Language Binding API implementation does not support the following builtin annotations: + + * :code:`@optional` + * :code:`@must_understand` + * :code:`@external` + * :code:`@try_construct` + +Member data can be managed using the corresponding accessors for the underlying member type. +Setting a member automatically changes the discriminator value selecting the set member. +When reading a member, the discriminator must be selecting the member being read. +Member ID might be retrieved using |DynamicData::get_member_id_by_name| API. +For managing complex type members, please refer to :ref:`xtypes_complextypes`. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_UNION + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_UNION<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_UNION + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Union Types`. + +.. _xtypes_supportedtypes_bitset: + +Bitset Types +"""""""""""" + +Bitset types are an aggregation of bitfields. +The :code:`TypeKind` used to identify bitsets is :code:`TK_BITSET`. +:code:`bound` property contains the sequence with the bitfield's bitcount (number of bits). +In order to be consistent, the length of the :code:`bound` sequence must agree with the number of bitfields. +Bitset types have single inheritance support, so a bitset type might extend one other already defined bitset. +The bitset type which is extended should be configured in the |TypeDescriptor-api| :code:`base_type` property. + +Bitfields must be configured using the |DynamicTypeBuilder-api| by calling the |DynamicTypeBuilder::add_member| +function with the corresponding |MemberDescriptor-api|. +At least one bitfield is required for the bitset to be consistent. +Bitfield name is configured using |MemberDescriptor-api| :code:`name` property, and the bitfield initial bit position +is set using |MemberDescriptor-api| :code:`id` property. + +.. note:: + + For derived bitsets, the first bitfield initial position must be after the bits defined by the parent bitset type. + +A bitfield manages exclusively a set of bits, so no bitfield superposition is allowed. +Additionally, |MemberDescriptor-api| :code:`type` property might be set to configure an integer type to access bitfield +data. +If not set, the minimum unsigned integer type is used instead: + +.. list-table:: + :header-rows: 1 + :align: left + + * - Number of bits + - C++ holder type + * - :code:`1` + - :code:`bool` + * - :code:`2-8` + - :code:`uint8_t` + * - :code:`9-16` + - :code:`uint16_t` + * - :code:`17-32` + - :code:`uint32_t` + * - :code:`33-64` + - :code:`uint64_t` + +Each bitfield (or member) works like its primitive type with the only difference that the internal storage only +modifies the involved bits instead of the full primitive value. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_BITSET + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITSET<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_BITSET + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Bitset Types`. + +Annotations +^^^^^^^^^^^ + +Custom annotations +"""""""""""""""""" + +Both types and type members might be annotated using |DynamicTypeBuilder::apply_annotation| and +|DynamicTypeBuilder::apply_annotation_to_member| API respectively. + +Annotations are defined using an |AnnotationDescriptor-api| which provides two properties: :code:`type` and +:code:`value`. +The annotation type must be the DynamicType representing the annotation being applied. +The :code:`TypeKind` used to identify annotations is :code:`TK_ANNOTATION`. +The annotation name is set in |TypeDescriptor-api| :code:`name` property. + +The annotation type might have any number of parameters. +Annotation parameters must be configured using the |DynamicTypeBuilder-api| by calling the +|DynamicTypeBuilder::add_member| function with the corresponding |MemberDescriptor-api|. +Annotation parameters must define the annotation parameter name in |MemberDescriptor-api| :code:`name` property, +and the parameter type using :code:`type` property. +Only the following types can be used to define an annotation parameter: + +* `Primitive types`_ +* `String types`_ +* `Enumeration types`_ + +.. note:: + + Currently, wide string types are not supported as annotation parameters. + +Annotation parameter values are defined with |AnnotationDescriptor-api| :code:`value` property using +|AnnotationDescriptor::set_value-api|. +The annotation parameter name provided to the API must coincide with the one defined with the annotation type. +The annotation parameter value must be converted to its string representation. + +.. note:: + + Currently, custom annotations are not supported with :ref:`XML DynamicTypes `. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: omg-idl + :start-after: //!--IDL_CUSTOM_ANNOTATION + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_CUSTOM_ANNOTATION<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_CUSTOM_ANNOTATION + :end-before: //!-- + + +Builtin annotations +""""""""""""""""""" + +Beside the user-defined custom annotations, there are a number of builtin annotations that have already mentioned +throughout this section. + +The table below summarizes the builtin annotations that can be applied using the Dynamic Language Binding API. +Please, refer to :ref:`builtin annotations ` for the complete list and their behavior. + +.. list-table:: + :header-rows: 1 + :align: left + + * - Builtin annotation + - Dynamic Language Binding API + - Dynamic Language Binding support + - XML Dynamic Type profiles support + * - :code:`@appendable` + - |TypeDescriptor-api| :code:`extensibility_kind` property. + - ✅ + - ❌ + * - :code:`@bit_bound` + - |TypeDescriptor-api| :code:`bound` property. + - ✅ + - ✅❌ (`Enumeration types`_ not configurable). + * - :code:`@default` + - |MemberDescriptor-api| :code:`default_value` property. + - ✅ + - ❌ + * - :code:`default_literal` + - |MemberDescriptor-api| :code:`is_default_label` property. + - ✅ + - ❌ + * - :code:`@extensibility` + - |TypeDescriptor-api| :code:`extensibility_kind` property. + - ✅ + - ❌ + * - :code:`@external` + - |MemberDescriptor-api| :code:`is_shared` property. + - ❌ + - ❌ + * - :code:`@final` + - |TypeDescriptor-api| :code:`extensibility_kind` property. + - ✅ + - ❌ + * - :code:`@id` + - |MemberDescriptor-api| :code:`id` property. + - ✅ + - ❌ + * - :code:`@key` / :code:`@Key` + - |MemberDescriptor-api| :code:`is_key` property. + - ✅ + - ❌ + * - :code:`@mutable` + - |TypeDescriptor-api| :code:`extensibility_kind` property. + - ✅ + - ❌ + * - :code:`@nested` + - |TypeDescriptor-api| :code:`is_nested` property. + - ❌ + - ❌ + * - :code:`@optional` + - |MemberDescriptor-api| :code:`is_optional` property. + - ❌ + - ❌ + * - :code:`@position` + - |MemberDescriptor-api| :code:`id` property. + - ✅ + - ✅ + * - :code:`@try_construct` + - |MemberDescriptor-api| :code:`try_construct_kind` property. + - ❌ + - ❌ + * - :code:`@value` + - |MemberDescriptor-api| :code:`default_value` property. + - ✅ + - ✅ + * - :code:`@verbatim` + - |VerbatimTextDescriptor-api| + - ❌ + - ❌ + +To apply the :code:`@extensibility` annotation (and its shortcuts) the |TypeDescriptor-api| provides +:code:`extensibility_kind` property. + +:code:`@key` annotation is applied enabling |MemberDescriptor-api| :code:`is_key` property. + +.. _xtypes_complextypes: + +Managing Complex Types Data +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some |DynamicData-api| instances manage complex types that cannot be directly modified with the primitive getters and +setters. +Dynamic Language Binding provides two possible approaches for managing complex data types: + +1. |DynamicData::get_complex_value| and |DynamicData::set_complex_value|: This API allows to get/set generic DynamicData. + The main difference with the next approach is that this API performs always a copy. +2. |DynamicData::loan_value|: this API allows to loan a reference to a DynamicData to work with preventing the data copy. + |DynamicData::return_loaned_value| must be called to return the loan. + Calling |DynamicData::loan_value| for an already loaned value will fail. + +The following snippet includes an example of managing complex data using the same structure as the one defined in +`Structure types`_: + +.. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_DATA + :end-before: //!-- diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst new file mode 100644 index 000000000..da79d8c53 --- /dev/null +++ b/docs/fastdds/xtypes/xtypes.rst @@ -0,0 +1,30 @@ +.. _dynamic-types: + +XTypes +====== + +.. _Extensible and Dynamic Topic Types for DDS: https://www.omg.org/spec/DDS-XTypes/1.3 + +*eProsima Fast DDS* supports the OMG `Extensible and Dynamic Topic Types for DDS`_ specification (also known as XTypes). +This specification defines the following concepts: + +* DDS supported type system, including the concept of extensible types that might evolve in time. + +.. note:: + + This section also defines the type compatibility rules among evolved types which is still unsupported in Fast DDS. + +* Type representation, including :ref:`IDL` and :ref:`TypeObject` + representations. +* Data representation over the wire. +* Language binding, defining both a plain and a dynamic language binding. + :ref:`eProsima Fast DDS-Gen` generates the plain language binding given an IDL type representation. + :ref:`xtypes_language_binding` section explains the required API to define and set/read the data types. +* DDS builtin mechanism to automatically discover remote data types. + More information in :ref:`xtypes_discovery_matching` section. + +.. toctree:: + :maxdepth: 3 + + /fastdds/xtypes/discovery_matching.rst + /fastdds/xtypes/language_binding.rst diff --git a/docs/fastddsgen/dataTypes/dataTypes.rst b/docs/fastddsgen/dataTypes/dataTypes.rst index 5b8aca60f..0c011b5ce 100644 --- a/docs/fastddsgen/dataTypes/dataTypes.rst +++ b/docs/fastddsgen/dataTypes/dataTypes.rst @@ -1,3 +1,4 @@ +.. include:: ../../03-exports/aliases-api.include .. include:: ../../03-exports/roles.include .. _fastddsgen_idl_datatypes: @@ -452,8 +453,7 @@ Annotations -------------- The application allows the user to define and use their own annotations as defined in the -`OMG IDL 4.2 specification `_. -User annotations will be passed to TypeObject generated code if the ``-typeobject`` argument was used. +`OMG IDL specification `_. .. code-block:: omg-idl @@ -463,73 +463,122 @@ User annotations will be passed to TypeObject generated code if the ``-typeobjec string name; }; -Additionally, the following standard annotations are builtin (recognized and passed to TypeObject when unimplemented). - -+-------------------------+--------------------------------------------------------------------------------------------+ -| Annotation | Implemented behavior | -+=========================+============================================================================================+ -| @id | [Unimplemented] Assign a 32-bit integer identifier to an element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @autoid | [Unimplemented] Automatically allocate identifiers to the elements. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @optional | Setting an element as optional. More info in `Optional Members`_. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @extensibility | Applied to any element which is constructed. Allow specifying how the |br| | -| | element is allowed to evolve. More info in Extensibility_. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @final | Shortcut for `@extensibility(FINAL)` | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @appendable | Shortcut for `@extensibility(APPENDABLE)` | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @mutable | Shortcut for `@extensibility(MUTABLE)` | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @position | Setting a position to an element or group of elements. Used by bitmasks_. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @value | [Unimplemented] Allow setting a constant value to any element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @key | Alias for eProsima's @Key annotation. Indicate that a data member is part of the key |br| | -| | (please refer to :ref:`dds_layer_topic_instances` for more information). | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @must_understand | [Unimplemented] Indicate that the data member must be understood by any application |br| | -| | making use of that piece of data. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @default_literal | [Unimplemented] Allow selecting one member as the default within a collection. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @default | Allow specifying the default value of the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @range | [Unimplemented] Allow specifying a range of allowed values for the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @min | [Unimplemented] Allow specifying a minimum value for the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @max | [Unimplemented] Allow specifying a maximum value for the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @unit | [Unimplemented] Allow specifying a unit of measurement for the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @bit_bound | Allow setting a size to a bitmasks_. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @external | [Unimplemented] Force the annotated element to be placed in a dedicated data space. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @nested | [Unimplemented] Allow indicating that the objects from the type under annotation will |br| | -| | always be nested within another one. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @verbatim | [Unimplemented] Allow injecting some user-provided information into what the compiler |br| | -| | will generate. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @service | [Unimplemented] Allow indicating that an interface is to be treated as a service. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @oneway | [Unimplemented] Allow indicating that an operation is one way only, meaning that |br| | -| | related information flow will go from client to server but not back. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @ami | [Unimplemented] Allow indicating that an interface or an operation is to be made |br| | -| | callable asynchronously. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @non_serialized | The annotated member will be omitted from serialization. | -+-------------------------+--------------------------------------------------------------------------------------------+ - -Most unimplemented annotations are related to Extended Types. +.. _builtin_annotations: + +Additionally, the following standard annotations are defined by the specification and considered builtin (these +annotations might be applied without the need of defining them). + +.. list-table:: + :header-rows: 1 + :align: left + + * - Builtin Annotation + - Behavior + - Supported + * - :code:`@ami` + - Asynchronous interface or operation. + - ❌ + * - :code:`@appendable` + - Shortcut for :code:`@extensibility(APPENDABLE)`. + - ✅ + * - :code:`@autoid` + - Member ID algorithm configuration if there is no member ID explicitly set using :code:`@id` annotation. |br| + Possible values are :code:`SEQUENTIAL` (member ID is assigned sequentially. Default value) or |br| + :code:`HASH` (member ID is calculated with an algorithm involving hashing the member name). |br| + This annotation might be defined in module, structure or union declarations. + - ✅ + * - :code:`@bit_bound` + - Set number of bits on `bitmasks`_ and `enumerations`_ underlying primitive type. |br| + Currently, :code:`@bit_bound` can only be applied to bitmask types. + - ✅❌ + * - :code:`@data_representation` + - Specify the |DataRepresentationId-api| required for a specific type. + - ❌ + * - :code:`@default` + - Set constant default value to a member. + - ❌ + * - :code:`@default_literal` + - Mark an `enumerations`_ literal as default. + - ❌ + * - :code:`@default_nested` + - Use in module declaration to mark as :code:`@nested` every element defined within the module. + - ❌ + * - :code:`@extensibility` + - Applicable to any constructed element. + Specify how the element is allowed to evolve. |br| + Please, refer to Extensibility_ for more information. + - ✅ + * - :code:`@external` + - Member is stored in external storage. + - ✅ + * - :code:`@final` + - Shortcut for :code:`@extensibility(FINAL)` + - ✅ + * - :code:`@hashid` + - Calculate the member ID with the string provided or, if empty, with the member name. + - ✅ + * - :code:`@id` + - Assign member ID to a structure or union member. + - ✅ + * - :code:`@ignore_literal_names` + - When checking evolved type compatibility, take or not into account member names. + - ❌ + * - :code:`@key` + - Mark a structure member as part of the key. :code:`@Key` is also supported. |br| + Please, refer to :ref:`dds_layer_topic_instances` for more information. + - ✅ + * - :code:`@max` + - Set a maximum constant value to the member. + - ❌ + * - :code:`@min` + - Set a minimum constant value to the member. + - ❌ + * - :code:`@must_understand` + - Mark a structure member as essential for the structure cohesion. + - ❌ + * - :code:`@mutable` + - Shortcut for :code:`@extensibility(MUTABLE)` + - ✅ + * - :code:`@nested` + - Type is always used within another one. + - ❌ + * - :code:`@non_serialized` + - Omit member during serialization. + - ❌ + * - :code:`@oneway` + - One-way operation, flowing the information only on one direction. + - ❌ + * - :code:`@optional` + - Configure a structure member as optional. Please refer to `Optional Members`_ for more information. + - ✅ + * - :code:`@position` + - Set a bitflag position in `bitmasks`_. + - ✅ + * - :code:`@range` + - Set a range of allowed values for the member. + - ❌ + * - :code:`@service` + - Interface is to be treated as a service. + - ❌ + * - :code:`@topic` + - Structure or union is meant to be used as Topic Data Type. + - ❌ + * - :code:`@try_construct` + - When checking evolved type compatibility, configure the behavior for |br| + collection/aggregated types construction and what to do in case of failure. + - ❌ + * - :code:`@unit` + - Specify a unit of measurement for the member. + - ❌ + * - :code:`@value` + - Set constant value to `enumerations`_ literal. + - ❌ + * - :code:`@verbatim` + - Add comment or text to the element. + - ❌ Forward declaration ---------------------- +------------------- *Fast DDS-Gen* supports forward declarations. This allows declaring inter-dependant structures, unions, etc. diff --git a/docs/fastddsgen/pubsub_app/includes/workspace.rst b/docs/fastddsgen/pubsub_app/includes/workspace.rst index e74810232..4a263922e 100644 --- a/docs/fastddsgen/pubsub_app/includes/workspace.rst +++ b/docs/fastddsgen/pubsub_app/includes/workspace.rst @@ -18,8 +18,7 @@ The file ``build/HelloWorld`` is the generated *Fast DDS* application. │   ├── libHelloWorld_lib.a │   └── Makefile ├── CMakeLists.txt - ├── HelloWorld.cxx - ├── HelloWorld.h + ├── HelloWorld.hpp ├── HelloWorld.idl ├── HelloWorldCdrAux.hpp ├── HelloWorldCdrAux.ipp @@ -29,7 +28,9 @@ The file ``build/HelloWorld`` is the generated *Fast DDS* application. ├── HelloWorldPubSubTypes.cxx ├── HelloWorldPubSubTypes.h ├── HelloWorldSubscriber.cxx - └── HelloWorldSubscriber.h + ├── HelloWorldSubscriber.h + ├── HelloWorldTypeObjecSupport.cxx + └── HelloWorldTypeObjecSupport.h Execute the following command to create the directory in which the files generated by *Fast DDS-Gen* will be saved. diff --git a/docs/fastddsgen/usage/usage.rst b/docs/fastddsgen/usage/usage.rst index 1ca0e4fc1..6145f509a 100644 --- a/docs/fastddsgen/usage/usage.rst +++ b/docs/fastddsgen/usage/usage.rst @@ -45,7 +45,7 @@ The expected argument list of the application is: fastddsgen [] [ ...] -Where the option choices are: +Where the options are: .. list-table:: :header-rows: 1 @@ -53,18 +53,13 @@ Where the option choices are: * - Option - Description - * - -cdr - - Sets the Fast CDR version used to generate types source code. |br| - Values: |br| - - v1. Generate source code for Fast CDR v1. |br| - - v2 (default). Generate source code for Fast CDR v2. |br| - - both. Generate source code for both Fast CDR v1 and Fast CDR v2. * - -cs - - Enables Case Sensitivity + - Enables case sensitivity in variable names. * - -d - - Sets the output directory where the generated files are created. - * - -flat-output-dir - - Ignore input files relative paths and place all generated files in the specified output directory. + - Sets the output directory for the generated files. + * - -default-container-prealloc-size + - Sets the default preallocated size for unbounded collections (sequences and maps) |br| + Default value: 0 (empty collection). * - -default_extensibility |br| -de - Sets the default extensibility for types without the @extensibility annotation. |br| @@ -81,10 +76,19 @@ Where the option choices are: This option expects the location of the template and the location of the file where source code output will be stored. |br| A custom template example can be found in this `link `_ + * - -flat-output-dir + - Ignores input files relative paths and place all generated files in the specified output directory. * - -help - Shows the help information * - -I - - Add directory to preprocessor include paths. + - Adds directory to preprocessor include paths. + * - -no-typesupport + - Avoids generating the type support files. + * - -no-typeobjectsupport + - Avoids generating the TypeObject support specific files. |br| + Enabled automatically if -no-typesupport argument is used. + * - -no-dependencies + - Avoids processing the dependent IDL files. * - -ppDisable - Disables the preprocessor. * - -ppPath @@ -92,17 +96,13 @@ Where the option choices are: * - -python - Generates source code and a CMake solution to compile a library containing the data types |br| Python bindings required to run a *Fast DDS* Python-based application. - This option is |br| - incompatible with the `-example` and `-typeobject` ones. + This option is incompatible with `-example`. * - -replace - Replaces the generated source code files even if they exist. * - -t - Sets a specific directory as a temporary directory. - * - -typeobject - - Generates `TypeObject` files for the IDL provided and modifies MyType constructor to |br| - register the TypeObject representation into the factory. * - -typeros2 - - Generates type naming compatible with ROS 2 + - Generates type naming compatible with ROS 2. * - -version - Shows the current version of eProsima *Fast DDS-Gen*. diff --git a/docs/index.rst b/docs/index.rst index e31ab6f71..6d7dc2843 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -49,7 +49,7 @@ /fastdds/env_vars/env_vars /fastdds/property_policies/property_policies /fastdds/statistics/statistics - /fastdds/dynamic_types/dynamic_types + /fastdds/xtypes/xtypes /fastdds/use_cases/use_cases /fastdds/ros2/ros2 /fastdds/troubleshooting/troubleshooting diff --git a/docs/notes/previous_versions/v2.11.0.rst b/docs/notes/previous_versions/v2.11.0.rst index 53eb8c78a..70132d34a 100644 --- a/docs/notes/previous_versions/v2.11.0.rst +++ b/docs/notes/previous_versions/v2.11.0.rst @@ -6,7 +6,7 @@ This release includes the following **features**: 1. :ref:`Ignore every local endpoint within the DomainParticipant preventing local matching `. 2. Extend DynamicDataHelper API providing a ``print`` overload with ``std::ostream`` as parameter. -3. :ref:`typelookup_config`. +3. TypeLookup Service settings. 4. Static Discovery XSD Schema. This release includes the following **improvements**: diff --git a/docs/notes/previous_versions/v2.4.2.rst b/docs/notes/previous_versions/v2.4.2.rst index 33198745a..0a09f8a88 100644 --- a/docs/notes/previous_versions/v2.4.2.rst +++ b/docs/notes/previous_versions/v2.4.2.rst @@ -6,7 +6,7 @@ This release includes the following **improvements**: 1. Enable memory protection on :ref:`DataSharing ` readers 2. Add const overload of ``DataReader::guid()`` 3. Set recommended statistics :ref:`DataReaderQos ` to ``PREALLOCATED_WITH_REALLOC`` -4. Allow fully qualified name on :ref:`MemberDescriptor ` +4. Allow fully qualified name on MemberDescriptor This release includes the following bugfixes: diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 142df4750..5da12fef3 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -31,6 +31,7 @@ backports benchmarking bitfield Bitfields +bitflags bitmask bitmasks bitset @@ -144,6 +145,7 @@ ifaddrs ifreq ignoreParticipantFlags initializations +instantiation interoperability interprocess intra @@ -208,6 +210,7 @@ postfixed ppDisable ppPath pre +prealloc preallocate preallocated preallocates @@ -270,10 +273,12 @@ Topologies txqueuelen typeobject TypeObject +typeobjectsupport typeros typeros2 typesupport uint +UInt uncheck unicast unidimensional