From b0e29870b3046d93f9c83bdfd3375d1a57600f52 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Fri, 2 Feb 2024 19:30:30 +0100 Subject: [PATCH 01/23] Refs #20359: Updates for xtypes1.3. Removed TypeLookupSettings. Removed auto_fill_typeonject. Renamede discovery methods. Added typelookup_service_threads. Signed-off-by: adriancampo --- code/DDSCodeTester.cpp | 253 +++++++----------- .../src/HelloWorldSubscriber.cpp | 16 +- code/XMLTester.xml | 24 +- code/XMLTesterExample.xml | 11 +- .../listeners_inheritance_diagram.svg | 2 +- docs/03-exports/aliases-api.include | 6 +- .../dds_pim/topic/typeinformation.rst | 8 +- .../rtps/attributes/TypeLookupSettings.rst | 8 - .../rtps/attributes/attributes.rst | 1 - docs/fastdds/dds_layer/core/entity/entity.rst | 4 +- .../domainParticipant/domainParticipant.rst | 3 + .../domainParticipantListener.rst | 4 +- docs/fastdds/discovery/disc_callbacks.rst | 4 +- docs/fastdds/dynamic_types/discovery.rst | 28 -- .../xml_configuration/domainparticipant.rst | 32 +-- docs/notes/previous_versions/v2.11.0.rst | 2 +- 16 files changed, 136 insertions(+), 270 deletions(-) delete mode 100644 docs/fastdds/api_reference/rtps/attributes/TypeLookupSettings.rst diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 900567bb0..d7e58a9e8 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -201,7 +201,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener #endif // if HAVE_SECURITY - void on_subscriber_discovery( + void on_data_reader_discovery( DomainParticipant* /*participant*/, eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override { @@ -215,7 +215,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener } } - void on_publisher_discovery( + void on_data_writer_discovery( DomainParticipant* /*participant*/, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override { @@ -229,48 +229,6 @@ class CustomDomainParticipantListener : public DomainParticipantListener } } - 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; - } - }; //!-- @@ -457,7 +415,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 +423,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 +446,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 +471,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 +494,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 +511,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 +519,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 +534,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 +553,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 +769,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 +780,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; @@ -966,8 +924,8 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener } } - /* 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 { @@ -989,8 +947,8 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener } } - /* 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 { @@ -1012,24 +970,6 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener } } - /* Custom Callback on_type_discovery */ - 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 of topic '" << topic << "' discovered." << std::endl; - } - }; //!-- @@ -1240,7 +1180,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 +1285,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 +1305,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; } @@ -1602,7 +1542,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 +1550,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 +1582,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 +1608,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 +1630,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 +1647,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 +1655,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; @@ -1945,7 +1885,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 +1896,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 +1960,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; @@ -2108,19 +2048,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 +2072,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 +2082,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 +2110,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 +2323,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 +2331,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 +2363,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 +2396,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 +2418,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 +2435,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 +2443,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; @@ -2714,7 +2654,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; @@ -2722,7 +2662,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; @@ -2745,7 +2685,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; @@ -2762,7 +2702,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; @@ -2784,7 +2724,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; @@ -2801,7 +2741,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; @@ -2809,7 +2749,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; @@ -2848,7 +2788,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; @@ -2863,7 +2803,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; @@ -2878,7 +2818,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; @@ -3154,7 +3094,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; @@ -3162,7 +3102,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; @@ -3194,14 +3134,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; @@ -3227,7 +3167,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; @@ -3249,7 +3189,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; @@ -3266,7 +3206,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; @@ -3274,7 +3214,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; @@ -3506,7 +3446,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; @@ -3514,7 +3454,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; @@ -3537,14 +3477,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; @@ -3561,7 +3501,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; @@ -3583,7 +3523,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; @@ -3600,7 +3540,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; @@ -3608,7 +3548,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; @@ -3645,9 +3585,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) { @@ -3698,7 +3638,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) { @@ -3726,7 +3666,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) { @@ -3777,7 +3717,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) @@ -3820,7 +3760,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) { @@ -4351,17 +4291,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 @@ -4490,7 +4419,7 @@ 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 = @@ -4522,7 +4451,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())) { @@ -4542,7 +4471,7 @@ 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 @@ -4565,7 +4494,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; @@ -5890,7 +5819,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); @@ -5927,7 +5856,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) @@ -6142,7 +6071,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 @@ -6165,7 +6094,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; @@ -6196,7 +6125,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)) { @@ -6258,7 +6187,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; @@ -6539,7 +6468,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; @@ -6557,7 +6486,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; 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/XMLTester.xml b/code/XMLTester.xml index 7c2ca7036..2113989d4 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -1442,6 +1442,13 @@ -1 + + -1 + 0 + 0 + -1 + + -1 0 @@ -1620,10 +1627,6 @@ 55 - - true - true - <--> @@ -3870,19 +3873,6 @@ <--> -XML_TYPELOOKUP_SERVICE_ENABLING<--> - - - - - true - true - - - - -<--> - diff --git a/code/XMLTesterExample.xml b/code/XMLTesterExample.xml index b9f6e1248..f130bf684 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 diff --git a/docs/01-figures/listeners_inheritance_diagram.svg b/docs/01-figures/listeners_inheritance_diagram.svg index b8c3a6bc3..47e7b0722 100644 --- a/docs/01-figures/listeners_inheritance_diagram.svg +++ b/docs/01-figures/listeners_inheritance_diagram.svg @@ -1,4 +1,4 @@ -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 +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_data_reader_discovery()on_data_writer_discovery()on_type_discovery()on_type_dependencies_reply()on_type_information_received()TopicListeneron_inconsistent_topic() \ No newline at end of file diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 1990d7f0a..ba8423420 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -170,8 +170,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_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::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()` @@ -189,6 +189,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_threads()` .. |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 ` @@ -962,7 +963,6 @@ .. |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` 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/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/dds_layer/core/entity/entity.rst b/docs/fastdds/dds_layer/core/entity/entity.rst index fccd3ddd7..9ca4ca275 100644 --- a/docs/fastdds/dds_layer/core/entity/entity.rst +++ b/docs/fastdds/dds_layer/core/entity/entity.rst @@ -132,8 +132,8 @@ diagram: * |DomainParticipantListener::on_participant_discovery-api| * |DomainParticipantListener::onParticipantAuthentication-api| - * |DomainParticipantListener::on_subscriber_discovery-api| - * |DomainParticipantListener::on_publisher_discovery-api| + * |DomainParticipantListener::on_data_reader_discovery-api| + * |DomainParticipantListener::on_data_writer_discovery-api| * |DomainParticipantListener::on_type_discovery-api| * |DomainParticipantListener::on_type_dependencies_reply-api| * |DomainParticipantListener::on_type_information_received-api| 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..3ce3805bf 100644 --- a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst +++ b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst @@ -34,11 +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, + * |DomainParticipantListener::on_data_reader_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_publisher_discovery-api|: A new :ref:`dds_layer_publisher_publisher` is discovered in the same domain, + * |DomainParticipantListener::on_data_writer_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. diff --git a/docs/fastdds/discovery/disc_callbacks.rst b/docs/fastdds/discovery/disc_callbacks.rst index 11968c1bc..b984ea316 100644 --- a/docs/fastdds/discovery/disc_callbacks.rst +++ b/docs/fastdds/discovery/disc_callbacks.rst @@ -11,8 +11,8 @@ As stated in :ref:`dds_layer_domainParticipantListener`, the |DomainParticipantL 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: |DomainParticipantListener::on_participant_discovery-api|, -|DomainParticipantListener::on_subscriber_discovery-api|, -|DomainParticipantListener::on_publisher_discovery-api|, +|DomainParticipantListener::on_data_reader_discovery-api|, +|DomainParticipantListener::on_data_writer_discovery-api|, |DomainParticipantListener::on_type_discovery-api|. Further information about the DomainParticipantListener is provided in the :ref:`dds_layer_domainParticipantListener` section. diff --git a/docs/fastdds/dynamic_types/discovery.rst b/docs/fastdds/dynamic_types/discovery.rst index d6c45daf9..63493949c 100644 --- a/docs/fastdds/dynamic_types/discovery.rst +++ b/docs/fastdds/dynamic_types/discovery.rst @@ -110,14 +110,6 @@ 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 @@ -130,26 +122,6 @@ 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 diff --git a/docs/fastdds/xml_configuration/domainparticipant.rst b/docs/fastdds/xml_configuration/domainparticipant.rst index 1e2a74042..b974336a4 100644 --- a/docs/fastdds/xml_configuration/domainparticipant.rst +++ b/docs/fastdds/xml_configuration/domainparticipant.rst @@ -202,6 +202,10 @@ These elements allow the user to define the DomainParticipant configuration. - |ThreadSettings| for the discovery server thread. - |ThreadSettings| - + * - ```` + - |ThreadSettings| for the threads used by the TypeLookup service. + - |ThreadSettings| + - * - ```` - |ThreadSettings| for the builtin transports reception threads. - |ThreadSettings| @@ -323,12 +327,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 +518,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/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**: From 01979495014c74ed29af1e9712f3a64904ba728f Mon Sep 17 00:00:00 2001 From: adriancampo Date: Sun, 4 Feb 2024 13:59:38 +0100 Subject: [PATCH 02/23] 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 --- .../C++/DDSHelloWorld/src/HelloWorld.cxx | 168 ---- .../src/{HelloWorld.h => HelloWorld.hpp} | 123 ++- .../DDSHelloWorld/src/HelloWorldCdrAux.hpp | 4 +- .../DDSHelloWorld/src/HelloWorldCdrAux.ipp | 2 - .../src/HelloWorldPubSubTypes.cxx | 15 +- .../DDSHelloWorld/src/HelloWorldPubSubTypes.h | 7 +- .../listeners_inheritance_diagram.svg | 804 +++++++++++++++++- docs/03-exports/aliases-api.include | 6 - docs/03-exports/aliases.include | 1 - docs/fastdds/dds_layer/core/entity/entity.rst | 3 - .../domainParticipantListener.rst | 9 - .../createContentFilteredTopic.rst | 4 +- .../dds_layer/topic/fastddsgen/fastddsgen.rst | 11 +- docs/fastdds/discovery/disc_callbacks.rst | 1 - docs/fastdds/dynamic_types/discovery.rst | 44 +- docs/fastdds/dynamic_types/dynamic_types.rst | 4 +- docs/fastdds/dynamic_types/examples.rst | 3 +- .../simple_app/includes/dataType.rst | 5 +- .../simple_app/includes/workspace.rst | 3 +- .../simple_python_app/includes/dataType.rst | 5 +- .../simple_python_app/includes/workspace.rst | 3 +- .../rosbag_capture/rosbag_capture.rst | 5 +- docs/fastddsgen/dataTypes/dataTypes.rst | 15 +- .../pubsub_app/includes/first_app.rst | 10 +- .../pubsub_app/includes/workspace.rst | 7 +- docs/fastddsgen/usage/usage.rst | 41 +- 26 files changed, 962 insertions(+), 341 deletions(-) delete mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorld.cxx rename code/Examples/C++/DDSHelloWorld/src/{HelloWorld.h => HelloWorld.hpp} (70%) 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 70% rename from code/Examples/C++/DDSHelloWorld/src/HelloWorld.h rename to code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp index 5cd0ddba5..f3efa3c34 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,100 +62,155 @@ 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; + } /*! * @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); + 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 +219,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..f8d9d08b7 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx @@ -19,18 +19,16 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.h" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.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 +217,12 @@ bool HelloWorldPubSubType::getKey( return true; } +void HelloWorldPubSubType::register_type_object_representation() const +{ + EPROSIMA_LOG_WARNING(XTYPES_TYPE_REPRESENTATION, + "TypeObject type representation support disabled in generated code"); +} + + +// 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/docs/01-figures/listeners_inheritance_diagram.svg b/docs/01-figures/listeners_inheritance_diagram.svg index 47e7b0722..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_data_reader_discovery()on_data_writer_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 ba8423420..fba74b849 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -172,9 +172,6 @@ .. |DomainParticipantListener::on_participant_discovery-api| replace:: :cpp:func:`on_participant_discovery()` .. |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::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::onParticipantAuthentication-api| replace:: :cpp:func:`onParticipantAuthentication()` .. |DomainParticipantQos-api| replace:: :cpp:class:`DomainParticipantQos` @@ -288,7 +285,6 @@ .. |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() ` @@ -965,8 +961,6 @@ .. |TopicDataType::auto_fill_type_information-api| replace:: :cpp:func:`auto_fill_type_information` -.. |DomainParticipant::register_remote_type-api| replace:: :cpp:func:`register_remote_type` - .. |DomainParticipant::set_listener-api| replace:: :cpp:func:`DomainParticipant::set_listener()` .. |Publisher::set_listener-api| replace:: :cpp:func:`Publisher::set_listener()` .. |DataWriter::set_listener-api| replace:: :cpp:func:`DataWriter::set_listener()` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index eed1b2adb..b2d6b5838 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -118,7 +118,6 @@ .. |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` diff --git a/docs/fastdds/dds_layer/core/entity/entity.rst b/docs/fastdds/dds_layer/core/entity/entity.rst index 9ca4ca275..b23edb57d 100644 --- a/docs/fastdds/dds_layer/core/entity/entity.rst +++ b/docs/fastdds/dds_layer/core/entity/entity.rst @@ -134,9 +134,6 @@ diagram: * |DomainParticipantListener::onParticipantAuthentication-api| * |DomainParticipantListener::on_data_reader_discovery-api| * |DomainParticipantListener::on_data_writer_discovery-api| - * |DomainParticipantListener::on_type_discovery-api| - * |DomainParticipantListener::on_type_dependencies_reply-api| - * |DomainParticipantListener::on_type_information_received-api| * |DataWriterListener::on_unacknowledged_sample_removed-api| .. warning:: diff --git a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst index 3ce3805bf..97fd79e33 100644 --- a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst +++ b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst @@ -42,15 +42,6 @@ Additionally, DomainParticipantListener adds the following non-standard callback 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::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..b806e6c6a 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 bu 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..2e111cabe 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -37,7 +37,7 @@ 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 +* ``-no-typeobjectsupport``: Avoids building 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``. @@ -51,12 +51,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. +* HelloWorldCdrAux.hpp/.ipp: C++ serialization and deserialization code for the HelloWorld type. +* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject-api| generation and regstration. diff --git a/docs/fastdds/discovery/disc_callbacks.rst b/docs/fastdds/discovery/disc_callbacks.rst index b984ea316..813dd40d0 100644 --- a/docs/fastdds/discovery/disc_callbacks.rst +++ b/docs/fastdds/discovery/disc_callbacks.rst @@ -13,7 +13,6 @@ Fast DDS defines four callbacks attached to events that may occur during discove |DomainParticipantListener::on_participant_discovery-api|, |DomainParticipantListener::on_data_reader_discovery-api|, |DomainParticipantListener::on_data_writer_discovery-api|, -|DomainParticipantListener::on_type_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/discovery.rst b/docs/fastdds/dynamic_types/discovery.rst index 63493949c..3b417a9fb 100644 --- a/docs/fastdds/dynamic_types/discovery.rst +++ b/docs/fastdds/dynamic_types/discovery.rst @@ -6,7 +6,7 @@ Dynamic Types Discovery and Endpoint Matching ============================================= -.. _DDS-XTypes V1.2: http://www.omg.org/spec/DDS-XTypes/1.2 +.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 When using |DynamicTypes| support, *Fast DDS* checks the optional |TypeObject| and |TypeIdentifier| values during endpoint matching. @@ -21,7 +21,7 @@ The process of checking the types is as follows: 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. +If one of the endpoints transmits a :class:`CompleteTypeObject`, :ref:`discovery-time-data-typing` can be performed. .. _dynamictypes_discovery_typeobject: @@ -36,7 +36,7 @@ There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`Mini 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, +Both are described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. @@ -45,7 +45,7 @@ please refer to this document for details. TypeInformation --------------- -|TypeInformation-api| is an extension of *XTypes 1.2* that allow Endpoints to +|TypeInformation-api| is an extension of *XTypes 1.3* 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. @@ -53,7 +53,7 @@ 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, +|TypeInformation-api| is described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. @@ -67,32 +67,17 @@ 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, +|TypeIdV1-api| is described in the annexes of `DDS-XTypes V1.3`_ 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, +*Fast DDS-Gen* supports the generation of `XXXTypeObjecSupport.h` and `XXXTypeObjecSupport.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. +Generally, these files are not used directly, as now the type :class:`XXX` will register itself, +making it very easy to use static types with dynamic types. .. _discovery-time-data-typing: @@ -102,7 +87,6 @@ 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. @@ -117,16 +101,12 @@ 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. 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. @@ -137,12 +117,10 @@ This callback has the following signature: 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|, +* **type_name**: Is the name given to the type 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 +* **type**: If unable 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 diff --git a/docs/fastdds/dynamic_types/dynamic_types.rst b/docs/fastdds/dynamic_types/dynamic_types.rst index 158df34af..8ac9de4c9 100644 --- a/docs/fastdds/dynamic_types/dynamic_types.rst +++ b/docs/fastdds/dynamic_types/dynamic_types.rst @@ -3,11 +3,11 @@ Dynamic Topic Types =================== -.. _DDS-XTypes V1.2: http://www.omg.org/spec/DDS-XTypes/1.2 +.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 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`_. +For more information, you can read the specification for `DDS-XTypes V1.3`_. 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, diff --git a/docs/fastdds/dynamic_types/examples.rst b/docs/fastdds/dynamic_types/examples.rst index 3affb5648..f97e6075f 100644 --- a/docs/fastdds/dynamic_types/examples.rst +++ b/docs/fastdds/dynamic_types/examples.rst @@ -38,7 +38,7 @@ This example uses the DDS API, and can be retrieve from folder 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. +discovered type on the listener. TypeLookupService ----------------- @@ -48,4 +48,3 @@ This example uses the DDS API, and it is located in folder 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/getting_started/simple_app/includes/dataType.rst b/docs/fastdds/getting_started/simple_app/includes/dataType.rst index eb054adbb..ddfff016b 100644 --- a/docs/fastdds/getting_started/simple_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_app/includes/dataType.rst @@ -37,12 +37,11 @@ To do this, run the following command from the ``src`` directory. .. code-block:: bash - /scripts/fastddsgen HelloWorld.idl + /scripts/fastddsgen -no-typeobjectsupport HelloWorld.idl 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. diff --git a/docs/fastdds/getting_started/simple_app/includes/workspace.rst b/docs/fastdds/getting_started/simple_app/includes/workspace.rst index 2cfd0e60b..8a2cdc0ab 100644 --- a/docs/fastdds/getting_started/simple_app/includes/workspace.rst +++ b/docs/fastdds/getting_started/simple_app/includes/workspace.rst @@ -18,8 +18,7 @@ Subscriber application respectively. │   └── Makefile ├── CMakeLists.txt └── src - ├── HelloWorld.cxx - ├── HelloWorld.h + ├── HelloWorld.hpp ├── HelloWorld.idl ├── HelloWorldCdrAux.hpp ├── HelloWorldCdrAux.ipp 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..6511627e4 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst @@ -38,12 +38,11 @@ To do this, run the following command. .. code-block:: bash - /scripts/fastddsgen -python HelloWorld.idl + /scripts/fastddsgen -python -no-typeobjectsupport HelloWorld.idl 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. 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..9bed601b5 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 diff --git a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst index adce32741..a5f393d5e 100644 --- a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst +++ b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst @@ -163,8 +163,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/fastddsgen/dataTypes/dataTypes.rst b/docs/fastddsgen/dataTypes/dataTypes.rst index 5b8aca60f..9e458ff67 100644 --- a/docs/fastddsgen/dataTypes/dataTypes.rst +++ b/docs/fastddsgen/dataTypes/dataTypes.rst @@ -453,7 +453,6 @@ 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. .. code-block:: omg-idl @@ -468,9 +467,9 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | Annotation | Implemented behavior | +=========================+============================================================================================+ -| @id | [Unimplemented] Assign a 32-bit integer identifier to an element. | +| @id | Assign a 32-bit integer identifier to an element. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @autoid | [Unimplemented] Automatically allocate identifiers to the elements. | +| @autoid | Automatically allocate identifiers to the elements. | +-------------------------+--------------------------------------------------------------------------------------------+ | @optional | Setting an element as optional. More info in `Optional Members`_. | +-------------------------+--------------------------------------------------------------------------------------------+ @@ -485,15 +484,15 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | @position | Setting a position to an element or group of elements. Used by bitmasks_. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @value | [Unimplemented] Allow setting a constant value to any element. | +| @value | Allow setting a constant value to any element.Used by enumeration's members. | +-------------------------+--------------------------------------------------------------------------------------------+ | @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| | +| @must_understand | 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_literal | Allow selecting one member as the default within a collection. | +-------------------------+--------------------------------------------------------------------------------------------+ | @default | Allow specifying the default value of the annotated element. | +-------------------------+--------------------------------------------------------------------------------------------+ @@ -507,9 +506,9 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | @bit_bound | Allow setting a size to a bitmasks_. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @external | [Unimplemented] Force the annotated element to be placed in a dedicated data space. | +| @external | 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| | +| @nested | 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| | diff --git a/docs/fastddsgen/pubsub_app/includes/first_app.rst b/docs/fastddsgen/pubsub_app/includes/first_app.rst index 11640af2f..979c1c223 100644 --- a/docs/fastddsgen/pubsub_app/includes/first_app.rst +++ b/docs/fastddsgen/pubsub_app/includes/first_app.rst @@ -18,13 +18,13 @@ installation followed and the operating system. .. code:: bash - /src/fastddsgen/scripts/fastddsgen -example CMake HelloWorld.idl + /src/fastddsgen/scripts/fastddsgen -no-typeobjectsupport -example CMake HelloWorld.idl - For a **stand-alone installation**, run: .. code:: bash - /scripts/fastddsgen -example CMake HelloWorld.idl + /scripts/fastddsgen -no-typeobjectsupport -example CMake HelloWorld.idl * On Windows: @@ -32,19 +32,19 @@ installation followed and the operating system. .. code:: bash - /src/fastddsgen/scripts/fastddsgen.bat -example CMake HelloWorld.idl + /src/fastddsgen/scripts/fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl - For a **stand-alone installation**, run: .. code:: bash - /scripts/fastddsgen.bat -example CMake HelloWorld.idl + /scripts/fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl - For an **installation from binaries**, run: .. code:: bash - fastddsgen.bat -example CMake HelloWorld.idl + fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl .. warning:: 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..5bb599a5d 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,12 @@ 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 + - IDL grammar apply case sensitive matching. * - -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 an output directory for generated files. + * - -default-container-prealloc-size + - Sets the default preallocated size for containers (sequence and maps). Default value: 0. * - -default_extensibility |br| -de - Sets the default extensibility for types without the @extensibility annotation. |br| @@ -81,10 +75,25 @@ 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 + - Ignore input files relative paths and place all generated files in the specified output directory. + * - -fusion + - Activates fusion. * - -help - Shows the help information * - -I - Add directory to preprocessor include paths. + * - -language + - chooses between or languages. + * - -no-typesupport + - Avoid generating the type support files. + * - -no-typeobjectsupport + - Avoid generating the TypeObject support specific files. |br| + Enabled automatically if -no-typesupport argument is used. + * - -no-dependencies + - Avoid processing the dependent IDL files. + * - -package + - Default package used in Java files. * - -ppDisable - Disables the preprocessor. * - -ppPath @@ -92,17 +101,15 @@ 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. + * - -typesc + - Generates string and sequence types compatible with C. * - -version - Shows the current version of eProsima *Fast DDS-Gen*. From 8964bb1a90b7405b80fc70e685335e819b3abdaa Mon Sep 17 00:00:00 2001 From: adriancampo Date: Mon, 4 Mar 2024 15:12:08 +0100 Subject: [PATCH 03/23] Refs #20359: DDSCodeTester updates for DynamicTypes and discovery callbacks Signed-off-by: adriancampo --- code/DDSCodeTester.cpp | 71 +++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index d7e58a9e8..6a235139a 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -27,10 +27,14 @@ #include #include #include -#include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -203,7 +207,8 @@ class CustomDomainParticipantListener : public DomainParticipantListener void on_data_reader_discovery( DomainParticipant* /*participant*/, - eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) { @@ -217,7 +222,8 @@ class CustomDomainParticipantListener : public DomainParticipantListener void on_data_writer_discovery( DomainParticipant* /*participant*/, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override { if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) { @@ -927,7 +933,8 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener /* 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 { static_cast(participant); switch (info.status){ @@ -950,7 +957,8 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener /* 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 { static_cast(participant); switch (info.status){ @@ -1720,13 +1728,10 @@ void dds_topic_examples() // Load the XML file with the type description 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); - - // Build and register it - eprosima::fastrtps::types::DynamicType_ptr dyn_type = type->build(); - TypeSupport dyn_type_support(new eprosima::fastrtps::types::DynamicPubSubType(dyn_type)); + // Retrieve the an instance of the desired type and register it + traits::ref_type dyn_type; + eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName(dyn_type, "DynamicType"); + TypeSupport dyn_type_support(new DynamicPubSubType(dyn_type)); dyn_type_support.register_type(participant, nullptr); // Create a Topic with the registered type. @@ -4475,12 +4480,10 @@ void xml_profiles_examples() 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(); - + traits::ref_type my_struct_type; + eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName(my_struct_type, "MyStruct"); // 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 @@ -5644,28 +5647,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_INT32)); + 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(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 ********************************************************************************************************/ From a50e0eed2018a94a3b3acb8d460eacb537bf6218 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Sun, 17 Mar 2024 10:26:18 +0100 Subject: [PATCH 04/23] Refs #20359: Updated xtypes doc. Signed-off-by: adriancampo --- code/CodeTester.cpp | 719 +-------------- code/DDSCodeTester.cpp | 825 ++++++++++++++++- code/DynamicTypesIDLExamples.idl | 219 +++++ code/XMLTester.xml | 197 +++-- docs/03-exports/aliases-api.include | 37 +- docs/03-exports/aliases.include | 56 +- .../fastdds/api_reference/dds_pim/dds_pim.rst | 1 + .../dds_pim/xtypes/annotationdescriptor.rst | 10 + .../dds_pim/xtypes/dynamic_types.rst | 32 + .../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 + 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 | 133 --- .../dynamic_types/discovery_matching.rst | 66 ++ docs/fastdds/dynamic_types/dynamic_types.rst | 17 +- docs/fastdds/dynamic_types/examples.rst | 50 -- .../dynamic_types/language_binding.rst | 827 ++++++++++++++++++ .../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 - .../xml_configuration/dynamic_types.rst | 353 ++++++-- docs/fastddsgen/dataTypes/dataTypes.rst | 14 +- docs/notes/previous_versions/v2.4.2.rst | 2 +- 39 files changed, 2578 insertions(+), 1849 deletions(-) create mode 100644 code/DynamicTypesIDLExamples.idl 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/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 create mode 100644 docs/fastdds/dynamic_types/discovery_matching.rst delete mode 100644 docs/fastdds/dynamic_types/examples.rst create mode 100644 docs/fastdds/dynamic_types/language_binding.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 diff --git a/code/CodeTester.cpp b/code/CodeTester.cpp index ca60dd998..f897691a9 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 6a235139a..f7bbe6c0d 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -50,12 +51,7 @@ #include #include #include -#include -#include -#include -#include -#include - +#include using namespace eprosima::fastdds::dds; @@ -372,7 +368,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 @@ -1728,9 +1724,13 @@ void dds_topic_examples() // Load the XML file with the type description DomainParticipantFactory::get_instance()->load_XML_profiles_file("example_type.xml"); - // Retrieve the an instance of the desired type and register it - traits::ref_type dyn_type; - eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName(dyn_type, "DynamicType"); + // Retrieve the an instance of the desired type + DynamicTypeBuilder::_ref_type type_builder; + //TODO xtypes use the correct public method to get the type builder + //DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("DynamicType", type_builder); + + // Build and register it + DynamicType::_ref_type dyn_type = type_builder->build(); TypeSupport dyn_type_support(new DynamicPubSubType(dyn_type)); dyn_type_support.register_type(participant, nullptr); @@ -4420,6 +4420,767 @@ 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(ObjectName("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->name("my_char"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_wchar"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR16)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_octet"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BYTE)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_int8"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT8)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_uint8"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT8)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_short"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_ushort"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_long"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_ulong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_longlong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_ulonglong"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT64)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_float"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT32)); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_double"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_FLOAT64)); + struct_builder->add_member(member_descriptor); + 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(ObjectName("my_long")), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("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(ObjectName("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(LENGTH_UNLIMITED)->build()); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_wstring"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_wstring_type(LENGTH_UNLIMITED)->build()); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_bounded_string"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_string_type(41925)->build()); + struct_builder->add_member(member_descriptor); + member_descriptor->name("my_bounded_wstring"); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + create_wstring_type(20925)->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(ObjectName("my_string")), in_value); + data->get_string_value(out_value, data->get_member_id_by_name(ObjectName("my_string"))); + //!-- + } + { + //!--CPP_ENUM + // Define a struct type to contain an enum + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(TK_STRUCTURE); + type_descriptor->name(ObjectName("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 members to the enum type + MemberDescriptor::_ref_type union_member_descriptor {traits::make_shared()}; + union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + union_member_descriptor->name("A"); + enum_builder->add_member(union_member_descriptor); + union_member_descriptor = traits::make_shared(); + union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + union_member_descriptor->name("B"); + enum_builder->add_member(union_member_descriptor); + union_member_descriptor = traits::make_shared(); + union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); + union_member_descriptor->name("C"); + enum_builder->add_member(union_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 + int32_t in_value = 2; + int32_t out_value = 0; + data->set_int32_value(data->get_member_id_by_name(ObjectName("my_enum")), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("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(ObjectName("BitmaskStruct")); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + + // Define the bitmask type + 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"); + bitfield_member_descriptor->id(1); + 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"); + bitfield_member_descriptor->id(2); + 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 a bitmask member + bool in_value = 2; + bool out_value = 0; + data->set_boolean_value(data->get_member_id_by_name(ObjectName("my_bitmask")), in_value); + data->get_boolean_value(out_value, data->get_member_id_by_name(ObjectName("my_bitmask"))); + //!-- + } + { + 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(ObjectName("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("MyAliasEnum"); + 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 an array + TypeDescriptor::_ref_type aliasarray_type_descriptor {traits::make_shared()}; + aliasarray_type_descriptor->kind(TK_ALIAS); + aliasarray_type_descriptor->name("MyAliasArray"); + BoundSeq array_bounds = { 2, 2 }; + aliasarray_type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> + create_array_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_INT32), array_bounds)->build()); + DynamicTypeBuilder::_ref_type aliasarray_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(aliasarray_type_descriptor)}; + // Build the alias type for the array + DynamicType::_ref_type aliasarray_type = aliasarray_builder->build(); + + // Add alias enum member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_alias_enum"); + member_descriptor->type(aliasenum_type); + struct_builder->add_member(member_descriptor); + // Add alias array member to the struct + member_descriptor = traits::make_shared(); + member_descriptor->name("my_alias_array"); + member_descriptor->type(aliasarray_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 + int32_t in_value = 2; + int32_t out_value = 0; + data->set_int32_value(data->get_member_id_by_name(ObjectName("my_alias_enum")), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_alias_enum"))); + //!-- + } + { + //!--CPP_RECURSIVE_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(ObjectName("RecursiveAliasStruct")); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Define an alias type for base type + type_descriptor = traits::make_shared(); + type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); + type_descriptor->name(ObjectName("RecursiveAlias")); + type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::TK_UINT32)); + DynamicTypeBuilder::_ref_type builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(type_descriptor)}; + // Build the alias type for the base type + DynamicType::_ref_type rec_type {builder->build()}; + + type_descriptor = traits::make_shared(); + type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); + type_descriptor->name(ObjectName("MyAlias")); + type_descriptor->base_type(rec_type); + builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); + // Build the alias type for other alias + DynamicType::_ref_type alias_type {builder->build()}; + + // Add alias member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_alias"); + member_descriptor->type(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 member + int32_t in_value = 2; + int32_t out_value = 0; + data->set_int32_value(data->get_member_id_by_name(ObjectName("my_alias")), in_value); + data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_alias"))); + //!-- + } + { + //!--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(ObjectName("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()); + + // 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}; + Int32Seq out_value; + data->set_int32_values(data->get_member_id_by_name(ObjectName("long_array")), in_value); + data->get_int32_values(out_value, data->get_member_id_by_name(ObjectName("long_array"))); + //!-- + } + { + //!--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(ObjectName("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("short_sequence"); + sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type( + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16), 5)->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(ObjectName("short_sequence")), in_value); + data->get_int16_values(out_value, data->get_member_id_by_name(ObjectName("short_sequence"))); + //!-- + } + { + //!--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(ObjectName("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("long_long_map"); + map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_map_type( + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), + DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), 2)->build()); + // Add the map member to the struct + 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("long_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 + // Define a struct type + TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; + struct_type_descriptor->kind(TK_STRUCTURE); + struct_type_descriptor->name("MyStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + struct_type_descriptor)}; + // Add members to the struct + MemberDescriptor::_ref_type struct_member {traits::make_shared()}; + struct_member->name("first"); + struct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + struct_builder->add_member(struct_member); + struct_member = traits::make_shared(); + struct_member->name("second"); + struct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + struct_builder->add_member(struct_member); + + // 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 member + const int32_t value1 = 2; + int32_t value2 = 0; + data->set_int32_value(data->get_member_id_by_name(ObjectName("first")), value1); + data->get_int32_value(value2, data->get_member_id_by_name(ObjectName("first"))); + //!-- + } + { + DynamicType::_ref_type mystruct_type; + //!--CPP_UNION + // Define a struct type to contain the union + TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; + struct_type_descriptor->kind(TK_STRUCTURE); + struct_type_descriptor->name("UnionStruct"); + DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + struct_type_descriptor)}; + // Define a type for union + TypeDescriptor::_ref_type union_type_descriptor = traits::make_shared(); + union_type_descriptor->kind(TK_UNION); + union_type_descriptor->name("MyUnion"); + union_type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type( + TK_INT16)); + DynamicTypeBuilder::_ref_type union_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + union_type_descriptor)}; + // Add members to the union type + MemberDescriptor::_ref_type union_member_descriptor {traits::make_shared()}; + union_member_descriptor->name("first"); + union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + union_member_descriptor->label({0, 1}); + union_builder->add_member(union_member_descriptor); + union_member_descriptor = traits::make_shared(); + union_member_descriptor->name("second"); + union_member_descriptor->type(mystruct_type); + union_member_descriptor->label({2}); + union_builder->add_member(union_member_descriptor); + union_member_descriptor = traits::make_shared(); + union_member_descriptor->name("third"); + union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + union_member_descriptor->is_default_label(true); + union_builder->add_member(union_member_descriptor); + // Build the union type + DynamicType::_ref_type union_type = union_builder->build(); + + // Add the union member to the struct + MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; + member_descriptor->name("my_union"); + member_descriptor->type(union_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 member + DynamicData::_ref_type union_data = data->loan_value(data->get_member_id_by_name("my_union")); + + // Set and retrieve values for the member + int32_t in_value = 2; + int32_t out_value; + union_data->set_int32_value(union_data->get_member_id_by_name("first"), in_value); + union_data->get_int32_value(out_value, union_data->get_member_id_by_name("first")); + // 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 a type for bitset + TypeDescriptor::_ref_type bitset_type_descriptor {traits::make_shared()}; + bitset_type_descriptor->kind(TK_BITSET); + bitset_type_descriptor->name("MyBitset"); + bitset_type_descriptor->bound({3, 1, 4, 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); + 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); + 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); + 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 bitset_type = bitset_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)}; + // Set and retrieve values for the map member + DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name("my_bitset")); + + // Set and retrieve values for the member + 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_BITSET_INHERITANCE + // Create a parent bitset type + TypeDescriptor::_ref_type parentbitset_type_descriptor {traits::make_shared()}; + parentbitset_type_descriptor->kind(TK_BITSET); + parentbitset_type_descriptor->name("ParentBitSet"); + parentbitset_type_descriptor->bound({3, 1}); + DynamicTypeBuilder::_ref_type parentbitset_builder {DynamicTypeBuilderFactory::get_instance()->create_type( + parentbitset_type_descriptor)}; + // Add members to the parent bitset type + MemberDescriptor::_ref_type parentbitset_member_descriptor {traits::make_shared()}; + parentbitset_member_descriptor->name("a"); + parentbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_CHAR8)); + parentbitset_member_descriptor->id(0); + parentbitset_builder->add_member(parentbitset_member_descriptor); + parentbitset_member_descriptor = traits::make_shared(); + parentbitset_member_descriptor->name("b"); + parentbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(TK_BOOLEAN)); + parentbitset_member_descriptor->id(3); + parentbitset_builder->add_member(parentbitset_member_descriptor); + // Build the parent bitset type + DynamicType::_ref_type parentbitset_type = parentbitset_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({10, 12}); + 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("c"); + childbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); + childbitset_member_descriptor->id(0); + 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_INT16)); + childbitset_member_descriptor->id(10); + childbitset_builder->add_member(childbitset_member_descriptor); + // Build the child bitset type + DynamicType::_ref_type childbitset_type = childbitset_builder->build(); + //!-- + } + { + //!--CPP_STRUCT_INHERITANCE + // Create a 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_INT32)); + 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 child struct type + TypeDescriptor::_ref_type childstruct_type_descriptor {traits::make_shared()}; + childstruct_type_descriptor->kind(TK_STRUCTURE); + childstruct_type_descriptor->name("ChildStruct"); + childstruct_type_descriptor->base_type(parentstruct_type); + DynamicTypeBuilder::_ref_type childstruct_builder {DynamicTypeBuilderFactory::get_instance()-> + create_type(childstruct_type_descriptor)}; + // Add members to the child struct type + MemberDescriptor::_ref_type childstruct_member {traits::make_shared()}; + childstruct_member->name("third"); + childstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); + childstruct_builder->add_member(childstruct_member); + childstruct_member = traits::make_shared(); + childstruct_member->name("fourth"); + childstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); + childstruct_builder->add_member(childstruct_member); + // Build the child struct type + DynamicType::_ref_type childstruct_type = childstruct_builder->build(); + //!-- + } + { + //!--CPP_COMPLEX_STRUCTS + // Create a 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(0); + builder->add_member(member_descriptor); + // Build the inner struct type + DynamicType::_ref_type inner_struct_type {builder->build()}; + + // Create a complex struct type + type_descriptor = traits::make_shared(); + type_descriptor->kind(eprosima::fastdds::dds::TK_STRUCTURE); + type_descriptor->name("ComplexStruct"); + builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); + // Add members to the complex struct type + member_descriptor = traits::make_shared(); + member_descriptor->type(inner_struct_type); + member_descriptor->name("complex_member"); + member_descriptor->id(0); + builder->add_member(member_descriptor); + // Build the complex struct type + DynamicType::_ref_type struct_type {builder->build()}; + //!-- + } + { + //!--CPP_COMPLEX_UNIONS + // Create the inner union + TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; + type_descriptor->kind(eprosima::fastdds::dds::TK_UNION); + type_descriptor->name("InnerUnion"); + type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::TK_INT32)); + 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(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::TK_INT64)); + member_descriptor->name("first"); + member_descriptor->id(1); + member_descriptor->label({0}); + builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::TK_INT64)); + member_descriptor->name("second"); + member_descriptor->id(2); + 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(eprosima::fastdds::dds::TK_UNION); + type_descriptor->name("ComplexUnion"); + type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> + get_primitive_type(eprosima::fastdds::dds::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(eprosima::fastdds::dds::TK_INT32)); + member_descriptor->name("third"); + member_descriptor->id(1); + member_descriptor->label({0}); + builder->add_member(member_descriptor); + member_descriptor = traits::make_shared(); + member_descriptor->type(inner_union_type); + member_descriptor->name("fourth"); + member_descriptor->id(2); + member_descriptor->label({1}); + builder->add_member(member_descriptor); + // Build the complex union type + DynamicType::_ref_type union_type {builder->build()}; + //!-- + } + { + //!--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)}; + + // 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); + //!-- + } +} + void xml_profiles_examples() { { @@ -4479,10 +5240,13 @@ void xml_profiles_examples() if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { - // Retrieve the an instance of MyStruct type - traits::ref_type my_struct_type; - eprosima::fastrtps::xmlparser::XMLProfileManager::getDynamicTypeByName(my_struct_type, "MyStruct"); + // Retrieve the an instance of the desired type + DynamicTypeBuilder::_ref_type my_struct_builder; + //TODO xtypes use the correct public method to get the type builder + //DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("MyStruct", my_struct_builder); + // Register MyStruct type + DynamicType::_ref_type my_struct_type = my_struct_builder->build(); TypeSupport my_struct_type_support(new DynamicPubSubType(my_struct_type)); my_struct_type_support.register_type(participant, nullptr); } @@ -4782,7 +5546,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}); @@ -4799,7 +5564,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); @@ -5361,7 +6127,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 //!-- } @@ -5978,7 +6744,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; @@ -5993,7 +6760,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); @@ -6044,7 +6812,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; @@ -6060,7 +6829,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); @@ -6125,7 +6895,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; } @@ -6146,7 +6917,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] } @@ -6447,9 +7219,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 @@ -6507,8 +7279,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..5807c7a1c --- /dev/null +++ b/code/DynamicTypesIDLExamples.idl @@ -0,0 +1,219 @@ +//!--IDL_PRIMITIVES +struct PrimitivesStruct +{ + boolean my_bool; + char my_char; + wchar my_wchar; + octet my_octet; + int8 my_int8; + uint8 my_uint8; + int16 my_short; + uint16 my_ushort; + int32 my_long; + uint32 my_unlong; + int64 my_longlong; + uint64 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_ARRAYS +struct ArrayStruct +{ + int32 long_array[2][3][4]; +}; +//!-- + +//!--IDL_SEQUENCES +struct SequenceStruct +{ + sequence short_sequence; +}; +//!-- + +//!--IDL_MAPS +struct MapStruct +{ + map long_long_map; +}; +//!-- + +//!--IDL_ENUM +enum MyEnum +{ + A, + B, + C +}; +struct EnumStruct +{ + MyEnum my_enum; +}; +//!-- + +//!--IDL_BITMASK +@bit_bound(8) +bitmask MyBitMask +{ + @position(0) flag0, + @position(1) flag1, + @position(2) flag2, + @position(5) flag5 +}; +struct BitmaskStruct +{ + MyBitMask my_bitmask; +}; +//!-- + +//!--IDL_TYPEDEF +typedef MyEnum MyAliasEnum; +typedef int32 MyAliasArray[2][2]; +struct AliasStruct +{ + MyAliasEnum my_alias_enum; + MyAliasArray my_alias_array; +}; +//!-- + +//!--IDL_RECURSIVE_TYPEDEF +typedef uint32 RecursiveAlias; +typedef RecursiveAlias MyAlias; +struct RecursiveAliasStruct +{ + MyAlias my_alias; +}; +//!-- + +//!--IDL_STRUCT +struct MyStruct +{ + int32 first; + int64 second; +}; +//!-- + +//!--IDL_UNION +union MyUnion switch (int16) +{ + case 0: + case 1: + int32 first; + case 2: + MyStruct second; + default: + int64 third; +}; +struct UnionStruct +{ + MyUnion my_union; +};//!-- + +//!--IDL_BITSET +bitset MyBitset +{ + bitfield<3> a; + bitfield<1> b; + bitfield<4>; + bitfield<10> c; + bitfield<12, short> d; +}; +struct BitsetStruct +{ + MyBitset my_bitset; +}; +//!-- + +//!--IDL_BITSET_INHERITANCE +bitset ParentBitSet +{ + bitfield<3> a; + bitfield<1> b; +}; + +bitset ChildBitSet : ParentBitSet +{ + bitfield<10> c; + bitfield<12, short> d; +}; +//!-- + +//!--IDL_STRUCT_INHERITANCE +struct ParentStruct +{ + int32 first; + int64 second; +}; + +struct ChildStruct : ParentStruct +{ + int32 third; + int63 fourth; +}; +//!-- + +//!--CPP_COMPLEX_STRUCTS +struct InnerStruct +{ + int32 first; +}; + +struct ComplexStruct +{ + InnerStruct complex_member; +}; +//!-- + +//!--IDL_COMPLEX_STRUCTS +struct InnerStruct +{ + int32 first; +}; + +struct ComplexStruct +{ + InnerStruct complex_member; +}; +//!-- + +//!--IDL_COMPLEX_UNIONS +union InnerUnion switch (int32) +{ + case 0: + int64 first; + case 1: + int64 second; +}; + +union ComplexUnion switch (int32) +{ + case 0: + int32 third; + case 1: + InnerUnion fourth; +}; +//!-- + +//!--IDL_CUSTOM_ANNOTATION +@annotation MyAnnotation +{ + short length; +}; + +@MyAnnotation(length = 5) +struct AnnotatedStruct +{ +}; +//!-- diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 2113989d4..6f4333feb 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -4276,39 +4276,97 @@ -XML-DYN-ENUM<--> + + + + +XML_PRIMITIVES<--> + + + + + + + + + + + + + + + + + +<--> +XML_STRINGS<--> + + + + + + +<--> +XML_ARRAYS<--> + + + +<--> +XML_SEQUENCES<--> + + + +<--> +XML_MAPS<--> + + + +<--> +XML_ENUM<--> + + + <--> - -XML-TYPEDEF<--> +XML_BITMASK<--> + + + + + + + + + +<--> +XML_TYPEDEF<--> - - - - + + + - - - - +<--> +XML_RECURSIVE_TYPEDEF<--> + + + + <--> - -XML-STRUCT<--> +XML_STRUCT<--> <--> - -XML-UNION<--> +XML_UNION<--> - + @@ -4323,81 +4381,33 @@ -<--> - -XML-GENERIC<--> - - - - - - - - - - - - - - - - - - - - -<--> - -XML-BOUNDEDSTRINGS<--> - - -<--> -XML-SEQUENCES<--> - -<--> -XML-ARRAYS<--> - -<--> -XML-MAPS<--> - -<--> - - -XML-COMPLEX<--> - - + + <--> - -XML-BITSET<--> - +XML_BITSET<--> + + + + <--> -XML-BITMASK<--> - - - - - - -<--> -XML-BITSET-INHERIT<--> +XML_BITSET_INHERITANCE<--> - - + + - - - + + <--> -XML-STRUCT-INHERIT<--> +XML_STRUCT_INHERITANCE<--> @@ -4407,6 +4417,39 @@ <--> +XML_COMPLEX_STRUCTS<--> + + + + + + +<--> +XML_COMPLEX_UNIONS<--> + + + + + + + + + + + + + + + + + + + + + + +<--> + diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index fba74b849..ff4adc0ea 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -951,10 +951,39 @@ .. |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 ` +.. |AnnotationDescriptor-api| replace:: :cpp:class:`AnnotationDescriptor ` +.. |DynamicData-api| replace:: :cpp:class:`DynamicData ` +.. |DynamicData::loan_value| replace:: :cpp:func:`DynamicData::loan_value ` +.. |DynamicData::return_loaned_value| replace:: :cpp:func:`DynamicData::return_loaned_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| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation ` +.. |DynamicTypeBuilder::apply_annotation_to_member| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation_to_member ` +.. |DynamicTypeBuilderFactory-api| replace:: :cpp:class:`DynamicTypeBuilderFactory ` +.. |DynamicTypeBuilderFactory::get_primitive_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::get_primitive_type ` +.. |DynamicTypeBuilderFactory::create_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type ` +.. |DynamicTypeBuilderFactory::create_string_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_string_type ` +.. |DynamicTypeBuilderFactory::create_wstring_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_wstring_type ` +.. |DynamicTypeBuilderFactory::create_sequence_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_sequence_type ` +.. |DynamicTypeBuilderFactory::create_array_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_array_type ` +.. |DynamicTypeBuilderFactory::create_map_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_map_type ` +.. |DynamicTypeBuilderFactory::create_bitmask_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_bitmask_type ` +.. |DynamicTypeMember-api| replace:: :cpp:class:`DynamicTypeMember ` +.. |MemberDescriptor-api| replace:: :cpp:class:`MemberDescriptor ` +.. |MemberDescriptor::label| replace:: :cpp:func:`MemberDescriptor::label ` +.. |MemberDescriptor::is_key| replace:: :cpp:func:`MemberDescriptor::is_key ` +.. |MemberDescriptor::is_default_label| replace:: :cpp:func:`MemberDescriptor::is_default_label ` +.. |TypeDescriptor-api| replace:: :cpp:class:`TypeDescriptor ` +.. |TypeDescriptor::extensibility_kind| replace:: :cpp:func:`TypeDescriptor::extensibility_kind ` +.. |TypeDescriptor::base_type| replace:: :cpp:func:`TypeDescriptor::base_type ` +.. |TypeDescriptor::discriminator_type| replace:: :cpp:func:`TypeDescriptor::discriminator_type ` +.. |VerbatimTextDescriptor-api| replace:: :cpp:class:`VerbatimTextDescriptor ` + +.. |ITypeObjectRegistry-api| replace:: :cpp:class:`ITypeObjectRegistry ` +.. |TypeObjectUtils-api| replace:: :cpp:class:`TypeObjectUtils ` .. |TypeObjectV1-api| replace:: :cpp:class:`TypeObject` .. |TypeIdV1-api| replace:: :cpp:class:`TypeIdentifier` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index b2d6b5838..3622f77a5 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -82,42 +82,28 @@ .. |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` +.. |DynamicTypes| replace:: :ref:`DynamicTypes` +.. |Supported Types| replace:: :ref:`Supported Types` +.. |Primitive Types| replace:: :ref:`Primitive Types` +.. |String and WString| replace:: :ref:`String and WString` +.. |Alias| replace:: :ref:`Alias` +.. |Alias of an alias| replace:: :ref:`Alias of an alias` +.. |Enumeration| replace:: :ref:`Enumeration` +.. |Bitmask| replace:: :ref:`Bitmask` +.. |Structure| replace:: :ref:`Structure` +.. |Bitset| replace:: :ref:`Bitset` +.. |Union| replace:: :ref:`Union` +.. |Sequence| replace:: :ref:`Sequence` +.. |Array| replace:: :ref:`Array` +.. |Map| replace:: :ref:`Map` +.. |Complex Types| replace:: :ref:`Complex Types` +.. |Structure inheritance| replace:: :ref:`Structure inheritance` +.. |Bitset inheritance| replace:: :ref:`Bitset inheritance` +.. |Nested Structures| replace:: :ref:`Nested Structures` +.. |Nested Unions| replace:: :ref:`Nested Unions` -.. |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` +.. |TypeObject| replace:: :ref:`TypeObject` +.. |TypeInformation| replace:: :ref:`TypeInformation` .. |TopicDataType| replace:: :ref:`TopicDataType` .. |TopicDataTypes| replace:: :ref:`TopicDataTypes` 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/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..bffd71c64 --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst @@ -0,0 +1,32 @@ +Dynamic Types +============= + +.. 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..ff462282a --- /dev/null +++ b/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst @@ -0,0 +1,10 @@ +.. _api_pim_invalidargumenterror: + +.. 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/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 3b417a9fb..000000000 --- a/docs/fastdds/dynamic_types/discovery.rst +++ /dev/null @@ -1,133 +0,0 @@ -.. include:: ../../03-exports/aliases-api.include -.. include:: ../../03-exports/aliases.include - -.. _dynamictypes_discovery: - -Dynamic Types Discovery and Endpoint Matching -============================================= - -.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 - -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.3`_ document, -please refer to this document for details. - - -.. _dynamictypes_discovery_typeinformation: - -TypeInformation ---------------- - -|TypeInformation-api| is an extension of *XTypes 1.3* 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.3`_ 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.3`_ document, -please refer to this document for details. - -Fast DDS-Gen ------------- - -*Fast DDS-Gen* supports the generation of `XXXTypeObjecSupport.h` and `XXXTypeObjecSupport.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, -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 -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. - -.. _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 -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. - -A participant can be enabled to act as a TypeLookup server, client, or both. - -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 - to allow the same callback to be used across different calls. - -* **type**: If unable 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/discovery_matching.rst b/docs/fastdds/dynamic_types/discovery_matching.rst new file mode 100644 index 000000000..031269029 --- /dev/null +++ b/docs/fastdds/dynamic_types/discovery_matching.rst @@ -0,0 +1,66 @@ +.. include:: ../../03-exports/aliases-api.include +.. include:: ../../03-exports/aliases.include + +.. _dynamictypes_discovery_matching: + +Dynamic Types Discovery and Endpoint Matching +============================================= + +.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 + +When using |DynamicTypes| support, *Fast DDS* checks the optional |TypeInformation-api| +value during endpoint matching. + +The process of checking the types is as follows: + +* If the discovered participant has sent |TypeInformation-api|, Fast DDS will check if all required types are known. + If not, it will initiate an automatic process of discovering the necessary types, using |TypeObject-api| + to communicate the information about the types with the other participants. + This process occurs asynchronously, and the matching of the discovered participant will not occur + until all necessary types are known, and they are fully compatible. +* If the discovered participant has not sent |TypeInformation-api|, Fast DDS will utilize a fallback mechanism, + using the type name to check if the type is known. Matching will occur if the type is known. + +.. _dynamictypes_discovery_typeinformation: + +TypeInformation +--------------- + +|TypeInformation-api| is an extension of *XTypes 1.3* 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 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.3`_ document, +please refer to this document for details. + +.. _dynamictypes_discovery_typeobject: + +TypeObject +---------- + +|TypeObject-api| provides a thorough description of a data type, similar to how it's represented in IDL. +There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`MinimalTypeObject`. + + - :class:`CompleteTypeObject` is representation of a type with the same level of detail and expressiveness as in IDL. + It serves as an alternative representation of types, suitable for programming and tooling purposes. + + - :class:`MinimalTypeObject` is a simplified version of the data type. + It includes only the necessary information for remote Endpoints to interpret the data accurately. + This simplified representation excludes details such as user-defined annotations or member order for types with + extensibility kind MUTABLE, which are irrelevant for type assignability. + By doing so, it reduces the amount of information applications need to transmit over the network. + +TypeObject is an IDL union with both *Minimal* and *Complete* representation. +Both are described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. + +Fast DDS-Gen +------------ +*Fast DDS-Gen* default behaviour creates the necessary code to work with *Dynamic Types*. +The generated code will include the `XXXTypeObjecSupport.h` and `XXXTypeObjecSupport.cxx` files, +taking :class:`XXX` as our IDL type. +These files provide a Type Factory for the type :class:`XXX`. +Generally, these files are not used directly, as the type :class:`XXX` will register itself. + +*Fast DDS-Gen* usage information can be found on the :ref:`Fast DDS-Gen ` section. diff --git a/docs/fastdds/dynamic_types/dynamic_types.rst b/docs/fastdds/dynamic_types/dynamic_types.rst index 8ac9de4c9..1761a9bea 100644 --- a/docs/fastdds/dynamic_types/dynamic_types.rst +++ b/docs/fastdds/dynamic_types/dynamic_types.rst @@ -1,13 +1,13 @@ .. _dynamic-types: -Dynamic Topic Types -=================== +XTypes 1.3 +========== .. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 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.3`_. +For more information, For more information, refer to the specification for `DDS-XTypes V1.3`_. 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, @@ -16,12 +16,5 @@ avoiding the additional step of updating the IDL file and the generation of *C++ .. 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 + /fastdds/dynamic_types/discovery_matching.rst + /fastdds/dynamic_types/language_binding.rst diff --git a/docs/fastdds/dynamic_types/examples.rst b/docs/fastdds/dynamic_types/examples.rst deleted file mode 100644 index f97e6075f..000000000 --- a/docs/fastdds/dynamic_types/examples.rst +++ /dev/null @@ -1,50 +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 listener. - -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. diff --git a/docs/fastdds/dynamic_types/language_binding.rst b/docs/fastdds/dynamic_types/language_binding.rst new file mode 100644 index 000000000..1f09efa4d --- /dev/null +++ b/docs/fastdds/dynamic_types/language_binding.rst @@ -0,0 +1,827 @@ +.. include:: ../../03-exports/aliases.include +.. include:: ../../03-exports/aliases-api.include +.. include:: ../../03-exports/roles.include + +.. _dynamictypes_language_binding: + +Dynamic Language Binding +======================== + +*eProsima Fast DDS* supports several methods for defining |DynamicTypes|. +Manual creation using |DynamicTypeBuilderFactory-api| and |DynamicTypeBuilder-api| to create the types. + +:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes directly defining +them through XML. + +:ref:`Fast DDS-Gen ` provides a way to automatically generate the code to define the |DynamicTypes| +from the IDL files. + +This section contains a detailed explanation of how to create |DynamicTypes| using the manual way, as well as the +same examples using XML and IDL files. + +.. _dynamictypes_supportedtypes: + +Supported Types +--------------- + +.. _dynamictypes_supportedtypes_primitive: + +Primitives +^^^^^^^^^^ + +By definition, primitive types are self-described and can be created without configuration parameters. +Therefore, |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| +to allow users to create the type avoiding the |DynamicTypeBuilder-api| step. +The |DynamicData-api| class has a specific :func:`get__value` and :func:`set__value` functions for each primitive +type of the list. + +The following table shows the supported primitive types and their corresponding ``TypeKind``. +The ``TypeKind`` is used to identify the type when creating it. + ++------------------+-------------------+ +| Type | TypeKind | ++------------------+-------------------+ +| ``BOOLEAN`` | ``TK_BOOLEAN`` | ++------------------+-------------------+ +| ``CHAR8`` | ``TK_CHAR8`` | ++------------------+-------------------+ +| ``CHAR16`` | ``TK_CHAR16`` | ++------------------+-------------------+ +| ``OCTET`` | ``TK_BYTE`` | ++------------------+-------------------+ +| ``INT8`` | ``TK_INT8`` | ++------------------+-------------------+ +| ``UINT8`` | ``TK_UINT8`` | ++------------------+-------------------+ +| ``INT16`` | ``TK_INT16`` | ++------------------+-------------------+ +| ``UINT16`` | ``TK_UINT16`` | ++------------------+-------------------+ +| ``INT32`` | ``TK_INT32`` | ++------------------+-------------------+ +| ``UINT32`` | ``TK_UINT32`` | ++------------------+-------------------+ +| ``INT64`` | ``TK_INT64`` | ++------------------+-------------------+ +| ``UINT64`` | ``TK_UINT64`` | ++------------------+-------------------+ +| ``FLOAT32`` | ``TK_FLOAT32`` | ++------------------+-------------------+ +| ``FLOAT64`` | ``TK_FLOAT64`` | ++------------------+-------------------+ +| ``FLOAT128`` | ``TK_FLOAT128`` | ++------------------+-------------------+ + +This examples show how to create members of each primitive type using |DynamicTypeBuilderFactory-api|. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Primitives `. + +.. _dynamictypes_supportedtypes_string: + +Strings +^^^^^^^ + +Strings are pretty similar to primitive types, the main difference being that they need to set their size limit. + +|DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and +|DynamicTypeBuilderFactory::create_wstring_type| to allow users create them directly. +This functions receive a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` +to set it as unlimited. +The |DynamicData-api| class has a specific :func:`get_string_value` and :func:`set_string_value`. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Primitives `. + +Constructed Types +^^^^^^^^^^^^^^^^^ + +Enumerated Types +"""""""""""""""" + +.. _dynamictypes_supportedtypes_enumeration: + +Enumerations +************ + +An enumeration contains a set of supported values and a selected value among those supported. +The ``TypeKind`` used to identify Enumerations is ``TK_ENUM``. + +The supported values must be configured using the |DynamicTypeBuilder-api|, using the |DynamicTypeBuilder::add_member| +function for each supported value. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Enumerations `. + +.. _dynamictypes_supportedtypes_bitmask: + +Bitmasks +******** + +Bitmasks are similar to |Enumeration| types, but their members work as bit flags that can be individually turned on and +off. +The ``TypeKind`` used to identify Bitmasks is ``TK_BITMASK``. + +Those flags might use the ``positition`` attribute to set their position in the bitmask. +The ``bit_bound`` attribute specifies the number of bits that the bitmask type will manage. +Bitmasks can be bound to any number of bits up to 64. +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to +facilitate the creation of this type. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Bitmask `. + +.. _dynamictypes_supportedtypes_alias: + +Alias +""""" + +Alias types provide an alternative name to an already existing type. +The ``TypeKind`` used to identify Alias is ``TK_ALIAS``. + +Once the |DynamicData-api| is created, users can access its information as if they were working with the base type. +To create an alias type, users must use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| with +the existing type they want the alias to represent. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Typedef `. + +.. _dynamictypes_complextypes_aliasalias: + +Alias types support recursion, simply by using an alias as base type for :|TypeDescriptor::base_type|. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_RECURSIVE_TYPEDEF + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_RECURSIVE_TYPEDEF<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_RECURSIVE_TYPEDEF + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, +please refer to :ref:`Primitives `. + +Collections +""""""""""" + +.. _dynamictypes_supportedtypes_sequence: + +Sequences +********* + +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. + +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to +facilitate the creation of this type. +To create this type users need to specify the type that it is going to store. +Additionally, the size limit of the list. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. + +The |DynamicData-api| class has a specific :func:`get__values` and :func:`set__values` functions for each primitive +type that allow users to work with multiple values at once. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Sequences `. + +.. _dynamictypes_supportedtypes_array: + +Arrays +****** + +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. + +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to +facilitate the creation of this type. + +The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each +primitive type that allow users to work with multiple values at once. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Arrays `. + +.. _dynamictypes_supportedtypes_map: + +Maps +**** + +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. + +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_map_type| to +facilitate the creation of this type. +To create a map, users must set the types of the key and the value elements. +Additionally, the size limit of the map. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. + +The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each primitive +type that allow users to work with multiple values at once. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Maps `. + +Aggregated Types +"""""""""""""""" + +.. _dynamictypes_supportedtypes_structure: + +Structures +********** + +Structures are the most 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. + +The function |DynamicTypeBuilderFactory::create_type| is used to create a new structure type. +The ``TypeKind`` used to identify Structures is ``TK_STRUCTURE``. + +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, |DynamicData::loan_value| should be used to access it and +|DynamicData::return_loaned_value| to release that loan. +|DynamicData-api| manages the loaned values and users can not loan a value that has been loaned previously +without calling |DynamicData::return_loaned_value| before. + + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Struct `. + +.. _dynamictypes_supportedtypes_union: + +Unions +****** + +Unions are a special kind of structures where only one of the members is active at the same time. +The ``TypeKind`` used to identify Unions is ``TK_UNION``. + +To control these members, users must set the ``discriminator`` type that is going to be used to select the current +member calling the |TypeDescriptor::discriminator_type| function of the union type. +The ``discriminator`` itself is a DynamicType of any primitive type, string type or union type. + +Additionally users can use the function |MemberDescriptor::label| with one or more values to set the labels of each +member of the union, and |MemberDescriptor::is_default_label| to specify the default label of the union. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Union `. + +.. _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. +The ``TypeKind`` used to identify Bitsets is ``TK_BITSET``. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: 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:`Bitset `. + +.. _dynamictypes_complextypes: + +Complex types +^^^^^^^^^^^^^ + +In complex data models, combinations of basic types :ref:`basic types` +can be used to create intricate structures, including nested compositions such as structures within structures. +Additionally, types can be extended using inheritance to enhance flexibility. + +The following subsections describe these *complex types* and their use. + +Inheritance +""""""""""" + +.. _dynamictypes_structure_inheritance: + +Structures allow inheritance, exactly with the same OOP meaning. +To inherit from another structure, users must create the parent structure calling the +|DynamicTypeBuilderFactory::create_type| normally. +After the parent type is created, use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| +when creating the child structure, using the parent type as the base type. + +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. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_STRUCT_INHERITANCE + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRUCT_INHERITANCE<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_STRUCT_INHERITANCE + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, +please refer to :ref:`Struct `. + +.. _dynamictypes_bitset_inheritance: + +Bitsets allows inheritance aswell, exactly with the same OOP meaning. +To inherit from another bitset, users must follow the same process as with +:ref:`structures `, but using bitset types. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_BITSET_INHERITANCE + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITSET_INHERITANCE<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_BITSET_INHERITANCE + :end-before: //!-- + +For a detailed explanation about the XML definition of this type, +please refer to :ref:`Bitset `. + +Nested Types +"""""""""""" + +.. _dynamictypes_nested_structures: + +Structures can contain other structures as members. +The access to these compound members is restricted and managed by the |DynamicData-api| instance. +Users must request access calling |DynamicData::loan_value| before using them, +and release them with |DynamicData::return_loaned_value| once they finished. +The loan operation will fail if the member is already loaned and has not been released yet. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_COMPLEX_STRUCTS + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_COMPLEX_STRUCTS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_STRUCTS + :end-before: //!-- + +.. _dynamictypes_nested_unions: + +Unions support complex type fields. +The access to these complex type fields is restricted and managed by the |DynamicData-api| instance. +Users must request access calling |DynamicData::loan_value| before using them, +and release them with |DynamicData::return_loaned_value| once they finished. +The loan operation will fail if the fields is already loaned and has not been released yet. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_COMPLEX_UNIONS + :end-before: //!-- + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_COMPLEX_UNIONS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_UNIONS + :end-before: //!-- + + +For a detailed explanation about the XML definition of this types, +please refer to :ref:`Complex types `. + +Annotations +^^^^^^^^^^^ + +|DynamicTypeBuilder-api| allows applying an annotation to both current type and inner members with the functions. +To add the annotations to the types, the function |DynamicTypeBuilder::apply_annotation| is used, and +|DynamicTypeBuilder::apply_annotation_to_member| to add them to the members. + +Both functions take the :class:`AnnotationDescriptor` of the annotation to be added, +and |DynamicTypeBuilder::apply_annotation_to_member| additionally receives the ``MemberId`` of the inner member. + + +Custom annotations +"""""""""""""""""" + +|DynamicTypes| allows users to create custom annotations to add extra information to the types. + +:ref:`XMLDynamicTypes ` does not currently support custom annotations. + +.. tabs:: + + .. tab:: IDL + + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_CUSTOM_ANNOTATION + :end-before: //!-- + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_CUSTOM_ANNOTATION + :end-before: //!-- + + +Builtin annotations +""""""""""""""""""" + +Beside the custom annotations created by the users, there are a number of builtin annotations. + +Currently, |DynamicTypes| supports the following builtin annotations: + ++-------------------------+-------------------------------------------------------------------------------------------+ +| Annotation | Implemented behavior | ++=========================+===========================================================================================+ +| ``@extensibility`` | Applied to any element which is constructed. Allow specifying how the |br| | +| | element is allowed to evolve. More info in :ref:`extensibility`. | ++-------------------------+-------------------------------------------------------------------------------------------+ +| ``@final`` | Shortcut for `@extensibility(FINAL)` | ++-------------------------+-------------------------------------------------------------------------------------------+ +| ``@appendable`` | Shortcut for `@extensibility(APPENDABLE)` | ++-------------------------+-------------------------------------------------------------------------------------------+ +| ``@mutable`` | Shortcut for `@extensibility(MUTABLE)` | ++-------------------------+-------------------------------------------------------------------------------------------+ +| ``@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). | ++-------------------------+-------------------------------------------------------------------------------------------+ + +To apply the @extensibility annotation (and its shortcuts) the |TypeDescriptor-api| exposes the function +|TypeDescriptor::extensibility_kind|, that recives a :class:`ExtensibilityKind`. + +For the @key annotation the function |MemberDescriptor::is_key| can be fount in |MemberDescriptor-api|. + +Type promotions +--------------- + +|DynamicTypes| 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: + ++--------------+-------------------------------------------------------------------------------------------+ +| Type | Promotions | ++==============+===========================================================================================+ +| `Int8` | Int16, Int32, Int64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Int16` | Int32, Int64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Int32` | Int64, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Int64` | Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `UInt8` | Int16,Int32, Int64, UInt16, UInt32, UInt64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `UInt16` | Int32, Int64, UInt32, UInt64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `UInt32` | Int64, UInt64, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `UInt64` | Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Float32` | Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Float64` | Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Float128` | (none) | ++--------------+-------------------------------------------------------------------------------------------+ +| `Char8` | Char16, Int16, Int32, Int64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Char16` | Int32, Int64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ +| `Byte` | (any) | ++--------------+-------------------------------------------------------------------------------------------+ +| `Boolean` | Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Float128 | ++--------------+-------------------------------------------------------------------------------------------+ 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/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 2732f0752..7f926e9fd 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -61,6 +61,8 @@ Member types are defined as any type that can belong to a `Struct`_ or a `Union` `Typedef`_. These can be defined by the ```` XML tag. +.. _xmldynamictypes_primivites: + Primitive types *************** @@ -90,10 +92,25 @@ Please, refer to :ref:`dynamictypes_supportedtypes_primitive` for more informati All of them are defined as follows: -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-GENERIC<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Primitives `. + +.. _xmldynamictypes_strings: Bounded strings *************** @@ -102,10 +119,25 @@ Bounded strings are defined as any other ``string`` or ``wstring`` but adding th 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-BOUNDEDSTRINGS<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Strings `. + +.. _xmldynamictypes_sequence: Sequences ********* @@ -115,10 +147,25 @@ The sequence type is implemented by setting three attributes: ``name``, ``type`` 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: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Sequences `. + +.. _xmldynamictypes_array: Arrays ****** @@ -127,10 +174,25 @@ Arrays are defined in the same way as any other member type but they add the att 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. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-ARRAYS<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Arrays `. + +.. _xmldynamictypes_map: Maps **** @@ -139,10 +201,25 @@ 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-MAPS<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Maps `. + +.. _xmldynamictypes_complextypes: Complex types """"""""""""" @@ -153,13 +230,45 @@ The ``type`` in this case is ``nonBasic`` (not a `Primitive types`_) and the nam given in the ``nonBasicTypeName`` attribute. Please, refer to :ref:`dynamictypes_complextypes` section for more information on complex types. -The following example shows a new structure with the ``primitive_types_example`` struct defined in `Primitive types`_ -example. +The following example shows structure having another structure as a member. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-COMPLEX<--> - :end-before: <--> +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_COMPLEX_STRUCTS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_STRUCTS + :end-before: //!-- + +For a full example of how to define this type, please refer to :ref:`Nested Types `. + +This example shows union having another union as a member. + +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_COMPLEX_UNIONS<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_UNIONS + :end-before: //!-- + +For a full example of how to define this type, please refer to :ref:`Nested Types `. Complex types attributes ************************ @@ -190,6 +299,8 @@ these attributes are then defined in the following table. * - ``mapMaxLength`` - Maximum length of a `Maps`_. +.. _xmldynamictypes_typedef: + Typedef """"""" @@ -200,10 +311,25 @@ Maps, arrays and sequences can be elements within another container using ```` element corresponds to :ref:`dynamictypes_supportedtypes_alias` in :ref:`dynamictypes_supportedtypes` section. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-TYPEDEF<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Alias `. + +.. _xmldynamictypes_enums: Enumerations """""""""""" @@ -212,10 +338,25 @@ The ```` type is defined by its attribute ``name`` and a set of ```` 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. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-DYN-ENUM<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Enumerations `. + +.. _xmldynamictypes_struct: Struct """""" @@ -223,20 +364,50 @@ Struct 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-STRUCT<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Structures `. + +.. _xmldynamictypes_struct_inheritance: 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/XMLTester.xml - :language: xml - :start-after: XML-STRUCT-INHERIT<--> - :end-before: <--> +.. tabs:: + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_STRUCT_INHERITANCE<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_STRUCT_INHERITANCE + :end-before: //!-- + +For a full example of how to define this type, please refer to :ref:`Structures Inheritance `. + +.. _xmldynamictypes_union: Union """"" @@ -248,10 +419,25 @@ Each ```` element has one or more ```` elements, which ```` type, and a unique ```` element. Please, refer to :ref:`dynamictypes_supportedtypes_union` for more information on the ```` type. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-UNION<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Unions `. + +.. _xmldynamictypes_bitset: Bitset """""" @@ -264,17 +450,50 @@ 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-BITSET<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Bitset `. + +.. _xmldynamictypes_bitset_inheritance: + +Moreover, bitsets can inherit from another bitsets. +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. -Moreover, bitsets can inherit from another bitsets: +.. tabs:: -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BITSET-INHERIT<--> - :end-before: <--> + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_BITSET_INHERITANCE<--> + :end-before: <--> + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_BITSET_INHERITANCE + :end-before: //!-- + +For a full example of how to define this type, please refer to :ref:`Bitset Inheritance `. + +.. _xmldynamictypes_bitmask: Bitmask """"""" @@ -287,10 +506,23 @@ The ```` element must define the ``name`` attribute and it might defi the ``positition`` attribute. Please, refer to :ref:`dynamictypes_supportedtypes_bitmask` for more information on the ```` type. -.. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML-BITMASK<--> - :end-before: <--> +.. tabs:: + + .. 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 full example of how to define this type, please refer to :ref:`Bitmasks `. .. _Usage: @@ -298,11 +530,10 @@ Loading dynamic types in a *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. +define the types must be loaded before trying to instantiate |DynamicPubSubType-api| objects of these types. .. literalinclude:: /../code/DDSCodeTester.cpp :language: c++ :start-after: //XML-USAGE :end-before: //!-- :dedent: 8 - diff --git a/docs/fastddsgen/dataTypes/dataTypes.rst b/docs/fastddsgen/dataTypes/dataTypes.rst index 9e458ff67..d3d7ff810 100644 --- a/docs/fastddsgen/dataTypes/dataTypes.rst +++ b/docs/fastddsgen/dataTypes/dataTypes.rst @@ -484,7 +484,7 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | @position | Setting a position to an element or group of elements. Used by bitmasks_. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @value | Allow setting a constant value to any element.Used by enumeration's members. | +| @value | [Unimplemented] Allow setting a constant value to a element.Used by enumeration's members. | +-------------------------+--------------------------------------------------------------------------------------------+ | @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). | @@ -494,7 +494,7 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | @default_literal | Allow selecting one member as the default within a collection. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @default | Allow specifying the default value of the annotated element. | +| @default | [Unimplemented] Allow specifying the default value of the annotated element. | +-------------------------+--------------------------------------------------------------------------------------------+ | @range | [Unimplemented] Allow specifying a range of allowed values for the annotated element. | +-------------------------+--------------------------------------------------------------------------------------------+ @@ -502,7 +502,7 @@ Additionally, the following standard annotations are builtin (recognized and pas +-------------------------+--------------------------------------------------------------------------------------------+ | @max | [Unimplemented] Allow specifying a maximum value for the annotated element. | +-------------------------+--------------------------------------------------------------------------------------------+ -| @unit | [Unimplemented] Allow specifying a unit of measurement for the annotated element. | +| @unit | Allow specifying a unit of measurement for the annotated element. | +-------------------------+--------------------------------------------------------------------------------------------+ | @bit_bound | Allow setting a size to a bitmasks_. | +-------------------------+--------------------------------------------------------------------------------------------+ @@ -511,15 +511,15 @@ Additionally, the following standard annotations are builtin (recognized and pas | @nested | 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| | +| @verbatim | 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. | +| @service | 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| | +| @oneway | 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| | +| @ami | 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. | 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: From aaa1c9ed111501dfb56e8aac99bb266179e1b334 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Mon, 18 Mar 2024 11:28:45 +0100 Subject: [PATCH 05/23] Refs #20359: Applied first suggestions. Signed-off-by: adriancampo --- docs/03-exports/aliases.include | 40 +++++------ .../dds_layer/topic/fastddsgen/fastddsgen.rst | 2 +- docs/fastdds/dynamic_types/dynamic_types.rst | 20 ------ .../xml_configuration/dynamic_types.rst | 66 +++++++++---------- .../discovery_matching.rst | 19 +++--- .../language_binding.rst | 46 ++++++------- docs/fastdds/xtypes/xtypes.rst | 27 ++++++++ docs/index.rst | 2 +- 8 files changed, 115 insertions(+), 107 deletions(-) delete mode 100644 docs/fastdds/dynamic_types/dynamic_types.rst rename docs/fastdds/{dynamic_types => xtypes}/discovery_matching.rst (85%) rename docs/fastdds/{dynamic_types => xtypes}/language_binding.rst (96%) create mode 100644 docs/fastdds/xtypes/xtypes.rst diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index 3622f77a5..2ab7c053e 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -83,27 +83,27 @@ .. |MemoryManagementPolicy| replace:: :ref:`MemoryManagementPolicy` .. |DynamicTypes| replace:: :ref:`DynamicTypes` -.. |Supported Types| replace:: :ref:`Supported Types` -.. |Primitive Types| replace:: :ref:`Primitive Types` -.. |String and WString| replace:: :ref:`String and WString` -.. |Alias| replace:: :ref:`Alias` -.. |Alias of an alias| replace:: :ref:`Alias of an alias` -.. |Enumeration| replace:: :ref:`Enumeration` -.. |Bitmask| replace:: :ref:`Bitmask` -.. |Structure| replace:: :ref:`Structure` -.. |Bitset| replace:: :ref:`Bitset` -.. |Union| replace:: :ref:`Union` -.. |Sequence| replace:: :ref:`Sequence` -.. |Array| replace:: :ref:`Array` -.. |Map| replace:: :ref:`Map` -.. |Complex Types| replace:: :ref:`Complex Types` -.. |Structure inheritance| replace:: :ref:`Structure inheritance` -.. |Bitset inheritance| replace:: :ref:`Bitset inheritance` -.. |Nested Structures| replace:: :ref:`Nested Structures` -.. |Nested Unions| replace:: :ref:`Nested Unions` +.. |Supported Types| replace:: :ref:`Supported Types` +.. |Primitive Types| replace:: :ref:`Primitive Types` +.. |String and WString| replace:: :ref:`String and WString` +.. |Alias| replace:: :ref:`Alias` +.. |Alias of an alias| replace:: :ref:`Alias of an alias` +.. |Enumeration| replace:: :ref:`Enumeration` +.. |Bitmask| replace:: :ref:`Bitmask` +.. |Structure| replace:: :ref:`Structure` +.. |Bitset| replace:: :ref:`Bitset` +.. |Union| replace:: :ref:`Union` +.. |Sequence| replace:: :ref:`Sequence` +.. |Array| replace:: :ref:`Array` +.. |Map| replace:: :ref:`Map` +.. |Complex Types| replace:: :ref:`Complex Types` +.. |Structure inheritance| replace:: :ref:`Structure inheritance` +.. |Bitset inheritance| replace:: :ref:`Bitset inheritance` +.. |Nested Structures| replace:: :ref:`Nested Structures` +.. |Nested Unions| replace:: :ref:`Nested Unions` -.. |TypeObject| replace:: :ref:`TypeObject` -.. |TypeInformation| replace:: :ref:`TypeInformation` +.. |TypeObject| replace:: :ref:`TypeObject` +.. |TypeInformation| replace:: :ref:`TypeInformation` .. |TopicDataType| replace:: :ref:`TopicDataType` .. |TopicDataTypes| replace:: :ref:`TopicDataTypes` diff --git a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index 2e111cabe..300ee15e6 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -38,7 +38,7 @@ 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. * ``-no-typeobjectsupport``: Avoids building additional files for |TypeObject-api| generation and management (see - :ref:`dynamictypes_discovery_typeobject`). + :ref:`xtypes_discovery_typeobject`). * ``-example``: It generates a basic example of a DDS application and the files to build it for the given ``platform``. Thus, *Fast DDS-Gen* tool can generate a sample application using the provided data type, together with a diff --git a/docs/fastdds/dynamic_types/dynamic_types.rst b/docs/fastdds/dynamic_types/dynamic_types.rst deleted file mode 100644 index 1761a9bea..000000000 --- a/docs/fastdds/dynamic_types/dynamic_types.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. _dynamic-types: - -XTypes 1.3 -========== - -.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 - -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, For more information, refer to the specification for `DDS-XTypes V1.3`_. - -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/discovery_matching.rst - /fastdds/dynamic_types/language_binding.rst diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 7f926e9fd..7e776b0eb 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -34,8 +34,8 @@ 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`. +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 of the types detailed below, an example of how to build the type's XML profile is provided. * `Member types`_ @@ -67,7 +67,7 @@ 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. +Please, refer to :ref:`xtypes_supportedtypes_primitive` for more information on the primitive types. .. list-table:: @@ -108,7 +108,7 @@ All of them are defined as follows: :start-after: //!--CPP_PRIMITIVES :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Primitives `. +For a full example of how to define this type, please refer to :ref:`Primitives `. .. _xmldynamictypes_strings: @@ -117,7 +117,7 @@ Bounded strings 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. +Please, refer to :ref:`xtypes_supportedtypes_string` for more information on string type. .. tabs:: @@ -135,7 +135,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_string` for more information :start-after: //!--CPP_STRINGS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Strings `. +For a full example of how to define this type, please refer to :ref:`Strings `. .. _xmldynamictypes_sequence: @@ -145,7 +145,7 @@ Sequences 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. +Please, refer to :ref:`xtypes_supportedtypes_sequence` section for more information on sequence type. .. tabs:: @@ -163,7 +163,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_sequence` section for more in :start-after: //!--CPP_SEQUENCES :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Sequences `. +For a full example of how to define this type, please refer to :ref:`Sequences `. .. _xmldynamictypes_array: @@ -172,7 +172,7 @@ Arrays 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. +Please, refer to :ref:`xtypes_supportedtypes_array` explanation for more information on array type. .. tabs:: @@ -190,7 +190,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_array` explanation for more i :start-after: //!--CPP_ARRAYS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Arrays `. +For a full example of how to define this type, please refer to :ref:`Arrays `. .. _xmldynamictypes_map: @@ -199,7 +199,7 @@ Maps 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. +See section :ref:`xtypes_supportedtypes_map` for more information on map type. .. tabs:: @@ -217,9 +217,9 @@ See section :ref:`dynamictypes_supportedtypes_map` for more information on map t :start-after: //!--CPP_MAPS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Maps `. +For a full example of how to define this type, please refer to :ref:`Maps `. -.. _xmldynamictypes_complextypes: +.. _xmlxtypes_complextypes: Complex types """"""""""""" @@ -228,7 +228,7 @@ 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. +Please, refer to :ref:`xtypes_complextypes` section for more information on complex types. The following example shows structure having another structure as a member. @@ -248,7 +248,7 @@ The following example shows structure having another structure as a member. :start-after: //!--CPP_COMPLEX_STRUCTS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Nested Types `. +For a full example of how to define this type, please refer to :ref:`Nested Types `. This example shows union having another union as a member. @@ -268,7 +268,7 @@ This example shows union having another union as a member. :start-after: //!--CPP_COMPLEX_UNIONS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Nested Types `. +For a full example of how to define this type, please refer to :ref:`Nested Types `. Complex types attributes ************************ @@ -308,7 +308,7 @@ The ```` XML element is defined by a ``name`` and a ``type`` mandatory 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` +The ```` element corresponds to :ref:`xtypes_supportedtypes_alias` in :ref:`xtypes_supportedtypes` section. .. tabs:: @@ -327,7 +327,7 @@ section. :start-after: //!--CPP_TYPEDEF :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Alias `. +For a full example of how to define this type, please refer to :ref:`Alias `. .. _xmldynamictypes_enums: @@ -336,7 +336,7 @@ Enumerations 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. +Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information on the ```` type. .. tabs:: @@ -354,7 +354,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_enumeration` for more informa :start-after: //!--CPP_ENUM :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Enumerations `. +For a full example of how to define this type, please refer to :ref:`Enumerations `. .. _xmldynamictypes_struct: @@ -362,7 +362,7 @@ Struct """""" 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. +Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on the ```` type. .. tabs:: @@ -380,7 +380,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_structure` for more informati :start-after: //!--CPP_STRUCT :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Structures `. +For a full example of how to define this type, please refer to :ref:`Structures `. .. _xmldynamictypes_struct_inheritance: @@ -405,7 +405,7 @@ This is exemplified by the code snippet below. :start-after: //!--CPP_STRUCT_INHERITANCE :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Structures Inheritance `. +For a full example of how to define this type, please refer to :ref:`Structures Inheritance `. .. _xmldynamictypes_union: @@ -417,7 +417,7 @@ 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. +Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the ```` type. .. tabs:: @@ -435,20 +435,20 @@ Please, refer to :ref:`dynamictypes_supportedtypes_union` for more information o :start-after: //!--CPP_UNION :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Unions `. +For a full example of how to define this type, please refer to :ref:`Unions `. .. _xmldynamictypes_bitset: Bitset """""" -The ```` element defines the :ref:`dynamictypes_supportedtypes_bitset` type. +The ```` element defines the :ref:`xtypes_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. +Please, refer to :ref:`xtypes_supportedtypes_bitset` for more information about the ```` type. .. tabs:: @@ -466,9 +466,9 @@ Please, refer to :ref:`dynamictypes_supportedtypes_bitset` for more information :start-after: //!--CPP_BITSET :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Bitset `. +For a full example of how to define this type, please refer to :ref:`Bitset `. -.. _xmldynamictypes_bitset_inheritance: +.. _xmlxtypes_bitset_inheritance: Moreover, bitsets can inherit from another bitsets. This is implemented by defining the value of the ``baseType`` attribute, on the child ```` element to be the @@ -491,20 +491,20 @@ This is exemplified by the code snippet below. :start-after: //!--CPP_BITSET_INHERITANCE :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Bitset Inheritance `. +For a full example of how to define this type, please refer to :ref:`Bitset Inheritance `. .. _xmldynamictypes_bitmask: Bitmask """"""" -The ```` element, which corresponds to the :ref:`dynamictypes_supportedtypes_bitmask` type, is defined by +The ```` element, which corresponds to the :ref:`xtypes_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. +Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on the ```` type. .. tabs:: @@ -522,7 +522,7 @@ Please, refer to :ref:`dynamictypes_supportedtypes_bitmask` for more information :start-after: //!--CPP_BITMASK :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Bitmasks `. +For a full example of how to define this type, please refer to :ref:`Bitmasks `. .. _Usage: diff --git a/docs/fastdds/dynamic_types/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst similarity index 85% rename from docs/fastdds/dynamic_types/discovery_matching.rst rename to docs/fastdds/xtypes/discovery_matching.rst index 031269029..3d1765efe 100644 --- a/docs/fastdds/dynamic_types/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -1,15 +1,16 @@ .. include:: ../../03-exports/aliases-api.include .. include:: ../../03-exports/aliases.include -.. _dynamictypes_discovery_matching: +.. _xtypes_discovery_matching: -Dynamic Types Discovery and Endpoint Matching -============================================= +Discovery and Endpoint Matching +=============================== -.. _DDS-XTypes V1.3: http://www.omg.org/spec/DDS-XTypes/1.3 +.. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 -When using |DynamicTypes| support, *Fast DDS* checks the optional |TypeInformation-api| -value during endpoint matching. +*eProsima Fast DDS* checks the optional |TypeInformation-api| value during endpoint discovery and matching +to check if the types are known, and in case they are not, +an automatic discovery of the necessary types it is initiated. The process of checking the types is as follows: @@ -21,7 +22,7 @@ The process of checking the types is as follows: * If the discovered participant has not sent |TypeInformation-api|, Fast DDS will utilize a fallback mechanism, using the type name to check if the type is known. Matching will occur if the type is known. -.. _dynamictypes_discovery_typeinformation: +.. _xtypes_discovery_typeinformation: TypeInformation --------------- @@ -35,7 +36,7 @@ This avoids sending the complete data type to Endpoints that may not be interest |TypeInformation-api| is described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. -.. _dynamictypes_discovery_typeobject: +.. _xtypes_discovery_typeobject: TypeObject ---------- @@ -57,7 +58,7 @@ Both are described in the annexes of `DDS-XTypes V1.3`_ document, please refer t Fast DDS-Gen ------------ -*Fast DDS-Gen* default behaviour creates the necessary code to work with *Dynamic Types*. +*Fast DDS-Gen* default behaviour creates the necessary code to work with :ref:`XTypes1.3 `. The generated code will include the `XXXTypeObjecSupport.h` and `XXXTypeObjecSupport.cxx` files, taking :class:`XXX` as our IDL type. These files provide a Type Factory for the type :class:`XXX`. diff --git a/docs/fastdds/dynamic_types/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst similarity index 96% rename from docs/fastdds/dynamic_types/language_binding.rst rename to docs/fastdds/xtypes/language_binding.rst index 1f09efa4d..736d1b970 100644 --- a/docs/fastdds/dynamic_types/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -2,7 +2,7 @@ .. include:: ../../03-exports/aliases-api.include .. include:: ../../03-exports/roles.include -.. _dynamictypes_language_binding: +.. _xtypes_language_binding: Dynamic Language Binding ======================== @@ -19,12 +19,12 @@ from the IDL files. This section contains a detailed explanation of how to create |DynamicTypes| using the manual way, as well as the same examples using XML and IDL files. -.. _dynamictypes_supportedtypes: +.. _xtypes_supportedtypes: Supported Types --------------- -.. _dynamictypes_supportedtypes_primitive: +.. _xtypes_supportedtypes_primitive: Primitives ^^^^^^^^^^ @@ -100,7 +100,7 @@ This examples show how to create members of each primitive type using |DynamicTy For a detailed explanation about the XML definition of this type, please refer to :ref:`Primitives `. -.. _dynamictypes_supportedtypes_string: +.. _xtypes_supportedtypes_string: Strings ^^^^^^^ @@ -145,7 +145,7 @@ Constructed Types Enumerated Types """""""""""""""" -.. _dynamictypes_supportedtypes_enumeration: +.. _xtypes_supportedtypes_enumeration: Enumerations ************ @@ -182,7 +182,7 @@ function for each supported value. For a detailed explanation about the XML definition of this type, please refer to :ref:`Enumerations `. -.. _dynamictypes_supportedtypes_bitmask: +.. _xtypes_supportedtypes_bitmask: Bitmasks ******** @@ -223,7 +223,7 @@ facilitate the creation of this type. For a detailed explanation about the XML definition of this type, please refer to :ref:`Bitmask `. -.. _dynamictypes_supportedtypes_alias: +.. _xtypes_supportedtypes_alias: Alias """"" @@ -261,7 +261,7 @@ the existing type they want the alias to represent. For a detailed explanation about the XML definition of this type, please refer to :ref:`Typedef `. -.. _dynamictypes_complextypes_aliasalias: +.. _xtypes_complextypes_aliasalias: Alias types support recursion, simply by using an alias as base type for :|TypeDescriptor::base_type|. @@ -294,7 +294,7 @@ please refer to :ref:`Primitives `. Collections """"""""""" -.. _dynamictypes_supportedtypes_sequence: +.. _xtypes_supportedtypes_sequence: Sequences ********* @@ -336,7 +336,7 @@ type that allow users to work with multiple values at once. For a detailed explanation about the XML definition of this type, please refer to :ref:`Sequences `. -.. _dynamictypes_supportedtypes_array: +.. _xtypes_supportedtypes_array: Arrays ****** @@ -380,7 +380,7 @@ primitive type that allow users to work with multiple values at once. For a detailed explanation about the XML definition of this type, please refer to :ref:`Arrays `. -.. _dynamictypes_supportedtypes_map: +.. _xtypes_supportedtypes_map: Maps **** @@ -426,7 +426,7 @@ please refer to :ref:`Maps `. Aggregated Types """""""""""""""" -.. _dynamictypes_supportedtypes_structure: +.. _xtypes_supportedtypes_structure: Structures ********** @@ -471,7 +471,7 @@ without calling |DynamicData::return_loaned_value| before. For a detailed explanation about the XML definition of this type, please refer to :ref:`Struct `. -.. _dynamictypes_supportedtypes_union: +.. _xtypes_supportedtypes_union: Unions ****** @@ -512,7 +512,7 @@ member of the union, and |MemberDescriptor::is_default_label| to specify the def For a detailed explanation about the XML definition of this type, please refer to :ref:`Union `. -.. _dynamictypes_supportedtypes_bitset: +.. _xtypes_supportedtypes_bitset: Bitset ****** @@ -568,12 +568,12 @@ The ``TypeKind`` used to identify Bitsets is ``TK_BITSET``. For a detailed explanation about the XML definition of this type, please refer to :ref:`Bitset `. -.. _dynamictypes_complextypes: +.. _xtypes_complextypes: Complex types ^^^^^^^^^^^^^ -In complex data models, combinations of basic types :ref:`basic types` +In complex data models, combinations of basic types :ref:`basic types` can be used to create intricate structures, including nested compositions such as structures within structures. Additionally, types can be extended using inheritance to enhance flexibility. @@ -582,7 +582,7 @@ The following subsections describe these *complex types* and their use. Inheritance """"""""""" -.. _dynamictypes_structure_inheritance: +.. _xtypes_structure_inheritance: Structures allow inheritance, exactly with the same OOP meaning. To inherit from another structure, users must create the parent structure calling the @@ -619,11 +619,11 @@ Structures support several levels of inheritance, so the base class can be anoth For a detailed explanation about the XML definition of this type, please refer to :ref:`Struct `. -.. _dynamictypes_bitset_inheritance: +.. _xtypes_bitset_inheritance: Bitsets allows inheritance aswell, exactly with the same OOP meaning. To inherit from another bitset, users must follow the same process as with -:ref:`structures `, but using bitset types. +:ref:`structures `, but using bitset types. .. tabs:: @@ -649,12 +649,12 @@ To inherit from another bitset, users must follow the same process as with :end-before: //!-- For a detailed explanation about the XML definition of this type, -please refer to :ref:`Bitset `. +please refer to :ref:`Bitset `. Nested Types """""""""""" -.. _dynamictypes_nested_structures: +.. _xtypes_nested_structures: Structures can contain other structures as members. The access to these compound members is restricted and managed by the |DynamicData-api| instance. @@ -685,7 +685,7 @@ The loan operation will fail if the member is already loaned and has not been re :start-after: //!--CPP_COMPLEX_STRUCTS :end-before: //!-- -.. _dynamictypes_nested_unions: +.. _xtypes_nested_unions: Unions support complex type fields. The access to these complex type fields is restricted and managed by the |DynamicData-api| instance. @@ -718,7 +718,7 @@ The loan operation will fail if the fields is already loaned and has not been re For a detailed explanation about the XML definition of this types, -please refer to :ref:`Complex types `. +please refer to :ref:`Complex types `. Annotations ^^^^^^^^^^^ diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst new file mode 100644 index 000000000..4717cd066 --- /dev/null +++ b/docs/fastdds/xtypes/xtypes.rst @@ -0,0 +1,27 @@ +.. _dynamic-types: + +XTypes 1.3 +========== + +.. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 + +*eProsima Fast DDS* manages :ref:`Discovery and Endpoint Matching ` +using |TypeInformation-api| and |TypeObject-api| when posible. +It checks that the types are known, initiating a type discovery process if necessary +before matching with other participants. +Alternatively, it uses a fallback mechanism based on type names when |TypeInformation-api| is unavailable. + +*eProsima Fast DDS* provides a dynamic way to define and use topic types and topic data. +The :ref:`Dynamic Language Binding ` 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. + +This implementation follows the *OMG Extensible and Dynamic Topic Types for DDS interface*. +For more information, refer to the specification for `DDS-XTypes V1.3`_. + +.. toctree:: + :maxdepth: 3 + + /fastdds/xtypes/discovery_matching.rst + /fastdds/xtypes/language_binding.rst 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 From 693c13bbe3a580fd7535cca084a4248abe224a20 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Wed, 20 Mar 2024 07:38:52 +0100 Subject: [PATCH 06/23] Refs #20359: Updates to discovery and endpoint matching. Signed-off-by: adriancampo --- docs/fastdds/xtypes/discovery_matching.rst | 95 +++++++++++++++------- docs/fastdds/xtypes/xtypes.rst | 2 + 2 files changed, 67 insertions(+), 30 deletions(-) diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index 3d1765efe..d03aa993e 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -8,30 +8,51 @@ Discovery and Endpoint Matching .. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 -*eProsima Fast DDS* checks the optional |TypeInformation-api| value during endpoint discovery and matching -to check if the types are known, and in case they are not, -an automatic discovery of the necessary types it is initiated. +*eProsima Fast DDS* incorporates advanced type discovery mechanisms for endpoint discovery and matching, +leveraging the optional |TypeInformation-api| value to ensure compatibility between communicating Endpoints. +Upon the discovery of a participant, *eProsima Fast DDS* examines the |TypeInformation-api| to determine +the availability of essential data type information. The process of checking the types is as follows: -* If the discovered participant has sent |TypeInformation-api|, Fast DDS will check if all required types are known. - If not, it will initiate an automatic process of discovering the necessary types, using |TypeObject-api| - to communicate the information about the types with the other participants. - This process occurs asynchronously, and the matching of the discovered participant will not occur - until all necessary types are known, and they are fully compatible. -* If the discovered participant has not sent |TypeInformation-api|, Fast DDS will utilize a fallback mechanism, - using the type name to check if the type is known. Matching will occur if the type is known. +1. **Evaluation of TypeInformation**: If the discovered participant has transmitted |TypeInformation-api|, + *eProsima Fast DDS* evaluates whether all required types are already known. + In cases where some types are missing, an automatic process to discover the necessary types is initiated. + Utilizing |TypeObject-api| to communicate with other participants and discover the topic types asynchronously. + Matching of the discovered participant is deferred until all necessary types are known. + +2. **Fallback Mechanism**: In scenarios where the discovered participant has not transmitted |TypeInformation-api|, + *eProsima Fast DDS* resorts to a fallback mechanism. + It utilizes the type name to verify if the type is already known within the system. + If the type name is recognized, matching occurs. .. _xtypes_discovery_typeinformation: TypeInformation --------------- -|TypeInformation-api| is an extension of *XTypes 1.3* 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 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 a fundamental component of the *XTypes 1.3* specification, facilitating the efficient exchange +of essential data type information between DDS Endpoints. +Instead of transmitting the entire |TypeObject|, Endpoints share a compact representation containing the |TypeIdV1-api| +of the respective data type. +The exchanged |TypeIdV1-api| serve as unique identifiers for the associated data types, allowing Endpoints to verify +compatibility and also facilitate subsequent retrieval of the necessary |TypeObject-api| for the data types needed, +enhancing interoperability without burdening non-interested Endpoints with unnecessary data. + +This approach significantly reduces network overhead, especially when communicating with Endpoints that may +not require the complete type definition. + +The contents of TypeInformation include: + +* |TypeIdV1-api|: This is the core component of TypeInformation, + representing the unique identifier of the data type associated with the Endpoint. + It enables Endpoints to identify and verify the compatibility of data types during communication. + +* Dependency Information: Optionally, TypeInformation may include dependency information, + indicating other data types on which the current data type depends. + This information aids Endpoints in understanding the data type hierarchy and its dependencies, + facilitating comprehensive compatibility checks. The decision regarding which types to include in the + dependency information of TypeInformation is left to the implementation. |TypeInformation-api| is described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. @@ -41,27 +62,41 @@ please refer to this document for details. TypeObject ---------- +The *XTypes* type system uniquely identifies any possible type with a TypeIdentifier. +For simple types such as primitive types, strings, or certain sequences of primitives, +the TypeIdentifier fully describes the type. +However, for more complex types, the TypeIdentifier only serves to identify the type, +and its complete description requires a TypeObject. + |TypeObject-api| provides a thorough description of a data type, similar to how it's represented in IDL. There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`MinimalTypeObject`. - - :class:`CompleteTypeObject` is representation of a type with the same level of detail and expressiveness as in IDL. - It serves as an alternative representation of types, suitable for programming and tooling purposes. +- :class:`CompleteTypeObject` mirrors the expressiveness of types represented in IDL or XML. + It can accurately represent any non-plain type from IDL without information loss, + except for formatting differences. + This representation is well-suited for programming and tooling purposes. - - :class:`MinimalTypeObject` is a simplified version of the data type. - It includes only the necessary information for remote Endpoints to interpret the data accurately. - This simplified representation excludes details such as user-defined annotations or member order for types with - extensibility kind MUTABLE, which are irrelevant for type assignability. - By doing so, it reduces the amount of information applications need to transmit over the network. +- :class:`MinimalTypeObject` offers a simplified representation of a data type, + containing only essential information for remote Endpoints to interpret the data accurately. + This representation excludes details such as user-defined annotations or member order for types with + extensibility kind MUTABLE, which do not affect type assignability. + By minimizing redundant information, MinimalTypeObject reduces network overhead during type compatibility + checks between DataWriters and DataReaders. -TypeObject is an IDL union with both *Minimal* and *Complete* representation. -Both are described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. +Both :class:`CompleteTypeObject` and :class:`MinimalTypeObject` are defined in the annexes of the `DDS-XTypes V1.3`_ +document, providing detailed specifications and IDL representations. Fast DDS-Gen ------------ -*Fast DDS-Gen* default behaviour creates the necessary code to work with :ref:`XTypes1.3 `. -The generated code will include the `XXXTypeObjecSupport.h` and `XXXTypeObjecSupport.cxx` files, -taking :class:`XXX` as our IDL type. -These files provide a Type Factory for the type :class:`XXX`. -Generally, these files are not used directly, as the type :class:`XXX` will register itself. -*Fast DDS-Gen* usage information can be found on the :ref:`Fast DDS-Gen ` section. +*Fast DDS-Gen* default behaviour generates code compatible with :ref:`XTypes1.3 `. +When processing an IDL file, it will automatically generate all the code files needed for the data types. + +For instance, assuming the IDL file is named *"Mytype"*, the generated files include: + +- *MyType.hpp*: This file contains the definition of the data type. +- *MyTypePubSubType.cxx/.h*: Serialization and deserialization source code for the data type. +- *MyTypeTypeObjectSupport.cxx/.hpp*: Generation and registration of |TypeObject-api|. + +Detailed usage instructions and additional information about *Fast DDS-Gen* can be found in the +:ref:`Fast DDS-Gen ` section. diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index 4717cd066..e3a97d92e 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -1,3 +1,5 @@ +.. include:: ../../03-exports/aliases-api.include + .. _dynamic-types: XTypes 1.3 From b9389cfee7805837e1f5824acb392422f73dd577 Mon Sep 17 00:00:00 2001 From: Adrian del Campo <107918259+adriancampo@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:02:05 +0100 Subject: [PATCH 07/23] Refs #20359: Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ricardo González Signed-off-by: adriancampo --- code/DDSCodeTester.cpp | 166 ++++++++-------- docs/03-exports/aliases-api.include | 1 + .../dds_pim/xtypes/dynamic_types.rst | 16 -- docs/fastdds/xtypes/discovery_matching.rst | 58 +++--- docs/fastdds/xtypes/language_binding.rst | 184 +++++++++++++----- docs/fastdds/xtypes/xtypes.rst | 8 +- 6 files changed, 257 insertions(+), 176 deletions(-) diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index f7bbe6c0d..ea40bd26c 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -161,7 +161,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener } void on_participant_discovery( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::ParticipantDiscoveryInfo&& info, bool& should_be_ignored) override { @@ -186,7 +186,7 @@ class CustomDomainParticipantListener : public DomainParticipantListener #if HAVE_SECURITY void onParticipantAuthentication( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::ParticipantAuthenticationInfo&& info) override { if (info.status == eprosima::fastrtps::rtps::ParticipantAuthenticationInfo::AUTHORIZED_PARTICIPANT) @@ -202,9 +202,9 @@ class CustomDomainParticipantListener : public DomainParticipantListener #endif // if HAVE_SECURITY void on_data_reader_discovery( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, - bool& /*should_be_ignored*/) override + bool& should_be_ignored) override { if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER) { @@ -217,9 +217,9 @@ class CustomDomainParticipantListener : public DomainParticipantListener } void on_data_writer_discovery( - DomainParticipant* /*participant*/, + DomainParticipant* participant, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, - bool& /*should_be_ignored*/) override + bool& should_be_ignored) override { if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER) { @@ -930,7 +930,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener void on_data_reader_discovery( DomainParticipant* participant, eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, - bool& /*should_be_ignored*/) override + bool& should_be_ignored) override { static_cast(participant); switch (info.status){ @@ -954,7 +954,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener void on_data_writer_discovery( DomainParticipant* participant, eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, - bool& /*should_be_ignored*/) override + bool& should_be_ignored) override { static_cast(participant); switch (info.status){ @@ -1363,21 +1363,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(); } @@ -1388,14 +1388,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; } @@ -2014,7 +2014,7 @@ void dds_custom_filters_examples() { deser >> index; } - catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& exception) { return false; } @@ -2497,7 +2497,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 << @@ -3299,7 +3299,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 << @@ -4427,7 +4427,7 @@ void dynamictypes_examples() // Define a struct type with various primitive members TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("PrimitivesStruct")); + type_descriptor->name("PrimitivesStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; @@ -4488,8 +4488,8 @@ void dynamictypes_examples() // 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(ObjectName("my_long")), in_value); - data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_long"))); + 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")); //!-- } { @@ -4497,7 +4497,7 @@ void dynamictypes_examples() // Define a struct type to contain the strings TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("StringsStruct")); + type_descriptor->name("StringsStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; @@ -4506,11 +4506,11 @@ void dynamictypes_examples() member_descriptor->name("my_string"); member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - create_string_type(LENGTH_UNLIMITED)->build()); + create_string_type(static_cast(LENGTH_UNLIMITED))->build()); struct_builder->add_member(member_descriptor); member_descriptor->name("my_wstring"); member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - create_wstring_type(LENGTH_UNLIMITED)->build()); + create_wstring_type(static_cast(LENGTH_UNLIMITED))->build()); struct_builder->add_member(member_descriptor); member_descriptor->name("my_bounded_string"); member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> @@ -4529,8 +4529,8 @@ void dynamictypes_examples() // 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(ObjectName("my_string")), in_value); - data->get_string_value(out_value, data->get_member_id_by_name(ObjectName("my_string"))); + 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")); //!-- } { @@ -4538,7 +4538,7 @@ void dynamictypes_examples() // Define a struct type to contain an enum TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("EnumStruct")); + type_descriptor->name("EnumStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define the enum type @@ -4548,18 +4548,18 @@ void dynamictypes_examples() DynamicTypeBuilder::_ref_type enum_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(enum_type_descriptor)}; // Add enum members to the enum type - MemberDescriptor::_ref_type union_member_descriptor {traits::make_shared()}; - union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); - union_member_descriptor->name("A"); - enum_builder->add_member(union_member_descriptor); - union_member_descriptor = traits::make_shared(); - union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); - union_member_descriptor->name("B"); - enum_builder->add_member(union_member_descriptor); - union_member_descriptor = traits::make_shared(); - union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT32)); - union_member_descriptor->name("C"); - enum_builder->add_member(union_member_descriptor); + 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(); @@ -4574,10 +4574,10 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for an enum member - int32_t in_value = 2; - int32_t out_value = 0; - data->set_int32_value(data->get_member_id_by_name(ObjectName("my_enum")), in_value); - data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_enum"))); + uint32_t in_value = 2; + 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")); //!-- } { @@ -4585,7 +4585,7 @@ void dynamictypes_examples() // Define a struct type to contain a bitmask TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("BitmaskStruct")); + type_descriptor->name("BitmaskStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; @@ -4598,6 +4598,10 @@ void dynamictypes_examples() bitmask_type_descriptor->bound().push_back(8); DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_type( bitmask_type_descriptor)}; + /* Alternative + DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_bitmask_type(8)}; + */ + // 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)); @@ -4632,20 +4636,21 @@ void dynamictypes_examples() // 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 bitmask member - bool in_value = 2; - bool out_value = 0; - data->set_boolean_value(data->get_member_id_by_name(ObjectName("my_bitmask")), in_value); - data->get_boolean_value(out_value, data->get_member_id_by_name(ObjectName("my_bitmask"))); + // Set and retrieve values for bitmask member. + uint8_t in_value = 2; + 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")); //!-- } { + // Type created as described in enumeration type section. 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(ObjectName("AliasStruct")); + type_descriptor->name("AliasStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define an alias type for the enum @@ -4689,8 +4694,8 @@ void dynamictypes_examples() // Set and retrieve values for the alias enum member int32_t in_value = 2; int32_t out_value = 0; - data->set_int32_value(data->get_member_id_by_name(ObjectName("my_alias_enum")), in_value); - data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_alias_enum"))); + 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")); //!-- } { @@ -4698,13 +4703,13 @@ void dynamictypes_examples() // Define a struct type to contain the alias TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("RecursiveAliasStruct")); + type_descriptor->name("RecursiveAliasStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define an alias type for base type type_descriptor = traits::make_shared(); type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); - type_descriptor->name(ObjectName("RecursiveAlias")); + type_descriptor->name("RecursiveAlias"); type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> get_primitive_type(eprosima::fastdds::dds::TK_UINT32)); DynamicTypeBuilder::_ref_type builder {DynamicTypeBuilderFactory::get_instance()-> @@ -4714,7 +4719,7 @@ void dynamictypes_examples() type_descriptor = traits::make_shared(); type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); - type_descriptor->name(ObjectName("MyAlias")); + type_descriptor->name("MyAlias"); type_descriptor->base_type(rec_type); builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); // Build the alias type for other alias @@ -4731,10 +4736,10 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for the alias member - int32_t in_value = 2; - int32_t out_value = 0; - data->set_int32_value(data->get_member_id_by_name(ObjectName("my_alias")), in_value); - data->get_int32_value(out_value, data->get_member_id_by_name(ObjectName("my_alias"))); + uint32_t in_value = 2; + uint32_t out_value = 0; + data->set_uint32_value(data->get_member_id_by_name("my_alias"), in_value); + data->get_uint32_value(out_value, data->get_member_id_by_name("my_alias")); //!-- } { @@ -4742,7 +4747,7 @@ void dynamictypes_examples() // Define a struct type to contain the array TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("ArrayStruct")); + type_descriptor->name("ArrayStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define a member for the array @@ -4759,10 +4764,10 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for the array member - Int32Seq in_value = {1, 2}; + 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(ObjectName("long_array")), in_value); - data->get_int32_values(out_value, data->get_member_id_by_name(ObjectName("long_array"))); + 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")); //!-- } { @@ -4770,7 +4775,7 @@ void dynamictypes_examples() // Define a struct type to contain the sequence TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("SequenceStruct")); + type_descriptor->name("SequenceStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define a member for the sequence @@ -4788,8 +4793,8 @@ void dynamictypes_examples() // 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(ObjectName("short_sequence")), in_value); - data->get_int16_values(out_value, data->get_member_id_by_name(ObjectName("short_sequence"))); + 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")); //!-- } { @@ -4797,7 +4802,7 @@ void dynamictypes_examples() // Define a struct type to contain the map TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; type_descriptor->kind(TK_STRUCTURE); - type_descriptor->name(ObjectName("MapStruct")); + type_descriptor->name("MapStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; // Define a member for the map @@ -4853,11 +4858,12 @@ void dynamictypes_examples() // Set and retrieve values for the member const int32_t value1 = 2; int32_t value2 = 0; - data->set_int32_value(data->get_member_id_by_name(ObjectName("first")), value1); - data->get_int32_value(value2, data->get_member_id_by_name(ObjectName("first"))); + data->set_int32_value(data->get_member_id_by_name("first"), value1); + data->get_int32_value(value2, data->get_member_id_by_name("first")); //!-- } { + // Skipped this type creation. Same as in previous section. DynamicType::_ref_type mystruct_type; //!--CPP_UNION // Define a struct type to contain the union @@ -6483,21 +6489,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(); } @@ -6508,14 +6514,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; } diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index ff4adc0ea..3770e5d63 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -953,6 +953,7 @@ .. |AnnotationDescriptor-api| replace:: :cpp:class:`AnnotationDescriptor ` .. |DynamicData-api| replace:: :cpp:class:`DynamicData ` +.. |DynamicData::get_member_id_by_name| replace:: :cpp:func:`DynamicData::get_member_id_by_name ` .. |DynamicData::loan_value| replace:: :cpp:func:`DynamicData::loan_value ` .. |DynamicData::return_loaned_value| replace:: :cpp:func:`DynamicData::return_loaned_value ` .. |DynamicDataFactory-api| replace:: :cpp:class:`DynamicDataFactory ` diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst index bffd71c64..1802207a9 100644 --- a/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst @@ -14,19 +14,3 @@ Dynamic Types /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/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index d03aa993e..95e18eb43 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -8,22 +8,22 @@ Discovery and Endpoint Matching .. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 -*eProsima Fast DDS* incorporates advanced type discovery mechanisms for endpoint discovery and matching, -leveraging the optional |TypeInformation-api| value to ensure compatibility between communicating Endpoints. -Upon the discovery of a participant, *eProsima Fast DDS* examines the |TypeInformation-api| to determine +*eProsima Fast DDS* incorporates an advanced type discovery service used on endpoint discovery and matching. +Discovery process leverages the optional |TypeInformation-api| value to ensure compatibility between communicating endpoints. +Upon the discovery of a remote endpoint, *eProsima Fast DDS* examines the |TypeInformation-api| to determine the availability of essential data type information. The process of checking the types is as follows: -1. **Evaluation of TypeInformation**: If the discovered participant has transmitted |TypeInformation-api|, +1. **Evaluation of TypeInformation**: If the discovered enpoint has transmitted |TypeInformation-api|, *eProsima Fast DDS* evaluates whether all required types are already known. In cases where some types are missing, an automatic process to discover the necessary types is initiated. - Utilizing |TypeObject-api| to communicate with other participants and discover the topic types asynchronously. - Matching of the discovered participant is deferred until all necessary types are known. + |TypeObject-api| is used to communicate with other participants and to discover the topic types asynchronously. + Matching of the discovered enpoint is deferred until all necessary types are known. -2. **Fallback Mechanism**: In scenarios where the discovered participant has not transmitted |TypeInformation-api|, +2. **Fallback Mechanism**: In scenarios where the discovered endpoint has not transmitted |TypeInformation-api|, *eProsima Fast DDS* resorts to a fallback mechanism. - It utilizes the type name to verify if the type is already known within the system. + This mechanism relys on the type name to verify if the type is already known within the system. If the type name is recognized, matching occurs. .. _xtypes_discovery_typeinformation: @@ -32,27 +32,27 @@ TypeInformation --------------- |TypeInformation-api| is a fundamental component of the *XTypes 1.3* specification, facilitating the efficient exchange -of essential data type information between DDS Endpoints. -Instead of transmitting the entire |TypeObject|, Endpoints share a compact representation containing the |TypeIdV1-api| +of essential data type information between DDS endpoints. +Instead of transmitting the entire |TypeObject|, endpoints share a compact representation containing the |TypeIdV1-api| of the respective data type. -The exchanged |TypeIdV1-api| serve as unique identifiers for the associated data types, allowing Endpoints to verify -compatibility and also facilitate subsequent retrieval of the necessary |TypeObject-api| for the data types needed, -enhancing interoperability without burdening non-interested Endpoints with unnecessary data. +The exchanged |TypeIdV1-api| serves as unique identifiers for the associated data types, allowing endpoints to verify +compatibility and also to facilitate subsequent retrieval of the necessary |TypeObject-api| for the data types needed, +This mechanism enhances interoperability without burdening non-interested endpoints with unnecessary data. -This approach significantly reduces network overhead, especially when communicating with Endpoints that may +This approach significantly reduces network overhead, especially when communicating with endpoints that may not require the complete type definition. The contents of TypeInformation include: -* |TypeIdV1-api|: This is the core component of TypeInformation, - representing the unique identifier of the data type associated with the Endpoint. - It enables Endpoints to identify and verify the compatibility of data types during communication. +* |TypeIdV1-api|: This is the core component of TypeInformation. + It represents the unique identifier of the data type associated with the endpoint and + enables endpoints to identify and verify the compatibility of data types during communication. -* Dependency Information: Optionally, TypeInformation may include dependency information, - indicating other data types on which the current data type depends. - This information aids Endpoints in understanding the data type hierarchy and its dependencies, - facilitating comprehensive compatibility checks. The decision regarding which types to include in the - dependency information of TypeInformation is left to the implementation. +* Dependency Information: Optionally, TypeInformation may include dependency information, which + indicates other data types on which the current data type depends. + This information helps endpoints understand the data type hierarchy and its dependencies, + which facilitates comprehensive compatibility checks. + The decision as to which types to include in the dependency information is left to the implementation. |TypeInformation-api| is described in the annexes of `DDS-XTypes V1.3`_ document, please refer to this document for details. @@ -62,11 +62,11 @@ please refer to this document for details. TypeObject ---------- -The *XTypes* type system uniquely identifies any possible type with a TypeIdentifier. -For simple types such as primitive types, strings, or certain sequences of primitives, +The *XTypes* type system uniquely identifies each possible type with a TypeIdentifier. +For simple types, such as primitive types, strings, or certain sequences of primitives, the TypeIdentifier fully describes the type. -However, for more complex types, the TypeIdentifier only serves to identify the type, -and its complete description requires a TypeObject. +For more complex types, however, the TypeIdentifier only serves to identify the type, +and its full description requires a TypeObject. |TypeObject-api| provides a thorough description of a data type, similar to how it's represented in IDL. There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`MinimalTypeObject`. @@ -76,10 +76,10 @@ There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`Mini except for formatting differences. This representation is well-suited for programming and tooling purposes. -- :class:`MinimalTypeObject` offers a simplified representation of a data type, - containing only essential information for remote Endpoints to interpret the data accurately. +- :class:`MinimalTypeObject` provides a simplified representation of a data type, + that contains only the information necessary for remote endpoints to interpret the data correctly. This representation excludes details such as user-defined annotations or member order for types with - extensibility kind MUTABLE, which do not affect type assignability. + extensibility kind MUTABLE, which do not affect the type assignability. By minimizing redundant information, MinimalTypeObject reduces network overhead during type compatibility checks between DataWriters and DataReaders. diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index 736d1b970..48aed4612 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -7,17 +7,92 @@ Dynamic Language Binding ======================== -*eProsima Fast DDS* supports several methods for defining |DynamicTypes|. +*eProsima Fast DDS* supports several methods to define |DynamicTypes|. Manual creation using |DynamicTypeBuilderFactory-api| and |DynamicTypeBuilder-api| to create the types. -:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes directly defining -them through XML. +:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes by defining +them directly through XML. -:ref:`Fast DDS-Gen ` provides a way to automatically generate the code to define the |DynamicTypes| -from the IDL files. +This section contains an small description of the interfaces used to work with |DynamicTypes| and a detailed +explanation of how to create |DynamicTypes| in the manual way, as well as the same examples using XML files. -This section contains a detailed explanation of how to create |DynamicTypes| using the manual way, as well as the -same examples using XML and IDL files. +.. _xtypes_intenfaces: + +Dynamic Types Interfaces +------------------------ + +DynamicTypeBuilderFactory +^^^^^^^^^^^^^^^^^^^^^^^^^ +The |DynamicTypeBuilderFactory-api| serves as a singleton wich isntance is responsible for creating |DynamicTypes| and +serves as the entry point for both creating and deleting |DynamicTypeBuilder-api| objects. +The simpler types can be directly instantiated without the need for a DynamicTypeBuilder. +Refer to the Supported Types documentation for details on which types support this direct creation option. + +AnnotationDescriptor +^^^^^^^^^^^^^^^^^^^^ +|AnnotationDescriptor-api| encapsulates the state of an annotation when applied to an element (not an annotation type). + +TypeDescriptor +^^^^^^^^^^^^^^ +|TypeDescriptor-api| stores the state of a type, including its structure, relationships, and constraints. +As the class responsible for describing the inner structure of a DynamicType, +When the DynamicType is created, DynamicTypeBuilderFactory utilizes the information from the TypeDescriptor to +instantiate the DynamicType. +This information is then copied to the DynamicType during creation, gaining independence from the DynamicTypeBuilder + +so the builder can be reused for another type. + +DynamicTypeMember +^^^^^^^^^^^^^^^^^ +|DynamicTypeMember-api| represents a data member of a DynamicType that itself is a DynamicType. +Dynamic types that are composed of other dynamic types have a DynamicTypeMember for every child +DynamicType added to it. +Functioning as the representation of a "member" of a type, it may be a member of an aggregate type, +or constants within enumerations, or other types of substructure. + +MemberDescriptor +^^^^^^^^^^^^^^^^ +|MemberDescriptor-api| encapsulates the state of a DynamicTypeMember. +Analogous to TypeDescriptor's role in describing the inner structure of a DynamicType, MemberDescriptor +stores all essential information for managing a DynamicTypeMember. +This information, including member name, unique ID, and default value, is copied to the DynamicData +upon its creation. + +DynamicType +^^^^^^^^^^^ +|DynamicType-api| objects represent a type's schema, including its name, type kind, and member definitions. +As the base class for all dynamically declared types, it is the representation of a dynamic data type used +for creating DynamicData values. +Once created, the structure of a DynamicType cannot be modified. + +DynamicTypeBuilder +^^^^^^^^^^^^^^^^^^ +|DynamicTypeBuilder-api| represents the transitional state of a type defined in the Type System. +It enables the instantiation of concrete DynamicType objects and serves as an intermediary for configuring a +DynamicType before its creation. +A DynamicType's composition must be defined before its creation, with the builder facilitating this setup, +and its structure cannot be modified once the object is created. +Upon definition, DynamicTypeBuilderFactory leverages the information contained in the builder to create +the DynamicType. +The builder offers a :func:`build` function for convenient creation of a fully constructed DynamicType, +utilizing DynamicTypeBuilderFactory internally. +Builders remain reusable after DynamicType creation, ensuring changes to the builder do not affect previously +created types. + +DynamicDataFactory +^^^^^^^^^^^^^^^^^^ +|DynamicDataFactory-api|, logically a singleton, oversees the creation of DynamicData objects. +As the sole entry point for creating and deleting DynamicData and objects, it operates similarly to the singleton +DomainParticipantFactory. +This singleton class manages every DynamicData instance, capable of generating an instance corresponding to a specified +DynamicType. + +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: @@ -29,17 +104,17 @@ Supported Types Primitives ^^^^^^^^^^ -By definition, primitive types are self-described and can be created without configuration parameters. -Therefore, |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| -to allow users to create the type avoiding the |DynamicTypeBuilder-api| step. -The |DynamicData-api| class has a specific :func:`get__value` and :func:`set__value` functions for each primitive -type of the list. +By definition, primitive types are self-describing and can be created without configuration parameters. +Therefore, the |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| +to allow users to create the type bypassing the |DynamicTypeBuilder-api| step. +The |DynamicData-api| class has a specific :func:`get_value` and :func:`set_value` functions for each primitive +type in the list. The following table shows the supported primitive types and their corresponding ``TypeKind``. -The ``TypeKind`` is used to identify the type when creating it. +The ``TypeKind`` is used to identify the type when it is created. +------------------+-------------------+ -| Type | TypeKind | +| C++ Type | TypeKind | +------------------+-------------------+ | ``BOOLEAN`` | ``TK_BOOLEAN`` | +------------------+-------------------+ @@ -72,7 +147,7 @@ The ``TypeKind`` is used to identify the type when creating it. | ``FLOAT128`` | ``TK_FLOAT128`` | +------------------+-------------------+ -This examples show how to create members of each primitive type using |DynamicTypeBuilderFactory-api|. +This example shows how to create members of each primitive type using |DynamicTypeBuilderFactory-api|. .. tabs:: @@ -105,12 +180,12 @@ please refer to :ref:`Primitives `. Strings ^^^^^^^ -Strings are pretty similar to primitive types, the main difference being that they need to set their size limit. +Strings are quite similar to primitive types, the main difference being that they need to set their size limit. -|DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and -|DynamicTypeBuilderFactory::create_wstring_type| to allow users create them directly. -This functions receive a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` -to set it as unlimited. +The |DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and +|DynamicTypeBuilderFactory::create_wstring_type| to allow users to create them directly. +These functions take a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` +to set it to unlimited. The |DynamicData-api| class has a specific :func:`get_string_value` and :func:`set_string_value`. .. tabs:: @@ -154,7 +229,10 @@ An enumeration contains a set of supported values and a selected value among tho The ``TypeKind`` used to identify Enumerations is ``TK_ENUM``. The supported values must be configured using the |DynamicTypeBuilder-api|, using the |DynamicTypeBuilder::add_member| -function for each supported value. +function for the respective supported values. +The type to which the enumeration will be bound to is determined the first time +|DynamicTypeBuilder::add_member| is invoked by taking the type of that member. +Subsequently added members must follow the same type. .. tabs:: @@ -187,15 +265,16 @@ please refer to :ref:`Enumerations `. Bitmasks ******** -Bitmasks are similar to |Enumeration| types, but their members work as bit flags that can be individually turned on and -off. +Bitmasks are similar to |Enumeration| types, but their members act as bit flags that can be turned on and +off individually. The ``TypeKind`` used to identify Bitmasks is ``TK_BITMASK``. -Those flags might use the ``positition`` attribute to set their position in the bitmask. -The ``bit_bound`` attribute specifies the number of bits that the bitmask type will manage. +These flags might use the ``id`` attribute to set their position in the bitmask. +The ``bound`` attribute specifies the number of bits that the bitmask type will manage. Bitmasks can be bound to any number of bits up to 64. The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to facilitate the creation of this type. +The members added to a bitmask using |DynamicTypeBuilder::add_member| must be of type ``TK_BOOLEAN``. .. tabs:: @@ -299,16 +378,16 @@ Collections Sequences ********* -A complex type that manages its members as a list of items allowing users to insert, +A complex type that manages its members as a list of elements allowing users to insert, remove or access to a member of the list. The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to facilitate the creation of this type. -To create this type users need to specify the type that it is going to store. +To create this type, the user must specify the type to be stored. Additionally, the size limit of the list. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. -The |DynamicData-api| class has a specific :func:`get__values` and :func:`set__values` functions for each primitive -type that allow users to work with multiple values at once. +The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive +type, allowing users to work with multiple values at once. .. tabs:: @@ -341,17 +420,17 @@ please refer to :ref:`Sequences `. Arrays ****** -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. +Arrays are very similar to sequences with two main differences: +They can have multiple dimensions and their elements are initialized to the default value at the start. -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. +An array needs to know the number of dimensions it maanges. +The user must provide a vector with as many elements as there are dimensions in the array. Each element in the vector represents the size of the given dimension. The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to facilitate the creation of this type. -The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each +The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive type that allow users to work with multiple values at once. .. tabs:: @@ -389,7 +468,7 @@ Maps contain a list of 'key-value' pair types, allowing users to insert, remove 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. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_map_type| to +The |DynamicTypeBuilderFactory-api| exposes the |DynamicTypeBuilderFactory::create_map_type| function to facilitate the creation of this type. To create a map, users must set the types of the key and the value elements. Additionally, the size limit of the map. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. @@ -397,6 +476,11 @@ Additionally, the size limit of the map. Users can use ``LENGTH_UNLIMITED`` to c The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each primitive type that allow users to work with multiple values at once. +To access the members of the map using the keys, users can use the |DynamicData::get_member_id_by_name| function to get +the ``MemberId`` of the desired element key, and use it to modify the value of said element. +Note that parameter used in |DynamicData::get_member_id_by_name| as the key name, must be the correct ``string`` +representation of the value of the key. + .. tabs:: .. tab:: IDL @@ -431,17 +515,17 @@ Aggregated Types Structures ********** -Structures are the most common complex types, they allow to add any kind of members inside them. +Structures are the most common aggregated types, they allow any kind of members to be added inside them. They do not have any value, they are only used to contain other types. The function |DynamicTypeBuilderFactory::create_type| is used to create a new structure type. -The ``TypeKind`` used to identify Structures is ``TK_STRUCTURE``. +The ``TypeKind`` used to identify structures is ``TK_STRUCTURE``. 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``. +kind of the type inside the structure using its ``id``. If the structure contains a complex value, |DynamicData::loan_value| should be used to access it and -|DynamicData::return_loaned_value| to release that loan. -|DynamicData-api| manages the loaned values and users can not loan a value that has been loaned previously +|DynamicData::return_loaned_value| should be used to release that loan. +|DynamicData-api| manages the loaned values and users cannot loan a previously loaned value without calling |DynamicData::return_loaned_value| before. @@ -476,15 +560,21 @@ please refer to :ref:`Struct `. Unions ****** -Unions are a special kind of structures where only one of the members is active at the same time. -The ``TypeKind`` used to identify Unions is ``TK_UNION``. +Unions are a special type of structure where only one of the members is active at a time. +The ``TypeKind`` used to identify unions is ``TK_UNION``. To control these members, users must set the ``discriminator`` type that is going to be used to select the current -member calling the |TypeDescriptor::discriminator_type| function of the union type. -The ``discriminator`` itself is a DynamicType of any primitive type, string type or union type. - -Additionally users can use the function |MemberDescriptor::label| with one or more values to set the labels of each -member of the union, and |MemberDescriptor::is_default_label| to specify the default label of the union. +member by calling the |TypeDescriptor::discriminator_type| function of the union type. +The ``discriminator`` itself is a DynamicType that must be of any of the following types: +- Boolean. +- Byte. +- Char8, Char16. +- Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64. +- An enumerated type. +- Any alias type that resolves, directly or indirectly, to one of the aforementioned types. + +In addition, users can use the |MemberDescriptor::label| function with one or more values to set the labels of each +member of the union, and |MemberDescriptor::is_default_label| to set the default label of the union. .. tabs:: diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index e3a97d92e..58f130261 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -9,14 +9,14 @@ XTypes 1.3 *eProsima Fast DDS* manages :ref:`Discovery and Endpoint Matching ` using |TypeInformation-api| and |TypeObject-api| when posible. -It checks that the types are known, initiating a type discovery process if necessary -before matching with other participants. +When remote endpoints are discovered, it checks that the types are known, initiating a type discovery process if necessary +before the matching between the endpoints takes place. Alternatively, it uses a fallback mechanism based on type names when |TypeInformation-api| is unavailable. *eProsima Fast DDS* provides a dynamic way to define and use topic types and topic data. -The :ref:`Dynamic Language Binding ` offer the possibility to work over RTPS +The :ref:`Dynamic Language Binding ` offers the possibility to work over DDS/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, +The users can declare the different types that they need and manage the information on runtime, avoiding the additional step of updating the IDL file and the generation of *C++* classes. This implementation follows the *OMG Extensible and Dynamic Topic Types for DDS interface*. From 0ece561a2fae7499e1dd828d545c3f1e09f47314 Mon Sep 17 00:00:00 2001 From: adriancampo Date: Thu, 4 Apr 2024 09:11:05 +0200 Subject: [PATCH 08/23] Refs #20359: Regenerated example types. Removed classes after monitor service refactor. Signed-off-by: adriancampo --- code/CodeTester.cpp | 2 +- code/DDSCodeTester.cpp | 2 +- .../C++/DDSHelloWorld/src/HelloWorldv1.cxx | 286 ------------------ .../C++/DDSHelloWorld/src/HelloWorldv1.h | 244 --------------- docs/03-exports/aliases-api.include | 1 - .../dds_pim/core/status/ddsentitystatus.rst | 10 - .../dds_pim/core/status/status.rst | 1 - 7 files changed, 2 insertions(+), 544 deletions(-) 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/core/status/ddsentitystatus.rst diff --git a/code/CodeTester.cpp b/code/CodeTester.cpp index f897691a9..d1a0037bb 100644 --- a/code/CodeTester.cpp +++ b/code/CodeTester.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include using namespace eprosima::fastrtps; diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index ea40bd26c..452b6153b 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include using namespace eprosima::fastdds::dds; 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/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 3770e5d63..99ec538eb 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -1025,7 +1025,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/fastdds/api_reference/dds_pim/core/status/ddsentitystatus.rst b/docs/fastdds/api_reference/dds_pim/core/status/ddsentitystatus.rst deleted file mode 100644 index 295033724..000000000 --- a/docs/fastdds/api_reference/dds_pim/core/status/ddsentitystatus.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. _api_pim_ddsentitystatus: - -.. rst-class:: api-ref - -DDSEntityStatus ---------------- - -.. doxygenstruct:: eprosima::fastdds::statistics::rtps::DDSEntityStatus - :project: FastDDS - :members: diff --git a/docs/fastdds/api_reference/dds_pim/core/status/status.rst b/docs/fastdds/api_reference/dds_pim/core/status/status.rst index 78008432a..8926a1e52 100644 --- a/docs/fastdds/api_reference/dds_pim/core/status/status.rst +++ b/docs/fastdds/api_reference/dds_pim/core/status/status.rst @@ -4,7 +4,6 @@ Status .. toctree:: /fastdds/api_reference/dds_pim/core/status/basestatus.rst - /fastdds/api_reference/dds_pim/core/status/ddsentitystatus.rst /fastdds/api_reference/dds_pim/core/status/deadlinemissedstatus.rst /fastdds/api_reference/dds_pim/core/status/incompatibleqosstatus.rst /fastdds/api_reference/dds_pim/core/status/inconsistenttopicstatus.rst From 599a362c6cc12101fed9ddf09b4eaa5796a96cf0 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Mon, 8 Apr 2024 15:17:57 +0200 Subject: [PATCH 09/23] Refs #20631: apply review suggestions to Fast DDS-Gen usage Signed-off-by: JLBuenoLopez-eProsima --- docs/fastddsgen/usage/usage.rst | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/docs/fastddsgen/usage/usage.rst b/docs/fastddsgen/usage/usage.rst index 5bb599a5d..6145f509a 100644 --- a/docs/fastddsgen/usage/usage.rst +++ b/docs/fastddsgen/usage/usage.rst @@ -54,11 +54,12 @@ Where the options are: * - Option - Description * - -cs - - IDL grammar apply case sensitive matching. + - Enables case sensitivity in variable names. * - -d - - Sets an output directory for generated files. + - Sets the output directory for the generated files. * - -default-container-prealloc-size - - Sets the default preallocated size for containers (sequence and maps). Default value: 0. + - 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| @@ -76,24 +77,18 @@ Where the options are: stored. |br| A custom template example can be found in this `link `_ * - -flat-output-dir - - Ignore input files relative paths and place all generated files in the specified output directory. - * - -fusion - - Activates fusion. + - 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. - * - -language - - chooses between or languages. + - Adds directory to preprocessor include paths. * - -no-typesupport - - Avoid generating the type support files. + - Avoids generating the type support files. * - -no-typeobjectsupport - - Avoid generating the TypeObject support specific files. |br| + - Avoids generating the TypeObject support specific files. |br| Enabled automatically if -no-typesupport argument is used. * - -no-dependencies - - Avoid processing the dependent IDL files. - * - -package - - Default package used in Java files. + - Avoids processing the dependent IDL files. * - -ppDisable - Disables the preprocessor. * - -ppPath @@ -108,8 +103,6 @@ Where the options are: - Sets a specific directory as a temporary directory. * - -typeros2 - Generates type naming compatible with ROS 2. - * - -typesc - - Generates string and sequence types compatible with C. * - -version - Shows the current version of eProsima *Fast DDS-Gen*. From 9f25b71c79a34f54377238b6f655ff8b6222687f Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 08:41:58 +0200 Subject: [PATCH 10/23] Refs #20631: inheritance not yet supported with XML. Use correct typelookup service thread name Signed-off-by: JLBuenoLopez-eProsima --- code/XMLTester.xml | 21 ++++++++++----------- code/XMLTesterExample.xml | 14 ++++++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 6f4333feb..871da920f 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -1442,12 +1442,12 @@ -1 - + -1 0 0 -1 - + -1 @@ -4277,9 +4277,6 @@ - - - XML_PRIMITIVES<--> @@ -4386,7 +4383,8 @@ <--> XML_BITSET<--> - + + <--> + XML_BITSET_INHERITANCE<--> - + <--> XML_STRUCT_INHERITANCE<--> - + <--> XML_COMPLEX_STRUCTS<--> diff --git a/code/XMLTesterExample.xml b/code/XMLTesterExample.xml index f130bf684..805cb84f4 100644 --- a/code/XMLTesterExample.xml +++ b/code/XMLTesterExample.xml @@ -473,12 +473,12 @@ -1 - + -1 0 0 -1 - + -1 @@ -991,10 +991,11 @@ - + + @@ -1019,10 +1020,11 @@ - + + From 58ee585bcdf2f0bf8cf9cc62873cfd8b57a2e515 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 08:47:22 +0200 Subject: [PATCH 11/23] Refs #20631: fix tests: trailing whitespaces Signed-off-by: JLBuenoLopez-eProsima --- .../xml_configuration/dynamic_types.rst | 3 +- docs/fastdds/xtypes/discovery_matching.rst | 3 +- docs/fastdds/xtypes/language_binding.rst | 62 +++++++++---------- docs/fastdds/xtypes/xtypes.rst | 8 +-- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 7e776b0eb..3271db276 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -405,7 +405,8 @@ This is exemplified by the code snippet below. :start-after: //!--CPP_STRUCT_INHERITANCE :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Structures Inheritance `. +For a full example of how to define this type, please refer to +:ref:`Structures Inheritance `. .. _xmldynamictypes_union: diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index 95e18eb43..071ac0345 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -9,7 +9,8 @@ Discovery and Endpoint Matching .. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 *eProsima Fast DDS* incorporates an advanced type discovery service used on endpoint discovery and matching. -Discovery process leverages the optional |TypeInformation-api| value to ensure compatibility between communicating endpoints. +Discovery process leverages the optional |TypeInformation-api| value to ensure compatibility between communicating +endpoints. Upon the discovery of a remote endpoint, *eProsima Fast DDS* examines the |TypeInformation-api| to determine the availability of essential data type information. diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index 48aed4612..5e9a58c0d 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -10,7 +10,7 @@ Dynamic Language Binding *eProsima Fast DDS* supports several methods to define |DynamicTypes|. Manual creation using |DynamicTypeBuilderFactory-api| and |DynamicTypeBuilder-api| to create the types. -:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes by defining +:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes by defining them directly through XML. This section contains an small description of the interfaces used to work with |DynamicTypes| and a detailed @@ -105,9 +105,9 @@ Primitives ^^^^^^^^^^ By definition, primitive types are self-describing and can be created without configuration parameters. -Therefore, the |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| +Therefore, the |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| to allow users to create the type bypassing the |DynamicTypeBuilder-api| step. -The |DynamicData-api| class has a specific :func:`get_value` and :func:`set_value` functions for each primitive +The |DynamicData-api| class has a specific :func:`get_value` and :func:`set_value` functions for each primitive type in the list. The following table shows the supported primitive types and their corresponding ``TypeKind``. @@ -182,9 +182,9 @@ Strings Strings are quite similar to primitive types, the main difference being that they need to set their size limit. -The |DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and +The |DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and |DynamicTypeBuilderFactory::create_wstring_type| to allow users to create them directly. -These functions take a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` +These functions take a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` to set it to unlimited. The |DynamicData-api| class has a specific :func:`get_string_value` and :func:`set_string_value`. @@ -228,7 +228,7 @@ Enumerations An enumeration contains a set of supported values and a selected value among those supported. The ``TypeKind`` used to identify Enumerations is ``TK_ENUM``. -The supported values must be configured using the |DynamicTypeBuilder-api|, using the |DynamicTypeBuilder::add_member| +The supported values must be configured using the |DynamicTypeBuilder-api|, using the |DynamicTypeBuilder::add_member| function for the respective supported values. The type to which the enumeration will be bound to is determined the first time |DynamicTypeBuilder::add_member| is invoked by taking the type of that member. @@ -272,7 +272,7 @@ The ``TypeKind`` used to identify Bitmasks is ``TK_BITMASK``. These flags might use the ``id`` attribute to set their position in the bitmask. The ``bound`` attribute specifies the number of bits that the bitmask type will manage. Bitmasks can be bound to any number of bits up to 64. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to facilitate the creation of this type. The members added to a bitmask using |DynamicTypeBuilder::add_member| must be of type ``TK_BOOLEAN``. @@ -311,7 +311,7 @@ Alias types provide an alternative name to an already existing type. The ``TypeKind`` used to identify Alias is ``TK_ALIAS``. Once the |DynamicData-api| is created, users can access its information as if they were working with the base type. -To create an alias type, users must use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| with +To create an alias type, users must use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| with the existing type they want the alias to represent. .. tabs:: @@ -378,15 +378,15 @@ Collections Sequences ********* -A complex type that manages its members as a list of elements allowing users to insert, +A complex type that manages its members as a list of elements allowing users to insert, remove or access to a member of the list. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to facilitate the creation of this type. To create this type, the user must specify the type to be stored. Additionally, the size limit of the list. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. -The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive +The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive type, allowing users to work with multiple values at once. .. tabs:: @@ -427,10 +427,10 @@ An array needs to know the number of dimensions it maanges. The user must provide a vector with as many elements as there are dimensions in the array. Each element in the vector represents the size of the given dimension. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to +The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to facilitate the creation of this type. -The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each +The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive type that allow users to work with multiple values at once. .. tabs:: @@ -465,15 +465,15 @@ Maps **** 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 +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. -The |DynamicTypeBuilderFactory-api| exposes the |DynamicTypeBuilderFactory::create_map_type| function to +The |DynamicTypeBuilderFactory-api| exposes the |DynamicTypeBuilderFactory::create_map_type| function to facilitate the creation of this type. To create a map, users must set the types of the key and the value elements. Additionally, the size limit of the map. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. -The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each primitive +The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each primitive type that allow users to work with multiple values at once. To access the members of the map using the keys, users can use the |DynamicData::get_member_id_by_name| function to get @@ -521,11 +521,11 @@ They do not have any value, they are only used to contain other types. The function |DynamicTypeBuilderFactory::create_type| is used to create a new structure type. The ``TypeKind`` used to identify structures is ``TK_STRUCTURE``. -To manage the types inside the structure, users can call the :func:`get` and :func:`set` functions according to the +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 its ``id``. -If the structure contains a complex value, |DynamicData::loan_value| should be used to access it and +If the structure contains a complex value, |DynamicData::loan_value| should be used to access it and |DynamicData::return_loaned_value| should be used to release that loan. -|DynamicData-api| manages the loaned values and users cannot loan a previously loaned value +|DynamicData-api| manages the loaned values and users cannot loan a previously loaned value without calling |DynamicData::return_loaned_value| before. @@ -563,7 +563,7 @@ Unions Unions are a special type of structure where only one of the members is active at a time. The ``TypeKind`` used to identify unions is ``TK_UNION``. -To control these members, users must set the ``discriminator`` type that is going to be used to select the current +To control these members, users must set the ``discriminator`` type that is going to be used to select the current member by calling the |TypeDescriptor::discriminator_type| function of the union type. The ``discriminator`` itself is a DynamicType that must be of any of the following types: - Boolean. @@ -573,7 +573,7 @@ The ``discriminator`` itself is a DynamicType that must be of any of the followi - An enumerated type. - Any alias type that resolves, directly or indirectly, to one of the aforementioned types. -In addition, users can use the |MemberDescriptor::label| function with one or more values to set the labels of each +In addition, users can use the |MemberDescriptor::label| function with one or more values to set the labels of each member of the union, and |MemberDescriptor::is_default_label| to set the default label of the union. .. tabs:: @@ -628,7 +628,7 @@ Each bitfield in a bitset can be modified through their minimal needed primitive | ``33-64`` | ``UINT64`` | +--------------------------+--------------------------+ -Each bitfield (or member) works like its primitive type with the only difference that the internal storage only +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. The ``TypeKind`` used to identify Bitsets is ``TK_BITSET``. @@ -675,10 +675,10 @@ Inheritance .. _xtypes_structure_inheritance: Structures allow inheritance, exactly with the same OOP meaning. -To inherit from another structure, users must create the parent structure calling the +To inherit from another structure, users must create the parent structure calling the |DynamicTypeBuilderFactory::create_type| normally. -After the parent type is created, use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| -when creating the child structure, using the parent type as the base type. +After the parent type is created, use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| +when creating the child structure, using the parent type as the base type. 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. @@ -712,7 +712,7 @@ please refer to :ref:`Struct `. .. _xtypes_bitset_inheritance: Bitsets allows inheritance aswell, exactly with the same OOP meaning. -To inherit from another bitset, users must follow the same process as with +To inherit from another bitset, users must follow the same process as with :ref:`structures `, but using bitset types. .. tabs:: @@ -748,7 +748,7 @@ Nested Types Structures can contain other structures as members. The access to these compound members is restricted and managed by the |DynamicData-api| instance. -Users must request access calling |DynamicData::loan_value| before using them, +Users must request access calling |DynamicData::loan_value| before using them, and release them with |DynamicData::return_loaned_value| once they finished. The loan operation will fail if the member is already loaned and has not been released yet. @@ -779,7 +779,7 @@ The loan operation will fail if the member is already loaned and has not been re Unions support complex type fields. The access to these complex type fields is restricted and managed by the |DynamicData-api| instance. -Users must request access calling |DynamicData::loan_value| before using them, +Users must request access calling |DynamicData::loan_value| before using them, and release them with |DynamicData::return_loaned_value| once they finished. The loan operation will fail if the fields is already loaned and has not been released yet. @@ -814,10 +814,10 @@ Annotations ^^^^^^^^^^^ |DynamicTypeBuilder-api| allows applying an annotation to both current type and inner members with the functions. -To add the annotations to the types, the function |DynamicTypeBuilder::apply_annotation| is used, and +To add the annotations to the types, the function |DynamicTypeBuilder::apply_annotation| is used, and |DynamicTypeBuilder::apply_annotation_to_member| to add them to the members. -Both functions take the :class:`AnnotationDescriptor` of the annotation to be added, +Both functions take the :class:`AnnotationDescriptor` of the annotation to be added, and |DynamicTypeBuilder::apply_annotation_to_member| additionally receives the ``MemberId`` of the inner member. @@ -876,7 +876,7 @@ For the @key annotation the function |MemberDescriptor::is_key| can be fount in Type promotions --------------- -|DynamicTypes| supports type promotion, enabling implicit promotion of types during both :func:`get` and :func:`set` +|DynamicTypes| 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. diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index 58f130261..9b9803d3f 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -2,15 +2,15 @@ .. _dynamic-types: -XTypes 1.3 -========== +XTypes +====== .. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 *eProsima Fast DDS* manages :ref:`Discovery and Endpoint Matching ` using |TypeInformation-api| and |TypeObject-api| when posible. -When remote endpoints are discovered, it checks that the types are known, initiating a type discovery process if necessary -before the matching between the endpoints takes place. +When remote endpoints are discovered, it checks that the types are known, initiating a type discovery process if +necessary before the matching between the endpoints takes place. Alternatively, it uses a fallback mechanism based on type names when |TypeInformation-api| is unavailable. *eProsima Fast DDS* provides a dynamic way to define and use topic types and topic data. From 02773e728abf1e4a546f113a059c0463b49f6a91 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 11:10:00 +0200 Subject: [PATCH 12/23] Refs #20631: fix spelling Signed-off-by: JLBuenoLopez-eProsima --- .../api_reference/spelling_wordlist.txt | 111 ++++++++++++++++++ .../dds_layer/topic/fastddsgen/fastddsgen.rst | 2 +- docs/fastdds/xtypes/discovery_matching.rst | 6 +- docs/fastdds/xtypes/language_binding.rst | 8 +- docs/fastdds/xtypes/xtypes.rst | 2 +- docs/spelling_wordlist.txt | 4 + 6 files changed, 124 insertions(+), 9 deletions(-) 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/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index 300ee15e6..a84fbb345 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -56,4 +56,4 @@ Assuming the IDL file had the name *“Mytype”*, and none of the above options 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`). * HelloWorldCdrAux.hpp/.ipp: C++ serialization and deserialization code for the HelloWorld type. -* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject-api| generation and regstration. +* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject-api| generation and registration. diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index 071ac0345..98b77158f 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -16,15 +16,15 @@ the availability of essential data type information. The process of checking the types is as follows: -1. **Evaluation of TypeInformation**: If the discovered enpoint has transmitted |TypeInformation-api|, +1. **Evaluation of TypeInformation**: If the discovered endpoint has transmitted |TypeInformation-api|, *eProsima Fast DDS* evaluates whether all required types are already known. In cases where some types are missing, an automatic process to discover the necessary types is initiated. |TypeObject-api| is used to communicate with other participants and to discover the topic types asynchronously. - Matching of the discovered enpoint is deferred until all necessary types are known. + Matching of the discovered endpoint is deferred until all necessary types are known. 2. **Fallback Mechanism**: In scenarios where the discovered endpoint has not transmitted |TypeInformation-api|, *eProsima Fast DDS* resorts to a fallback mechanism. - This mechanism relys on the type name to verify if the type is already known within the system. + This mechanism relies on the type name to verify if the type is already known within the system. If the type name is recognized, matching occurs. .. _xtypes_discovery_typeinformation: diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index 5e9a58c0d..d2f56934d 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -23,7 +23,7 @@ Dynamic Types Interfaces DynamicTypeBuilderFactory ^^^^^^^^^^^^^^^^^^^^^^^^^ -The |DynamicTypeBuilderFactory-api| serves as a singleton wich isntance is responsible for creating |DynamicTypes| and +The |DynamicTypeBuilderFactory-api| serves as a singleton which instance is responsible for creating |DynamicTypes| and serves as the entry point for both creating and deleting |DynamicTypeBuilder-api| objects. The simpler types can be directly instantiated without the need for a DynamicTypeBuilder. Refer to the Supported Types documentation for details on which types support this direct creation option. @@ -423,7 +423,7 @@ Arrays Arrays are very similar to sequences with two main differences: They can have multiple dimensions and their elements are initialized to the default value at the start. -An array needs to know the number of dimensions it maanges. +An array needs to know the number of dimensions it manages. The user must provide a vector with as many elements as there are dimensions in the array. Each element in the vector represents the size of the given dimension. @@ -711,7 +711,7 @@ please refer to :ref:`Struct `. .. _xtypes_bitset_inheritance: -Bitsets allows inheritance aswell, exactly with the same OOP meaning. +Bitsets allows inheritance as well, exactly with the same OOP meaning. To inherit from another bitset, users must follow the same process as with :ref:`structures `, but using bitset types. @@ -869,7 +869,7 @@ Currently, |DynamicTypes| supports the following builtin annotations: +-------------------------+-------------------------------------------------------------------------------------------+ To apply the @extensibility annotation (and its shortcuts) the |TypeDescriptor-api| exposes the function -|TypeDescriptor::extensibility_kind|, that recives a :class:`ExtensibilityKind`. +|TypeDescriptor::extensibility_kind|, that receives a :class:`ExtensibilityKind`. For the @key annotation the function |MemberDescriptor::is_key| can be fount in |MemberDescriptor-api|. diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index 9b9803d3f..9b841b1e9 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -8,7 +8,7 @@ XTypes .. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 *eProsima Fast DDS* manages :ref:`Discovery and Endpoint Matching ` -using |TypeInformation-api| and |TypeObject-api| when posible. +using |TypeInformation-api| and |TypeObject-api| when possible. When remote endpoints are discovered, it checks that the types are known, initiating a type discovery process if necessary before the matching between the endpoints takes place. Alternatively, it uses a fallback mechanism based on type names when |TypeInformation-api| is unavailable. diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index a55b5a24d..64e3a55fe 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -143,6 +143,7 @@ ifaddrs ifreq ignoreParticipantFlags initializations +instantiation interoperability interprocess intra @@ -207,6 +208,7 @@ postfixed ppDisable ppPath pre +prealloc preallocate preallocated preallocates @@ -269,10 +271,12 @@ Topologies txqueuelen typeobject TypeObject +typeobjectsupport typeros typeros2 typesupport uint +UInt uncheck unicast unidimensional From 366d46aaf15f2dac549190015d2320d025c1f6c3 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 12:32:12 +0200 Subject: [PATCH 13/23] Refs #20631: migrate to list tables and use proper C++ types Signed-off-by: JLBuenoLopez-eProsima --- docs/fastdds/xtypes/language_binding.rst | 205 ++++++++++++----------- 1 file changed, 111 insertions(+), 94 deletions(-) diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index d2f56934d..d55896569 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -113,39 +113,40 @@ type in the list. The following table shows the supported primitive types and their corresponding ``TypeKind``. The ``TypeKind`` is used to identify the type when it is created. -+------------------+-------------------+ -| C++ Type | TypeKind | -+------------------+-------------------+ -| ``BOOLEAN`` | ``TK_BOOLEAN`` | -+------------------+-------------------+ -| ``CHAR8`` | ``TK_CHAR8`` | -+------------------+-------------------+ -| ``CHAR16`` | ``TK_CHAR16`` | -+------------------+-------------------+ -| ``OCTET`` | ``TK_BYTE`` | -+------------------+-------------------+ -| ``INT8`` | ``TK_INT8`` | -+------------------+-------------------+ -| ``UINT8`` | ``TK_UINT8`` | -+------------------+-------------------+ -| ``INT16`` | ``TK_INT16`` | -+------------------+-------------------+ -| ``UINT16`` | ``TK_UINT16`` | -+------------------+-------------------+ -| ``INT32`` | ``TK_INT32`` | -+------------------+-------------------+ -| ``UINT32`` | ``TK_UINT32`` | -+------------------+-------------------+ -| ``INT64`` | ``TK_INT64`` | -+------------------+-------------------+ -| ``UINT64`` | ``TK_UINT64`` | -+------------------+-------------------+ -| ``FLOAT32`` | ``TK_FLOAT32`` | -+------------------+-------------------+ -| ``FLOAT64`` | ``TK_FLOAT64`` | -+------------------+-------------------+ -| ``FLOAT128`` | ``TK_FLOAT128`` | -+------------------+-------------------+ +.. 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` This example shows how to create members of each primitive type using |DynamicTypeBuilderFactory-api|. @@ -614,19 +615,22 @@ A bitfield can be anonymous (cannot be addressed) to skip unused bits within a b 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`` | -+--------------------------+--------------------------+ +.. 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. @@ -852,21 +856,27 @@ Beside the custom annotations created by the users, there are a number of builti Currently, |DynamicTypes| supports the following builtin annotations: -+-------------------------+-------------------------------------------------------------------------------------------+ -| Annotation | Implemented behavior | -+=========================+===========================================================================================+ -| ``@extensibility`` | Applied to any element which is constructed. Allow specifying how the |br| | -| | element is allowed to evolve. More info in :ref:`extensibility`. | -+-------------------------+-------------------------------------------------------------------------------------------+ -| ``@final`` | Shortcut for `@extensibility(FINAL)` | -+-------------------------+-------------------------------------------------------------------------------------------+ -| ``@appendable`` | Shortcut for `@extensibility(APPENDABLE)` | -+-------------------------+-------------------------------------------------------------------------------------------+ -| ``@mutable`` | Shortcut for `@extensibility(MUTABLE)` | -+-------------------------+-------------------------------------------------------------------------------------------+ -| ``@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). | -+-------------------------+-------------------------------------------------------------------------------------------+ +.. list-table:: + :header-rows: 1 + :align: left + + * - Builtin annotation + - Behavior + * - :code:`@extensibility` + - This annotation applies to any type declaration and defines |br| + how the type is allowed to evolve. + More info in :ref:`extensibility`. + * - :code:`@final` + - Shortcut for :code:`@extensibility(FINAL)`. + * - :code:`@appendable` + - Shortcut for :code:`@extensibility(APPENDABLE)`. + * - :code:`@mutable` + - Shortcut for :code:`@extensibility(MUTABLE)` + * - :code:`@key` + - Mark a member as part of the key (please refer to :ref:`dds_layer_topic_instances` |br| + for more information). + * - :code:`@Key` + - :code:`@key` alias. To apply the @extensibility annotation (and its shortcuts) the |TypeDescriptor-api| exposes the function |TypeDescriptor::extensibility_kind|, that receives a :class:`ExtensibilityKind`. @@ -882,36 +892,43 @@ This means that a smaller type can be implicitly promoted to a larger type, but The following promotions are supported: -+--------------+-------------------------------------------------------------------------------------------+ -| Type | Promotions | -+==============+===========================================================================================+ -| `Int8` | Int16, Int32, Int64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Int16` | Int32, Int64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Int32` | Int64, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Int64` | Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `UInt8` | Int16,Int32, Int64, UInt16, UInt32, UInt64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `UInt16` | Int32, Int64, UInt32, UInt64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `UInt32` | Int64, UInt64, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `UInt64` | Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Float32` | Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Float64` | Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Float128` | (none) | -+--------------+-------------------------------------------------------------------------------------------+ -| `Char8` | Char16, Int16, Int32, Int64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Char16` | Int32, Int64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ -| `Byte` | (any) | -+--------------+-------------------------------------------------------------------------------------------+ -| `Boolean` | Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, Float128 | -+--------------+-------------------------------------------------------------------------------------------+ +.. 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:`lonf TK_FLOAT64` + * - :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:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, + :code:`TK_FLOAT128` + * - :code:`TK_CHAR16` + - :code:`TK_INT32`, :code:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + * - :code:`TK_BYTE` + - (any) + * - :code:`TK_BOOLEAN` + - :code:`TK_INT8`, `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` From 8fb616c6e3288d8cf847f1d7e0c88d017d916dc4 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 12:56:33 +0200 Subject: [PATCH 14/23] Refs #20631: rewrite XTypes introduction section Signed-off-by: JLBuenoLopez-eProsima --- docs/fastdds/xtypes/xtypes.rst | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index 9b841b1e9..be277ad20 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -1,26 +1,27 @@ -.. include:: ../../03-exports/aliases-api.include - .. _dynamic-types: XTypes ====== -.. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 +.. _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. -*eProsima Fast DDS* manages :ref:`Discovery and Endpoint Matching ` -using |TypeInformation-api| and |TypeObject-api| when possible. -When remote endpoints are discovered, it checks that the types are known, initiating a type discovery process if -necessary before the matching between the endpoints takes place. -Alternatively, it uses a fallback mechanism based on type names when |TypeInformation-api| is unavailable. +.. note:: -*eProsima Fast DDS* provides a dynamic way to define and use topic types and topic data. -The :ref:`Dynamic Language Binding ` offers the possibility to work over DDS/RTPS -without the restrictions related to the IDLs. -The users can declare the different types that they need and manage the information on runtime, -avoiding the additional step of updating the IDL file and the generation of *C++* classes. + This section also defines the type compatibility rules among evolved types which is still unsupported in Fast DDS. -This implementation follows the *OMG Extensible and Dynamic Topic Types for DDS interface*. -For more information, refer to the specification for `DDS-XTypes V1.3`_. +* Type representation, including :ref:`IDL` and :ref:`xtypes_discovery_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 From 1226bc4ccb7fda1d841573511e90db6d5212ae4c Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 15:28:22 +0200 Subject: [PATCH 15/23] Refs #20631: rewrite remote data type discovery section Signed-off-by: JLBuenoLopez-eProsima --- code/DynamicTypesIDLExamples.idl | 35 +++++ docs/03-exports/aliases-api.include | 12 +- docs/03-exports/aliases.include | 4 +- .../core/policy/xtypesExtensions.rst | 4 +- .../dds_layer/topic/fastddsgen/fastddsgen.rst | 5 +- docs/fastdds/xtypes/discovery_matching.rst | 127 +++++++----------- docs/fastdds/xtypes/xtypes.rst | 2 +- 7 files changed, 92 insertions(+), 97 deletions(-) diff --git a/code/DynamicTypesIDLExamples.idl b/code/DynamicTypesIDLExamples.idl index 5807c7a1c..aaa7cf814 100644 --- a/code/DynamicTypesIDLExamples.idl +++ b/code/DynamicTypesIDLExamples.idl @@ -1,3 +1,38 @@ +//!--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 { diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 99ec538eb..4f1b4c7ba 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()` @@ -283,8 +284,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 ` .. |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() ` @@ -983,13 +982,8 @@ .. |TypeDescriptor::discriminator_type| replace:: :cpp:func:`TypeDescriptor::discriminator_type ` .. |VerbatimTextDescriptor-api| replace:: :cpp:class:`VerbatimTextDescriptor ` -.. |ITypeObjectRegistry-api| replace:: :cpp:class:`ITypeObjectRegistry ` -.. |TypeObjectUtils-api| replace:: :cpp:class:`TypeObjectUtils ` - -.. |TypeObjectV1-api| replace:: :cpp:class:`TypeObject` -.. |TypeIdV1-api| replace:: :cpp:class:`TypeIdentifier` - -.. |TopicDataType::auto_fill_type_information-api| replace:: :cpp:func:`auto_fill_type_information` +.. |ITypeObjectRegistry-api| replace:: :cpp:class:`ITypeObjectRegistry ` +.. |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()` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index 2ab7c053e..83b7419b0 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -102,8 +102,8 @@ .. |Nested Structures| replace:: :ref:`Nested Structures` .. |Nested Unions| replace:: :ref:`Nested Unions` -.. |TypeObject| replace:: :ref:`TypeObject` -.. |TypeInformation| replace:: :ref:`TypeInformation` +.. |TypeObject| replace:: :ref:`TypeObject` +.. |TypeInformation| replace:: :ref:`TypeInformation` .. |TopicDataType| replace:: :ref:`TopicDataType` .. |TopicDataTypes| replace:: :ref:`TopicDataTypes` 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/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index a84fbb345..4625b838f 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -37,8 +37,7 @@ 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. -* ``-no-typeobjectsupport``: Avoids building additional files for |TypeObject-api| generation and management (see - :ref:`xtypes_discovery_typeobject`). +* ``-no-typeobjectsupport``: Avoids building additional files for |TypeObject| registration. * ``-example``: It generates a basic example of a DDS application and the files to build it for the given ``platform``. Thus, *Fast DDS-Gen* tool can generate a sample application using the provided data type, together with a @@ -56,4 +55,4 @@ Assuming the IDL file had the name *“Mytype”*, and none of the above options 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`). * HelloWorldCdrAux.hpp/.ipp: C++ serialization and deserialization code for the HelloWorld type. -* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject-api| generation and registration. +* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject| generation and registration. diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index 98b77158f..e2f31a18a 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -1,103 +1,68 @@ .. include:: ../../03-exports/aliases-api.include -.. include:: ../../03-exports/aliases.include .. _xtypes_discovery_matching: -Discovery and Endpoint Matching -=============================== +Remote Data Types Discovery +=========================== -.. _DDS-XTypes V1.3: https://www.omg.org/spec/DDS-XTypes/1.3 +.. _DDS-XTypes specification: https://www.omg.org/spec/DDS-XTypes/1.3 -*eProsima Fast DDS* incorporates an advanced type discovery service used on endpoint discovery and matching. -Discovery process leverages the optional |TypeInformation-api| value to ensure compatibility between communicating -endpoints. -Upon the discovery of a remote endpoint, *eProsima Fast DDS* examines the |TypeInformation-api| to determine -the availability of essential data type information. - -The process of checking the types is as follows: - -1. **Evaluation of TypeInformation**: If the discovered endpoint has transmitted |TypeInformation-api|, - *eProsima Fast DDS* evaluates whether all required types are already known. - In cases where some types are missing, an automatic process to discover the necessary types is initiated. - |TypeObject-api| is used to communicate with other participants and to discover the topic types asynchronously. - Matching of the discovered endpoint is deferred until all necessary types are known. - -2. **Fallback Mechanism**: In scenarios where the discovered endpoint has not transmitted |TypeInformation-api|, - *eProsima Fast DDS* resorts to a fallback mechanism. - This mechanism relies on the type name to verify if the type is already known within the system. - If the type name is recognized, matching occurs. - -.. _xtypes_discovery_typeinformation: +`DDS-XTypes specification`_ defines an internal mechanism to discover the remote data types at runtime and match depending on the +extesible types compatibility rules configured using the :ref:`typeconsistencyenforcementqospolicy`. -TypeInformation ---------------- +.. note:: -|TypeInformation-api| is a fundamental component of the *XTypes 1.3* specification, facilitating the efficient exchange -of essential data type information between DDS endpoints. -Instead of transmitting the entire |TypeObject|, endpoints share a compact representation containing the |TypeIdV1-api| -of the respective data type. -The exchanged |TypeIdV1-api| serves as unique identifiers for the associated data types, allowing endpoints to verify -compatibility and also to facilitate subsequent retrieval of the necessary |TypeObject-api| for the data types needed, -This mechanism enhances interoperability without burdening non-interested endpoints with unnecessary data. + *eProsima Fast DDS* does not support XTypes compatibility check yet. -This approach significantly reduces network overhead, especially when communicating with endpoints that may -not require the complete type definition. +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. -The contents of TypeInformation include: +.. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--TYPEINFORMATION + :end-before: //!-- -* |TypeIdV1-api|: This is the core component of TypeInformation. - It represents the unique identifier of the data type associated with the endpoint and - enables endpoints to identify and verify the compatibility of data types during communication. +: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: -* Dependency Information: Optionally, TypeInformation may include dependency information, which - indicates other data types on which the current data type depends. - This information helps endpoints understand the data type hierarchy and its dependencies, - which facilitates comprehensive compatibility checks. - The decision as to which types to include in the dependency information is left to the implementation. +.. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--TYPEOBJECT + :end-before: //!-- -|TypeInformation-api| is described in the annexes of `DDS-XTypes V1.3`_ document, -please refer to this document for details. +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. -.. _xtypes_discovery_typeobject: +Prerequisites +------------- -TypeObject ----------- +The remote data type discovery feature only works if some requisites are met: -The *XTypes* type system uniquely identifies each possible type with a TypeIdentifier. -For simple types, such as primitive types, strings, or certain sequences of primitives, -the TypeIdentifier fully describes the type. -For more complex types, however, the TypeIdentifier only serves to identify the type, -and its full description requires a TypeObject. +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. -|TypeObject-api| provides a thorough description of a data type, similar to how it's represented in IDL. -There are two kinds of TypeObjects: :class:`CompleteTypeObject` and :class:`MinimalTypeObject`. + .. note:: -- :class:`CompleteTypeObject` mirrors the expressiveness of types represented in IDL or XML. - It can accurately represent any non-plain type from IDL without information loss, - except for formatting differences. - This representation is well-suited for programming and tooling purposes. + :code:`-no-typeobjectsupport` option disables the generation of these files and effectively disables the + discovery of remote types. -- :class:`MinimalTypeObject` provides a simplified representation of a data type, - that contains only the information necessary for remote endpoints to interpret the data correctly. - This representation excludes details such as user-defined annotations or member order for types with - extensibility kind MUTABLE, which do not affect the type assignability. - By minimizing redundant information, MinimalTypeObject reduces network overhead during type compatibility - checks between DataWriters and DataReaders. + .. note:: -Both :class:`CompleteTypeObject` and :class:`MinimalTypeObject` are defined in the annexes of the `DDS-XTypes V1.3`_ -document, providing detailed specifications and IDL representations. + 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. -Fast DDS-Gen ------------- +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. -*Fast DDS-Gen* default behaviour generates code compatible with :ref:`XTypes1.3 `. -When processing an IDL file, it will automatically generate all the code files needed for the data types. - -For instance, assuming the IDL file is named *"Mytype"*, the generated files include: - -- *MyType.hpp*: This file contains the definition of the data type. -- *MyTypePubSubType.cxx/.h*: Serialization and deserialization source code for the data type. -- *MyTypeTypeObjectSupport.cxx/.hpp*: Generation and registration of |TypeObject-api|. - -Detailed usage instructions and additional information about *Fast DDS-Gen* can be found in the -:ref:`Fast DDS-Gen ` section. +If the prerequisites are not met, endpoint matching relies on type name and topic name in order to match the discovered +endpoints. diff --git a/docs/fastdds/xtypes/xtypes.rst b/docs/fastdds/xtypes/xtypes.rst index be277ad20..da79d8c53 100644 --- a/docs/fastdds/xtypes/xtypes.rst +++ b/docs/fastdds/xtypes/xtypes.rst @@ -14,7 +14,7 @@ This specification defines the following concepts: 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:`xtypes_discovery_typeobject` +* 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. From fb250c46a640e108244c37d808137a0f9852bc9c Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 9 Apr 2024 16:38:35 +0200 Subject: [PATCH 16/23] Refs #20631: implement pending TODO Signed-off-by: JLBuenoLopez-eProsima --- code/DDSCodeTester.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 452b6153b..01af4182f 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -1725,12 +1725,10 @@ void dds_topic_examples() DomainParticipantFactory::get_instance()->load_XML_profiles_file("example_type.xml"); // Retrieve the an instance of the desired type - DynamicTypeBuilder::_ref_type type_builder; - //TODO xtypes use the correct public method to get the type builder - //DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("DynamicType", type_builder); + DynamicType::_ref_type dyn_type; + DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("DynamicType", dyn_type); - // Build and register it - DynamicType::_ref_type dyn_type = type_builder->build(); + // Register dynamic type TypeSupport dyn_type_support(new DynamicPubSubType(dyn_type)); dyn_type_support.register_type(participant, nullptr); @@ -5247,12 +5245,10 @@ void xml_profiles_examples() DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { // Retrieve the an instance of the desired type - DynamicTypeBuilder::_ref_type my_struct_builder; - //TODO xtypes use the correct public method to get the type builder - //DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("MyStruct", my_struct_builder); + DynamicType::_ref_type my_struct_type; + DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("MyStruct", my_struct_type); // Register MyStruct type - DynamicType::_ref_type my_struct_type = my_struct_builder->build(); TypeSupport my_struct_type_support(new DynamicPubSubType(my_struct_type)); my_struct_type_support.register_type(participant, nullptr); } From 1f40ec6245de6255b8f3189ef10ca2fdf1c17fea Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Fri, 12 Apr 2024 11:44:06 +0200 Subject: [PATCH 17/23] Refs #20631: rewrite XTypes sections and related information Signed-off-by: JLBuenoLopez-eProsima --- code/DDSCodeTester.cpp | 849 ++++++++------- code/DynamicTypesIDLExamples.idl | 175 ++-- code/XMLTester.xml | 163 ++- docs/03-exports/aliases-api.include | 19 +- docs/03-exports/aliases.include | 21 +- .../dds_pim/xtypes/dynamic_types.rst | 6 +- .../remote_type_discovery_matching.rst | 58 ++ docs/fastdds/use_cases/use_cases.rst | 5 + .../xml_configuration/dynamic_types.rst | 530 ++++------ docs/fastdds/xtypes/discovery_matching.rst | 19 +- docs/fastdds/xtypes/language_binding.rst | 964 ++++++++++-------- docs/fastddsgen/dataTypes/dataTypes.rst | 182 ++-- docs/spelling_wordlist.txt | 2 + 13 files changed, 1577 insertions(+), 1416 deletions(-) create mode 100644 docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 01af4182f..8a7fdb0b8 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -977,6 +978,107 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener }; //!-- +//!--REMOTE_TYPE_MATCHING +class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListener +{ + /* Custom Callback on_data_reader_discovery */ + void on_data_reader_discovery( + DomainParticipant* participant, + eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, + bool& should_be_ignored) override + { + static_cast(should_be_ignored); + // 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, nullptr); + + // 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 + { + static_cast(should_be_ignored); + // 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, nullptr); + + // 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; + } + + DataReader* data_reader = subscriber->create_datareader(topic, DATAREADER_QOS_DEFAULT); + if (nullptr == data_reader) + { + // Error + return; + } + } +}; +//!-- + void dds_discovery_examples() { using Locator_t = eprosima::fastrtps::rtps::Locator_t; @@ -4431,49 +4533,62 @@ void dynamictypes_examples() // 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_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_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_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_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_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); @@ -4505,18 +4620,52 @@ void dynamictypes_examples() 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)); + 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)); + 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 @@ -4533,6 +4682,13 @@ void dynamictypes_examples() } { //!--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); @@ -4545,7 +4701,7 @@ void dynamictypes_examples() enum_type_descriptor->name("MyEnum"); DynamicTypeBuilder::_ref_type enum_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(enum_type_descriptor)}; - // Add enum members to the enum type + // 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"); @@ -4572,7 +4728,7 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for an enum member - uint32_t in_value = 2; + MyEnum in_value = 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")); @@ -4588,17 +4744,18 @@ void dynamictypes_examples() create_type(type_descriptor)}; // Define the bitmask type - 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)}; + DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_bitmask_type(8)}; + /* Alternative - DynamicTypeBuilder::_ref_type bitmask_builder {DynamicTypeBuilderFactory::get_instance()->create_bitmask_type(8)}; - */ + 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()}; @@ -4609,12 +4766,10 @@ void dynamictypes_examples() bitfield_member_descriptor = traits::make_shared(); bitfield_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); bitfield_member_descriptor->name("flag1"); - bitfield_member_descriptor->id(1); 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"); - bitfield_member_descriptor->id(2); 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)); @@ -4639,11 +4794,25 @@ void dynamictypes_examples() 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()}; @@ -4651,93 +4820,134 @@ void dynamictypes_examples() 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("MyAliasEnum"); + 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 an array - TypeDescriptor::_ref_type aliasarray_type_descriptor {traits::make_shared()}; - aliasarray_type_descriptor->kind(TK_ALIAS); - aliasarray_type_descriptor->name("MyAliasArray"); - BoundSeq array_bounds = { 2, 2 }; - aliasarray_type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> - create_array_type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(TK_INT32), array_bounds)->build()); - DynamicTypeBuilder::_ref_type aliasarray_builder {DynamicTypeBuilderFactory::get_instance()-> - create_type(aliasarray_type_descriptor)}; - // Build the alias type for the array - DynamicType::_ref_type aliasarray_type = aliasarray_builder->build(); - - // Add alias enum member to the struct + // 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_alias_enum"); + member_descriptor->name("my_aliased_enum"); member_descriptor->type(aliasenum_type); struct_builder->add_member(member_descriptor); - // Add alias array member to the struct + // Add alias bounded string member to the structure member_descriptor = traits::make_shared(); - member_descriptor->name("my_alias_array"); - member_descriptor->type(aliasarray_type); + 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 - int32_t in_value = 2; + 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")); //!-- } { - //!--CPP_RECURSIVE_TYPEDEF - // Define a struct type to contain the alias + // 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("RecursiveAliasStruct"); + type_descriptor->name("SequenceStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()-> create_type(type_descriptor)}; - // Define an alias type for base type - type_descriptor = traits::make_shared(); - type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); - type_descriptor->name("RecursiveAlias"); - type_descriptor->base_type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(eprosima::fastdds::dds::TK_UINT32)); - DynamicTypeBuilder::_ref_type builder {DynamicTypeBuilderFactory::get_instance()-> - create_type(type_descriptor)}; - // Build the alias type for the base type - DynamicType::_ref_type rec_type {builder->build()}; - type_descriptor = traits::make_shared(); - type_descriptor->kind(eprosima::fastdds::dds::TK_ALIAS); - type_descriptor->name("MyAlias"); - type_descriptor->base_type(rec_type); - builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); - // Build the alias type for other alias - DynamicType::_ref_type alias_type {builder->build()}; + // 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()); - // Add alias member to the struct - MemberDescriptor::_ref_type member_descriptor {traits::make_shared()}; - member_descriptor->name("my_alias"); - member_descriptor->type(alias_type); - struct_builder->add_member(member_descriptor); + /* Alternative + type_descriptor = traits::make_shared(); + type_descriptor->kind(TK_SEQUENCE); + type_descriptor->element_type(bitmask_type); + 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 alias member - uint32_t in_value = 2; - uint32_t out_value = 0; - data->set_uint32_value(data->get_member_id_by_name("my_alias"), in_value); - data->get_uint32_value(out_value, data->get_member_id_by_name("my_alias")); + // 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); //!-- } { @@ -4754,6 +4964,17 @@ void dynamictypes_examples() 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 @@ -4766,36 +4987,25 @@ void dynamictypes_examples() 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")); - //!-- - } - { - //!--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("short_sequence"); - sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type( - DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT16), 5)->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 array_data {data->loan_value(data->get_member_id_by_name("long_array"))}; + // Set the two latest possible values on the array + array_data->set_int32_values(22, 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()}; @@ -4805,11 +5015,41 @@ void dynamictypes_examples() create_type(type_descriptor)}; // Define a member for the map MemberDescriptor::_ref_type map_member_descriptor {traits::make_shared()}; - map_member_descriptor->name("long_long_map"); + map_member_descriptor->name("string_long_array_unbounded_map"); map_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_map_type( - DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), - DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32), 2)->build()); + 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); + 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()}; @@ -4817,7 +5057,7 @@ void dynamictypes_examples() 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("long_long_map")); + 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; @@ -4832,88 +5072,128 @@ void dynamictypes_examples() } { //!--CPP_STRUCT - // Define a struct type - TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; - struct_type_descriptor->kind(TK_STRUCTURE); - struct_type_descriptor->name("MyStruct"); - DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( - struct_type_descriptor)}; - // Add members to the struct - MemberDescriptor::_ref_type struct_member {traits::make_shared()}; - struct_member->name("first"); - struct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); - struct_builder->add_member(struct_member); - struct_member = traits::make_shared(); - struct_member->name("second"); - struct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); - struct_builder->add_member(struct_member); + // 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()}; - // Build the struct type - DynamicType::_ref_type struct_type {struct_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(struct_type)}; + DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(complexstruct_type)}; - // Set and retrieve values for the member - const int32_t value1 = 2; - int32_t value2 = 0; - data->set_int32_value(data->get_member_id_by_name("first"), value1); - data->get_int32_value(value2, data->get_member_id_by_name("first")); + // 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 in previous section. - DynamicType::_ref_type mystruct_type; + // 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 - TypeDescriptor::_ref_type struct_type_descriptor {traits::make_shared()}; - struct_type_descriptor->kind(TK_STRUCTURE); - struct_type_descriptor->name("UnionStruct"); - DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( - struct_type_descriptor)}; - // Define a type for union - TypeDescriptor::_ref_type union_type_descriptor = traits::make_shared(); - union_type_descriptor->kind(TK_UNION); - union_type_descriptor->name("MyUnion"); - union_type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type( - TK_INT16)); - DynamicTypeBuilder::_ref_type union_builder {DynamicTypeBuilderFactory::get_instance()->create_type( - union_type_descriptor)}; - // Add members to the union type - MemberDescriptor::_ref_type union_member_descriptor {traits::make_shared()}; - union_member_descriptor->name("first"); - union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); - union_member_descriptor->label({0, 1}); - union_builder->add_member(union_member_descriptor); - union_member_descriptor = traits::make_shared(); - union_member_descriptor->name("second"); - union_member_descriptor->type(mystruct_type); - union_member_descriptor->label({2}); - union_builder->add_member(union_member_descriptor); - union_member_descriptor = traits::make_shared(); - union_member_descriptor->name("third"); - union_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); - union_member_descriptor->is_default_label(true); - union_builder->add_member(union_member_descriptor); - // Build the union type - DynamicType::_ref_type union_type = union_builder->build(); - - // Add the union member to the struct + // 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->name("my_union"); - member_descriptor->type(union_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)}; + 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)}; // Set and retrieve values for the member - DynamicData::_ref_type union_data = data->loan_value(data->get_member_id_by_name("my_union")); + DynamicData::_ref_type union_data = data->loan_value(data->get_member_id_by_name("InnerUnion")); // Set and retrieve values for the member - int32_t in_value = 2; - int32_t out_value; - union_data->set_int32_value(union_data->get_member_id_by_name("first"), in_value); - union_data->get_int32_value(out_value, union_data->get_member_id_by_name("first")); + 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); //!-- @@ -4926,27 +5206,25 @@ void dynamictypes_examples() struct_type_descriptor->name("BitsetStruct"); DynamicTypeBuilder::_ref_type struct_builder {DynamicTypeBuilderFactory::get_instance()->create_type( struct_type_descriptor)}; - // Define a type for bitset + + // Define type for parent bitset TypeDescriptor::_ref_type bitset_type_descriptor {traits::make_shared()}; bitset_type_descriptor->kind(TK_BITSET); - bitset_type_descriptor->name("MyBitset"); - bitset_type_descriptor->bound({3, 1, 4, 10, 12}); + 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_CHAR8)); 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BOOLEAN)); 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->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); bitset_member_descriptor->id(8); bitset_builder->add_member(bitset_member_descriptor); bitset_member_descriptor = traits::make_shared(); @@ -4955,7 +5233,28 @@ void dynamictypes_examples() bitset_member_descriptor->id(18); bitset_builder->add_member(bitset_member_descriptor); // Build the bitset type - DynamicType::_ref_type bitset_type = bitset_builder->build(); + 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(0); + 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(1); + 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()}; @@ -4978,181 +5277,6 @@ void dynamictypes_examples() data->return_loaned_value(bitset_data); //!-- } - { - //!--CPP_BITSET_INHERITANCE - // Create a parent bitset type - TypeDescriptor::_ref_type parentbitset_type_descriptor {traits::make_shared()}; - parentbitset_type_descriptor->kind(TK_BITSET); - parentbitset_type_descriptor->name("ParentBitSet"); - parentbitset_type_descriptor->bound({3, 1}); - DynamicTypeBuilder::_ref_type parentbitset_builder {DynamicTypeBuilderFactory::get_instance()->create_type( - parentbitset_type_descriptor)}; - // Add members to the parent bitset type - MemberDescriptor::_ref_type parentbitset_member_descriptor {traits::make_shared()}; - parentbitset_member_descriptor->name("a"); - parentbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(TK_CHAR8)); - parentbitset_member_descriptor->id(0); - parentbitset_builder->add_member(parentbitset_member_descriptor); - parentbitset_member_descriptor = traits::make_shared(); - parentbitset_member_descriptor->name("b"); - parentbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(TK_BOOLEAN)); - parentbitset_member_descriptor->id(3); - parentbitset_builder->add_member(parentbitset_member_descriptor); - // Build the parent bitset type - DynamicType::_ref_type parentbitset_type = parentbitset_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({10, 12}); - 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("c"); - childbitset_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_UINT16)); - childbitset_member_descriptor->id(0); - 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_INT16)); - childbitset_member_descriptor->id(10); - childbitset_builder->add_member(childbitset_member_descriptor); - // Build the child bitset type - DynamicType::_ref_type childbitset_type = childbitset_builder->build(); - //!-- - } - { - //!--CPP_STRUCT_INHERITANCE - // Create a 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_INT32)); - 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 child struct type - TypeDescriptor::_ref_type childstruct_type_descriptor {traits::make_shared()}; - childstruct_type_descriptor->kind(TK_STRUCTURE); - childstruct_type_descriptor->name("ChildStruct"); - childstruct_type_descriptor->base_type(parentstruct_type); - DynamicTypeBuilder::_ref_type childstruct_builder {DynamicTypeBuilderFactory::get_instance()-> - create_type(childstruct_type_descriptor)}; - // Add members to the child struct type - MemberDescriptor::_ref_type childstruct_member {traits::make_shared()}; - childstruct_member->name("third"); - childstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT32)); - childstruct_builder->add_member(childstruct_member); - childstruct_member = traits::make_shared(); - childstruct_member->name("fourth"); - childstruct_member->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); - childstruct_builder->add_member(childstruct_member); - // Build the child struct type - DynamicType::_ref_type childstruct_type = childstruct_builder->build(); - //!-- - } - { - //!--CPP_COMPLEX_STRUCTS - // Create a 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(0); - builder->add_member(member_descriptor); - // Build the inner struct type - DynamicType::_ref_type inner_struct_type {builder->build()}; - - // Create a complex struct type - type_descriptor = traits::make_shared(); - type_descriptor->kind(eprosima::fastdds::dds::TK_STRUCTURE); - type_descriptor->name("ComplexStruct"); - builder = DynamicTypeBuilderFactory::get_instance()->create_type(type_descriptor); - // Add members to the complex struct type - member_descriptor = traits::make_shared(); - member_descriptor->type(inner_struct_type); - member_descriptor->name("complex_member"); - member_descriptor->id(0); - builder->add_member(member_descriptor); - // Build the complex struct type - DynamicType::_ref_type struct_type {builder->build()}; - //!-- - } - { - //!--CPP_COMPLEX_UNIONS - // Create the inner union - TypeDescriptor::_ref_type type_descriptor {traits::make_shared()}; - type_descriptor->kind(eprosima::fastdds::dds::TK_UNION); - type_descriptor->name("InnerUnion"); - type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(eprosima::fastdds::dds::TK_INT32)); - 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(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(eprosima::fastdds::dds::TK_INT64)); - member_descriptor->name("first"); - member_descriptor->id(1); - member_descriptor->label({0}); - builder->add_member(member_descriptor); - member_descriptor = traits::make_shared(); - member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(eprosima::fastdds::dds::TK_INT64)); - member_descriptor->name("second"); - member_descriptor->id(2); - 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(eprosima::fastdds::dds::TK_UNION); - type_descriptor->name("ComplexUnion"); - type_descriptor->discriminator_type(DynamicTypeBuilderFactory::get_instance()-> - get_primitive_type(eprosima::fastdds::dds::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(eprosima::fastdds::dds::TK_INT32)); - member_descriptor->name("third"); - member_descriptor->id(1); - member_descriptor->label({0}); - builder->add_member(member_descriptor); - member_descriptor = traits::make_shared(); - member_descriptor->type(inner_union_type); - member_descriptor->name("fourth"); - member_descriptor->id(2); - member_descriptor->label({1}); - builder->add_member(member_descriptor); - // Build the complex union type - DynamicType::_ref_type union_type {builder->build()}; - //!-- - } { //!--CPP_CUSTOM_ANNOTATION // Create the structure to annotate @@ -5183,6 +5307,29 @@ void dynamictypes_examples() type_builder->apply_annotation(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() @@ -5246,7 +5393,13 @@ void xml_profiles_examples() { // Retrieve the an instance of the desired type DynamicType::_ref_type my_struct_type; - DomainParticipantFactory::get_instance()->get_dynamic_type_builder_from_xml_by_name("MyStruct", 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 DynamicPubSubType(my_struct_type)); diff --git a/code/DynamicTypesIDLExamples.idl b/code/DynamicTypesIDLExamples.idl index aaa7cf814..e905aad69 100644 --- a/code/DynamicTypesIDLExamples.idl +++ b/code/DynamicTypesIDLExamples.idl @@ -42,12 +42,12 @@ struct PrimitivesStruct octet my_octet; int8 my_int8; uint8 my_uint8; - int16 my_short; - uint16 my_ushort; - int32 my_long; - uint32 my_unlong; - int64 my_longlong; - uint64 my_ulonglong; + short my_short; + unsigned short my_ushort; + long my_long; + unsigned long my_ulong; + long long my_longlong; + unsigned long long my_ulonglong; float my_float; double my_double; long double my_longdouble; @@ -64,27 +64,6 @@ struct StringsStruct }; //!-- -//!--IDL_ARRAYS -struct ArrayStruct -{ - int32 long_array[2][3][4]; -}; -//!-- - -//!--IDL_SEQUENCES -struct SequenceStruct -{ - sequence short_sequence; -}; -//!-- - -//!--IDL_MAPS -struct MapStruct -{ - map long_long_map; -}; -//!-- - //!--IDL_ENUM enum MyEnum { @@ -92,6 +71,7 @@ enum MyEnum B, C }; + struct EnumStruct { MyEnum my_enum; @@ -103,10 +83,11 @@ struct EnumStruct bitmask MyBitMask { @position(0) flag0, - @position(1) flag1, - @position(2) flag2, + flag1, + flag2, @position(5) flag5 }; + struct BitmaskStruct { MyBitMask my_bitmask; @@ -114,130 +95,98 @@ struct BitmaskStruct //!-- //!--IDL_TYPEDEF -typedef MyEnum MyAliasEnum; -typedef int32 MyAliasArray[2][2]; +typedef MyEnum MyAliasedEnum; +typedef string<100> MyAliasedBoundedString; +typedef MyAliasedEnum MyRecursiveAlias; + struct AliasStruct { - MyAliasEnum my_alias_enum; - MyAliasArray my_alias_array; + MyAliasedEnum my_aliased_enum; + MyAliasedBoundedString my_aliased_bounded_string; + MyRecursiveAlias my_recursive_alias; }; //!-- -//!--IDL_RECURSIVE_TYPEDEF -typedef uint32 RecursiveAlias; -typedef RecursiveAlias MyAlias; -struct RecursiveAliasStruct +//!--IDL_SEQUENCES +struct SequenceStruct { - MyAlias my_alias; + sequence bitmask_sequence; + sequence short_sequence; }; //!-- -//!--IDL_STRUCT -struct MyStruct +//!--IDL_ARRAYS +struct ArrayStruct { - int32 first; - int64 second; + long long_array[2][3][4]; }; //!-- -//!--IDL_UNION -union MyUnion switch (int16) -{ - case 0: - case 1: - int32 first; - case 2: - MyStruct second; - default: - int64 third; -}; -struct UnionStruct -{ - MyUnion my_union; -};//!-- - -//!--IDL_BITSET -bitset MyBitset -{ - bitfield<3> a; - bitfield<1> b; - bitfield<4>; - bitfield<10> c; - bitfield<12, short> d; -}; -struct BitsetStruct +//!--IDL_MAPS +struct MapStruct { - MyBitset my_bitset; + map string_alias_unbounded_map; + map short_long_map; }; //!-- -//!--IDL_BITSET_INHERITANCE -bitset ParentBitSet -{ - bitfield<3> a; - bitfield<1> b; -}; - -bitset ChildBitSet : ParentBitSet +//!--IDL_STRUCT +struct InnerStruct { - bitfield<10> c; - bitfield<12, short> d; + @id(0x10) long first; }; -//!-- -//!--IDL_STRUCT_INHERITANCE struct ParentStruct { - int32 first; - int64 second; + float first; + long long second; }; -struct ChildStruct : ParentStruct +struct ComplexStruct : ParentStruct { - int32 third; - int63 fourth; + InnerStruct complex_member; }; //!-- -//!--CPP_COMPLEX_STRUCTS -struct InnerStruct -{ - int32 first; +//!--IDL_UNION +union InnerUnion switch (short) +{ + case 0: + @id(0x10) PrimitivesStruct first; + case 1: + default: + long long second; }; -struct ComplexStruct -{ - InnerStruct complex_member; +union ComplexUnion switch (long) +{ + case 0: + case 1: + long third; + default: + InnerUnion fourth; }; //!-- -//!--IDL_COMPLEX_STRUCTS -struct InnerStruct +//!--IDL_BITSET +bitset ParentBitSet { - int32 first; + bitfield<3> a; + bitfield<1> b; + bitfield<4>; + bitfield<10> c; + bitfield<12, short> d; }; -struct ComplexStruct +bitset ChildBitSet : ParentBitSet { - InnerStruct complex_member; + bitfield<1> e; + bitfield<20, unsigned long> f; }; -//!-- -//!--IDL_COMPLEX_UNIONS -union InnerUnion switch (int32) -{ - case 0: - int64 first; - case 1: - int64 second; -}; - -union ComplexUnion switch (int32) +struct BitsetStruct { - case 0: - int32 third; - case 1: - InnerUnion fourth; + ChildBitSet my_bitset; }; //!-- diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 871da920f..06ab50df1 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -4296,6 +4296,7 @@ <--> + XML_STRINGS<--> @@ -4304,135 +4305,94 @@ <--> -XML_ARRAYS<--> - - - -<--> -XML_SEQUENCES<--> - - - -<--> -XML_MAPS<--> - - - -<--> + XML_ENUM<--> + <--> + XML_BITMASK<--> - + + <--> + XML_TYPEDEF<--> - - + + + + + - - + + + <--> -XML_RECURSIVE_TYPEDEF<--> - - - - + +XML_SEQUENCES<--> + + + + <--> -XML_STRUCT<--> - - - + +XML_ARRAYS<--> + + <--> -XML_UNION<--> - - - - - - - - - - - - - - - - - - + +XML_MAPS<--> + + + + <--> -XML_BITSET<--> - - -<--> + +XML_STRUCT<--> + + + + + -XML_BITSET_INHERITANCE<--> - -<--> -XML_STRUCT_INHERITANCE<--> -<--> -XML_COMPLEX_STRUCTS<--> - - - - + + - + --> <--> -XML_COMPLEX_UNIONS<--> + +XML_UNION<--> - + - + + @@ -4440,15 +4400,40 @@ - + + - + <--> +XML_BITSET<--> + + + + + + + + + + +<--> + +XML_CUSTOM_ANNOTATION<--> + +<--> + diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 4f1b4c7ba..ea93c9714 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -163,6 +163,7 @@ .. |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()` +.. |DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name-api| replace:: :cpp:func:`DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name()` .. |DomainParticipantFactoryQos-api| replace:: :cpp:class:`DomainParticipantFactoryQos` .. |DomainParticipantFactoryQos::entity_factory-api| replace:: :cpp:func:`entity_factory()` @@ -951,10 +952,19 @@ .. |EDPStatic| replace:: :cpp:class:`EDPStatic ` .. |AnnotationDescriptor-api| replace:: :cpp:class:`AnnotationDescriptor ` +.. |AnnotationDescriptor::set_value-api| replace:: :cpp:func:`AnnotationDescriptor::set_value() ` .. |DynamicData-api| replace:: :cpp:class:`DynamicData ` .. |DynamicData::get_member_id_by_name| replace:: :cpp:func:`DynamicData::get_member_id_by_name ` .. |DynamicData::loan_value| replace:: :cpp:func:`DynamicData::loan_value ` .. |DynamicData::return_loaned_value| replace:: :cpp:func:`DynamicData::return_loaned_value ` +.. |DynamicData::get_string_value| replace:: :cpp:func:`DynamicData::get_string_value ` +.. |DynamicData::get_wstring_value| replace:: :cpp:func:`DynamicData::get_wstring_value ` +.. |DynamicData::set_string_value| replace:: :cpp:func:`DynamicData::set_string_value ` +.. |DynamicData::set_wstring_value| replace:: :cpp:func:`DynamicData::set_wstring_value ` +.. |DynamicData::get_boolean_value| replace:: :cpp:func:`DynamicData::get_boolean_value ` +.. |DynamicData::set_boolean_value| replace:: :cpp:func:`DynamicData::set_boolean_value ` +.. |DynamicData::get_complex_value| replace:: :cpp:func:`DynamicData::get_complex_value ` +.. |DynamicData::set_complex_value| replace:: :cpp:func:`DynamicData::set_complex_value ` .. |DynamicDataFactory-api| replace:: :cpp:class:`DynamicDataFactory ` .. |DynamicPubSubType-api| replace:: :cpp:class:`DynamicPubSubType ` .. |DynamicType-api| replace:: :cpp:class:`DynamicType ` @@ -962,9 +972,11 @@ .. |DynamicTypeBuilder::add_member| replace:: :cpp:func:`DynamicTypeBuilder::add_member ` .. |DynamicTypeBuilder::apply_annotation| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation ` .. |DynamicTypeBuilder::apply_annotation_to_member| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation_to_member ` +.. |DynamicTypeBuilder::build| replace:: :cpp:func:`DynamicTypeBuilder::build ` .. |DynamicTypeBuilderFactory-api| replace:: :cpp:class:`DynamicTypeBuilderFactory ` .. |DynamicTypeBuilderFactory::get_primitive_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::get_primitive_type ` .. |DynamicTypeBuilderFactory::create_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type ` +.. |DynamicTypeBuilderFactory::create_type_w_type_object| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type_w_type_object ` .. |DynamicTypeBuilderFactory::create_string_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_string_type ` .. |DynamicTypeBuilderFactory::create_wstring_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_wstring_type ` .. |DynamicTypeBuilderFactory::create_sequence_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_sequence_type ` @@ -973,16 +985,11 @@ .. |DynamicTypeBuilderFactory::create_bitmask_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_bitmask_type ` .. |DynamicTypeMember-api| replace:: :cpp:class:`DynamicTypeMember ` .. |MemberDescriptor-api| replace:: :cpp:class:`MemberDescriptor ` -.. |MemberDescriptor::label| replace:: :cpp:func:`MemberDescriptor::label ` -.. |MemberDescriptor::is_key| replace:: :cpp:func:`MemberDescriptor::is_key ` -.. |MemberDescriptor::is_default_label| replace:: :cpp:func:`MemberDescriptor::is_default_label ` .. |TypeDescriptor-api| replace:: :cpp:class:`TypeDescriptor ` -.. |TypeDescriptor::extensibility_kind| replace:: :cpp:func:`TypeDescriptor::extensibility_kind ` -.. |TypeDescriptor::base_type| replace:: :cpp:func:`TypeDescriptor::base_type ` -.. |TypeDescriptor::discriminator_type| replace:: :cpp:func:`TypeDescriptor::discriminator_type ` .. |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()` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index 83b7419b0..88fac10be 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -82,26 +82,7 @@ .. |whitelist| replace:: :ref:`Whitelist ` .. |MemoryManagementPolicy| replace:: :ref:`MemoryManagementPolicy` -.. |DynamicTypes| replace:: :ref:`DynamicTypes` -.. |Supported Types| replace:: :ref:`Supported Types` -.. |Primitive Types| replace:: :ref:`Primitive Types` -.. |String and WString| replace:: :ref:`String and WString` -.. |Alias| replace:: :ref:`Alias` -.. |Alias of an alias| replace:: :ref:`Alias of an alias` -.. |Enumeration| replace:: :ref:`Enumeration` -.. |Bitmask| replace:: :ref:`Bitmask` -.. |Structure| replace:: :ref:`Structure` -.. |Bitset| replace:: :ref:`Bitset` -.. |Union| replace:: :ref:`Union` -.. |Sequence| replace:: :ref:`Sequence` -.. |Array| replace:: :ref:`Array` -.. |Map| replace:: :ref:`Map` -.. |Complex Types| replace:: :ref:`Complex Types` -.. |Structure inheritance| replace:: :ref:`Structure inheritance` -.. |Bitset inheritance| replace:: :ref:`Bitset inheritance` -.. |Nested Structures| replace:: :ref:`Nested Structures` -.. |Nested Unions| replace:: :ref:`Nested Unions` - +.. |DynamicTypes| replace:: :ref:`Dynamic Language Binding` .. |TypeObject| replace:: :ref:`TypeObject` .. |TypeInformation| replace:: :ref:`TypeInformation` diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst index 1802207a9..7288a4e8d 100644 --- a/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst +++ b/docs/fastdds/api_reference/dds_pim/xtypes/dynamic_types.rst @@ -1,5 +1,7 @@ -Dynamic Types -============= +.. _dynamic_language_binding_api: + +Dynamic Language Binding +======================== .. toctree:: 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..dd54f2407 --- /dev/null +++ b/docs/fastdds/use_cases/remote_type_discovery_matching/remote_type_discovery_matching.rst @@ -0,0 +1,58 @@ +.. 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 is focused on the strategy that has to be followed in order to create an endpoint in 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 corresponding |DomainParticipantListener::on_data_reader_discovery-api| or +|DomainParticipantListener::on_data_writer_discovery-api| callback will be called, depending on the kind of endpoint +created on the remote participant. +The endpoint discovery callback provides access to the remote discovered information which includes 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 can then be obtained and registered using |DynamicPubSubType-api|. + +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/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/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 3271db276..7d7d2476a 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. @@ -38,57 +37,45 @@ 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 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`_ - -Member types -"""""""""""" - -Member types are defined as any type that can belong to a `Struct`_ or a `Union`_, or be aliased by a -`Typedef`_. -These can be defined by the ```` XML tag. +* `Primitive types`_ +* `String types`_ +* `Enumeration types`_ +* `Bitmask types`_ +* `Alias types`_ +* `Sequence types`_ +* `Array types`_ +* `Map types`_ +* `Structure types`_ +* `Union types`_ +* `Bitset types`_ .. _xmldynamictypes_primivites: Primitive types -*************** +""""""""""""""" -The identifiers of the available basic types are listed in the table below. -Please, refer to :ref:`xtypes_supportedtypes_primitive` for more information on the primitive types. +Primitive types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). +Primitive types are defined 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`` - ``char8`` - ``char16`` - * - ``byte`` - - ``octet`` + - ``byte`` + * - ``octet`` - ``uint8`` - * - ``int8`` + - ``int8`` - ``int16`` - - ``int32`` - * - ``uint16`` + * - ``int32`` + - ``uint16`` - ``uint32`` - ``int64`` * - ``uint64`` - ``float32`` - ``float64`` - * - ``float128`` - - ``string`` - - ``wstring`` + - ``float128`` All of them are defined as follows: @@ -101,23 +88,22 @@ All of them are defined as follows: :start-after: XML_PRIMITIVES<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_PRIMITIVES + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_PRIMITIVES :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Primitives `. .. _xmldynamictypes_strings: -Bounded strings -*************** +String Types +"""""""""""" -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:`xtypes_supportedtypes_string` for more information on string type. +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. .. tabs:: @@ -128,109 +114,57 @@ Please, refer to :ref:`xtypes_supportedtypes_string` for more information on str :start-after: XML_STRINGS<--> :end-before: <--> - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_STRINGS - :end-before: //!-- - -For a full example of how to define this type, please refer to :ref:`Strings `. - -.. _xmldynamictypes_sequence: - -Sequences -********* - -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:`xtypes_supportedtypes_sequence` section for more information on sequence type. - -.. tabs:: - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_SEQUENCES<--> - :end-before: <--> - - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_SEQUENCES + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_STRINGS :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Sequences `. - -.. _xmldynamictypes_array: - -Arrays -****** - -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:`xtypes_supportedtypes_array` explanation for more information on array type. - -.. tabs:: - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_ARRAYS<--> - :end-before: <--> - - .. tab:: C++ +.. _xmldynamictypes_enums: - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_ARRAYS - :end-before: //!-- +Enumeration Types +""""""""""""""""" -For a full example of how to define this type, please refer to :ref:`Arrays `. +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. -.. _xmldynamictypes_map: +.. note:: -Maps -**** + :code:`value` attribute is equivalent to :code:`@value` builtin annotation which is not still supported in neither + the plain (IDL) nor dynamic language binding. -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:`xtypes_supportedtypes_map` for more information on map type. +Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information on enumeration types. .. tabs:: - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_MAPS<--> - :end-before: <--> + .. tab:: XML - .. tab:: C++ + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ENUM<--> + :end-before: <--> - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_MAPS - :end-before: //!-- + .. tab:: IDL -For a full example of how to define this type, please refer to :ref:`Maps `. + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_ENUM + :end-before: //!-- -.. _xmlxtypes_complextypes: +.. _xmldynamictypes_bitmask: -Complex types +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:`xtypes_complextypes` section for more information on complex types. - -The following example shows structure having another structure as a member. +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. .. tabs:: @@ -238,19 +172,25 @@ The following example shows structure having another structure as a member. .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_COMPLEX_STRUCTS<--> + :start-after: XML_BITMASK<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_COMPLEX_STRUCTS + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_BITMASK :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Nested Types `. +.. _xmldynamictypes_typedef: + +Alias Types +""""""""""" -This example shows union having another union as a member. +Alias types are defined using the :code:`` tag. +Attributes :code:`name` and :code:`type` are mandatory. +Depending on the aliased type, any other attribute might be required or optionally added. +Please, refer to :ref:`xtypes_supportedtypes_alias` for more information on alias types. .. tabs:: @@ -258,167 +198,127 @@ This example shows union having another union as a member. .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_COMPLEX_UNIONS<--> + :start-after: XML_TYPEDEF<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_COMPLEX_UNIONS + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_TYPEDEF :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Nested Types `. - -Complex types attributes -************************ +.. _xmldynamictypes_sequence: -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. +Sequence Types +"""""""""""""" -.. 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`_. +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. -.. _xmldynamictypes_typedef: +.. important:: -Typedef -""""""" + Currently, unbounded sequences cannot be defined using XML profiles. -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:`xtypes_supportedtypes_alias` in :ref:`xtypes_supportedtypes` -section. +Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on sequence types. .. tabs:: - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_TYPEDEF<--> - :end-before: <--> + .. tab:: XML - .. tab:: C++ + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_SEQUENCES<--> + :end-before: <--> - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_TYPEDEF - :end-before: //!-- + .. tab:: IDL -For a full example of how to define this type, please refer to :ref:`Alias `. + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_SEQUENCES + :end-before: //!-- -.. _xmldynamictypes_enums: +.. _xmldynamictypes_array: -Enumerations -"""""""""""" +Array 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:`xtypes_supportedtypes_enumeration` for more information on the ```` type. +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. .. tabs:: - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_ENUM<--> - :end-before: <--> + .. tab:: XML - .. tab:: C++ + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_ARRAYS<--> + :end-before: <--> - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_ENUM - :end-before: //!-- + .. tab:: IDL -For a full example of how to define this type, please refer to :ref:`Enumerations `. + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_ARRAYS + :end-before: //!-- -.. _xmldynamictypes_struct: +.. _xmldynamictypes_map: -Struct -"""""" +Map Types +""""""""" -The ```` element is defined by its ``name`` attribute and its ```` child elements. -Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on the ```` type. +Maps 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. -.. tabs:: +.. important:: - .. tab:: XML + Currently, unbounded maps cannot be defined using XML profiles. - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_STRUCT<--> - :end-before: <--> +Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map types. - .. tab:: C++ +.. tabs:: - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_STRUCT - :end-before: //!-- + .. tab:: XML -For a full example of how to define this type, please refer to :ref:`Structures `. + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML_MAPS<--> + :end-before: <--> -.. _xmldynamictypes_struct_inheritance: + .. 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: idl + :start-after: //!--IDL_MAPS + :end-before: //!-- -.. tabs:: +.. _xmldynamictypes_struct: - .. tab:: XML +Structure Types +""""""""""""""" - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_STRUCT_INHERITANCE<--> - :end-before: <--> +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. - .. tab:: C++ +.. note:: - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_STRUCT_INHERITANCE - :end-before: //!-- + `IDL specification `__ introduced in version 4.1 the possibility of void + content structures. + Empty structures are not supported in XML Types profiles yet. -For a full example of how to define this type, please refer to -:ref:`Structures Inheritance `. +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. -.. _xmldynamictypes_union: +.. note:: -Union -""""" + Currently, XML Types profiles does not support setting the member ID or marking a member as key. -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:`xtypes_supportedtypes_union` for more information on the ```` type. +Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on structure types. .. tabs:: @@ -426,55 +326,42 @@ Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_UNION<--> + :start-after: XML_STRUCT<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_UNION + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_STRUCT :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Unions `. - -.. _xmldynamictypes_bitset: - -Bitset -"""""" - -The ```` element defines the :ref:`xtypes_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:`xtypes_supportedtypes_bitset` for more information about the ```` type. - -.. tabs:: +.. _xmldynamictypes_union: - .. tab:: XML +Union Types +""""""""""" - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_BITSET<--> - :end-before: <--> +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 as mandatory attribute :code:``. - .. tab:: C++ +Union types also require at least one case child defined using the :code:`` tag. +Each case child requires at least one caseDiscriminator child using the :code:`` tag. +:code:`value` attribute is mandatory and defines the label associated with that specific caseDiscriminator. +Several labels might be defined using several caseDiscriminator elements. +Each case child must have exclusively one union member defined. - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_BITSET - :end-before: //!-- +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. -For a full example of how to define this type, please refer to :ref:`Bitset `. +.. note:: -.. _xmlxtypes_bitset_inheritance: + Currently, XML Types profiles does not support setting the member ID or marking a member as key. -Moreover, bitsets can inherit from another bitsets. -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. +Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the union types. .. tabs:: @@ -482,30 +369,32 @@ This is exemplified by the code snippet below. .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_BITSET_INHERITANCE<--> + :start-after: XML_UNION<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_BITSET_INHERITANCE + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_UNION :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Bitset Inheritance `. +.. _xmldynamictypes_bitset: -.. _xmldynamictypes_bitmask: +Bitset Types +"""""""""""" -Bitmask -""""""" +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. -The ```` element, which corresponds to the :ref:`xtypes_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:`xtypes_supportedtypes_bitmask` for more information on the ```` type. +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:: @@ -513,25 +402,26 @@ Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on th .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_BITMASK<--> + :start-after: XML_BITSET<--> :end-before: <--> - .. tab:: C++ + .. tab:: IDL - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_BITMASK + .. literalinclude:: /../code/DynamicTypesIDLExamples.idl + :language: idl + :start-after: //!--IDL_BITSET :end-before: //!-- -For a full example of how to define this type, please refer to :ref:`Bitmasks `. - .. _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-api| 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++ diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index e2f31a18a..4d6920a4b 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -7,8 +7,8 @@ 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 -extesible types compatibility rules configured using the :ref:`typeconsistencyenforcementqospolicy`. +`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:: @@ -37,13 +37,20 @@ 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|/ + 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. @@ -66,3 +73,9 @@ The remote data type discovery feature only works if some requisites are met: 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 index d55896569..c74514587 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -7,88 +7,91 @@ Dynamic Language Binding ======================== -*eProsima Fast DDS* supports several methods to define |DynamicTypes|. -Manual creation using |DynamicTypeBuilderFactory-api| and |DynamicTypeBuilder-api| to create the types. +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. -:ref:`XMLDynamicTypes ` allows *eProsima Fast DDS* to create DynamicTypes by defining -them directly through XML. +This section presents first the Dynamic Language Binding API, and then the supported types and specific examples +defining and using those types. -This section contains an small description of the interfaces used to work with |DynamicTypes| and a detailed -explanation of how to create |DynamicTypes| in the manual way, as well as the same examples using XML files. +.. _xtypes_interfaces: -.. _xtypes_intenfaces: +Dynamic Language Binding Interfaces +----------------------------------- -Dynamic Types Interfaces ------------------------- - -DynamicTypeBuilderFactory -^^^^^^^^^^^^^^^^^^^^^^^^^ -The |DynamicTypeBuilderFactory-api| serves as a singleton which instance is responsible for creating |DynamicTypes| and -serves as the entry point for both creating and deleting |DynamicTypeBuilder-api| objects. -The simpler types can be directly instantiated without the need for a DynamicTypeBuilder. -Refer to the Supported Types documentation for details on which types support this direct creation option. - -AnnotationDescriptor -^^^^^^^^^^^^^^^^^^^^ -|AnnotationDescriptor-api| encapsulates the state of an annotation when applied to an element (not an annotation type). +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| stores the state of a type, including its structure, relationships, and constraints. -As the class responsible for describing the inner structure of a DynamicType, -When the DynamicType is created, DynamicTypeBuilderFactory utilizes the information from the TypeDescriptor to -instantiate the DynamicType. -This information is then copied to the DynamicType during creation, gaining independence from the DynamicTypeBuilder -so the builder can be reused for another type. +|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. -DynamicTypeMember -^^^^^^^^^^^^^^^^^ -|DynamicTypeMember-api| represents a data member of a DynamicType that itself is a DynamicType. -Dynamic types that are composed of other dynamic types have a DynamicTypeMember for every child -DynamicType added to it. -Functioning as the representation of a "member" of a type, it may be a member of an aggregate type, -or constants within enumerations, or other types of substructure. +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| encapsulates the state of a DynamicTypeMember. -Analogous to TypeDescriptor's role in describing the inner structure of a DynamicType, MemberDescriptor -stores all essential information for managing a DynamicTypeMember. -This information, including member name, unique ID, and default value, is copied to the DynamicData -upon its creation. + +|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 represent a type's schema, including its name, type kind, and member definitions. -As the base class for all dynamically declared types, it is the representation of a dynamic data type used -for creating DynamicData values. -Once created, the structure of a DynamicType cannot be modified. + +|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 that is in itself a DynamicType. +Consequently, the same remarks affecting DynamicTypes, also applies to DynamicTypeMembers. DynamicTypeBuilder ^^^^^^^^^^^^^^^^^^ -|DynamicTypeBuilder-api| represents the transitional state of a type defined in the Type System. -It enables the instantiation of concrete DynamicType objects and serves as an intermediary for configuring a -DynamicType before its creation. -A DynamicType's composition must be defined before its creation, with the builder facilitating this setup, -and its structure cannot be modified once the object is created. + +|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. -The builder offers a :func:`build` function for convenient creation of a fully constructed DynamicType, -utilizing DynamicTypeBuilderFactory internally. +|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|, logically a singleton, oversees the creation of DynamicData objects. -As the sole entry point for creating and deleting DynamicData and objects, it operates similarly to the singleton -DomainParticipantFactory. -This singleton class manages every DynamicData instance, capable of generating an instance corresponding to a specified -DynamicType. + +|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. @@ -99,19 +102,22 @@ Offering reflective getters and setters, DynamicData enables manipulation of ind 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: -Primitives -^^^^^^^^^^ +Primitive Types +^^^^^^^^^^^^^^^ -By definition, primitive types are self-describing and can be created without configuration parameters. -Therefore, the |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::get_primitive_type| -to allow users to create the type bypassing the |DynamicTypeBuilder-api| step. -The |DynamicData-api| class has a specific :func:`get_value` and :func:`set_value` functions for each primitive -type in the list. +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 ``TypeKind``. -The ``TypeKind`` is used to identify the type when it is created. +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 @@ -148,7 +154,7 @@ The ``TypeKind`` is used to identify the type when it is created. * - :code:`long double` - :code:`TK_FLOAT128` -This example shows how to create members of each primitive type using |DynamicTypeBuilderFactory-api|. +The example below shows how to create an structure with primitive members. .. tabs:: @@ -174,20 +180,76 @@ This example shows how to create members of each primitive type using |DynamicTy :end-before: //!-- For a detailed explanation about the XML definition of this type, -please refer to :ref:`Primitives `. +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_FLOAT64` + * - :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:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, + :code:`TK_FLOAT128` + * - :code:`TK_CHAR16` + - :code:`TK_INT32`, :code:`int64_t`, :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: -Strings -^^^^^^^ +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. -Strings are quite similar to primitive types, the main difference being that they need to set their size limit. +|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). -The |DynamicTypeBuilderFactory-api| exposes the functions |DynamicTypeBuilderFactory::create_string_type| and -|DynamicTypeBuilderFactory::create_wstring_type| to allow users to create them directly. -These functions take a parameter to set the maximum length of the string, using ``LENGTH_UNLIMITED`` -to set it to unlimited. -The |DynamicData-api| class has a specific :func:`get_string_value` and :func:`set_string_value`. +|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:: @@ -212,28 +274,36 @@ The |DynamicData-api| class has a specific :func:`get_string_value` and :func:`s :start-after: //!--CPP_STRINGS :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Primitives `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML String Types `. + -Constructed Types +.. _xtypes_supportedtypes_enumeration: + +Enumeration Types ^^^^^^^^^^^^^^^^^ -Enumerated 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`. -.. _xtypes_supportedtypes_enumeration: +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`. -Enumerations -************ +.. note:: -An enumeration contains a set of supported values and a selected value among those supported. -The ``TypeKind`` used to identify Enumerations is ``TK_ENUM``. + Currently, Fast DDS-Gen does not support :code:`@value` builtin annotation. -The supported values must be configured using the |DynamicTypeBuilder-api|, using the |DynamicTypeBuilder::add_member| -function for the respective supported values. -The type to which the enumeration will be bound to is determined the first time -|DynamicTypeBuilder::add_member| is invoked by taking the type of that member. -Subsequently added members must follow the same type. +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:: @@ -258,24 +328,35 @@ Subsequently added members must follow the same type. :start-after: //!--CPP_ENUM :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Enumerations `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Enumeration Types `. + .. _xtypes_supportedtypes_bitmask: -Bitmasks -******** +Bitmask Types +^^^^^^^^^^^^^ -Bitmasks are similar to |Enumeration| types, but their members act as bit flags that can be turned on and -off individually. -The ``TypeKind`` used to identify Bitmasks is ``TK_BITMASK``. +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. -These flags might use the ``id`` attribute to set their position in the bitmask. -The ``bound`` attribute specifies the number of bits that the bitmask type will manage. -Bitmasks can be bound to any number of bits up to 64. The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_bitmask_type| to -facilitate the creation of this type. -The members added to a bitmask using |DynamicTypeBuilder::add_member| must be of type ``TK_BOOLEAN``. +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:: @@ -300,20 +381,21 @@ The members added to a bitmask using |DynamicTypeBuilder::add_member| must be of :start-after: //!--CPP_BITMASK :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Bitmask `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Bitmask Types`. + .. _xtypes_supportedtypes_alias: -Alias -""""" +Alias Types +^^^^^^^^^^^ Alias types provide an alternative name to an already existing type. -The ``TypeKind`` used to identify Alias is ``TK_ALIAS``. +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, users can access its information as if they were working with the base type. -To create an alias type, users must use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| with -the existing type they want the alias to represent. +Once the |DynamicData-api| is created, information can be accessed as if working with the base type. .. tabs:: @@ -338,57 +420,35 @@ the existing type they want the alias to represent. :start-after: //!--CPP_TYPEDEF :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Typedef `. - -.. _xtypes_complextypes_aliasalias: - -Alias types support recursion, simply by using an alias as base type for :|TypeDescriptor::base_type|. - -.. tabs:: - - .. tab:: IDL - - .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl - :start-after: //!--IDL_RECURSIVE_TYPEDEF - :end-before: //!-- - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_RECURSIVE_TYPEDEF<--> - :end-before: <--> - - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_RECURSIVE_TYPEDEF - :end-before: //!-- - -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Primitives `. - -Collections -""""""""""" +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Alias Types`. .. _xtypes_supportedtypes_sequence: -Sequences -********* +Sequence types +^^^^^^^^^^^^^^ -A complex type that manages its members as a list of elements allowing users to insert, -remove or access to a member of the list. +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 might be configured to set a maximum length for the collection. +Otherwise, the collection is considered to be unbounded. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to +|DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_sequence_type| to facilitate the creation of this type. -To create this type, the user must specify the type to be stored. -Additionally, the size limit of the list. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. +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`. -The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each primitive -type, allowing users to work with multiple values at once. +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:: @@ -413,26 +473,38 @@ type, allowing users to work with multiple values at once. :start-after: //!--CPP_SEQUENCES :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Sequences `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Sequence Types `. .. _xtypes_supportedtypes_array: -Arrays -****** - -Arrays are very similar to sequences with two main differences: -They can have multiple dimensions and their elements are initialized to the default value at the start. +Array types +^^^^^^^^^^^ -An array needs to know the number of dimensions it manages. -The user must provide a vector with as many elements as there are dimensions in the array. -Each element in the vector represents the size of the given dimension. +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. -The |DynamicTypeBuilderFactory-api| exposes the function |DynamicTypeBuilderFactory::create_array_type| to +|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:: -The |DynamicData-api| class has a specific :func:`get_values` and :func:`set_values` functions for each -primitive type that allow users to work with multiple values at once. + 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:: @@ -457,30 +529,38 @@ primitive type that allow users to work with multiple values at once. :start-after: //!--CPP_ARRAYS :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Arrays `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Array Types`. .. _xtypes_supportedtypes_map: -Maps -**** +Map Types +^^^^^^^^^ -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. +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. -The |DynamicTypeBuilderFactory-api| exposes the |DynamicTypeBuilderFactory::create_map_type| function to -facilitate the creation of this type. -To create a map, users must set the types of the key and the value elements. -Additionally, the size limit of the map. Users can use ``LENGTH_UNLIMITED`` to create unbounded sequences. +.. note:: -The |DynamicData-api| class has a specific :func:`get__values` and :func:`set___values` functions for each primitive -type that allow users to work with multiple values at once. + Currently, wide string keys are not supported as map keys. -To access the members of the map using the keys, users can use the |DynamicData::get_member_id_by_name| function to get -the ``MemberId`` of the desired element key, and use it to modify the value of said element. -Note that parameter used in |DynamicData::get_member_id_by_name| as the key name, must be the correct ``string`` -representation of the value of the key. +Additionally, :code:`bound` property might be configured to set a maximum length for the collection. + +|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. +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:: @@ -505,30 +585,58 @@ representation of the value of the key. :start-after: //!--CPP_MAPS :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Maps `. - -Aggregated Types -"""""""""""""""" +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Map Types`. .. _xtypes_supportedtypes_structure: -Structures -********** +Structure Types +^^^^^^^^^^^^^^^ -Structures are the most common aggregated types, they allow any kind of members to be added inside them. -They do not have any value, they are only used to contain other 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. -The function |DynamicTypeBuilderFactory::create_type| is used to create a new structure type. -The ``TypeKind`` used to identify structures is ``TK_STRUCTURE``. +.. note:: -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 its ``id``. -If the structure contains a complex value, |DynamicData::loan_value| should be used to access it and -|DynamicData::return_loaned_value| should be used to release that loan. -|DynamicData-api| manages the loaned values and users cannot loan a previously loaned value -without calling |DynamicData::return_loaned_value| before. + 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 configured 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:: @@ -553,29 +661,76 @@ without calling |DynamicData::return_loaned_value| before. :start-after: //!--CPP_STRUCT :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Struct `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Structure Types`. .. _xtypes_supportedtypes_union: -Unions -****** - -Unions are a special type of structure where only one of the members is active at a time. -The ``TypeKind`` used to identify unions is ``TK_UNION``. - -To control these members, users must set the ``discriminator`` type that is going to be used to select the current -member by calling the |TypeDescriptor::discriminator_type| function of the union type. -The ``discriminator`` itself is a DynamicType that must be of any of the following types: -- Boolean. -- Byte. -- Char8, Char16. -- Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64. -- An enumerated type. -- Any alias type that resolves, directly or indirectly, to one of the aforementioned types. +Union Types +^^^^^^^^^^^ -In addition, users can use the |MemberDescriptor::label| function with one or more values to set the labels of each -member of the union, and |MemberDescriptor::is_default_label| to set the default label of the union. +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 configured 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:: @@ -600,20 +755,30 @@ member of the union, and |MemberDescriptor::is_default_label| to set the default :start-after: //!--CPP_UNION :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Union `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Union Types`. .. _xtypes_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. +Bitset Types +"""""""""""" -Each bitfield in a bitset can be modified through their minimal needed primitive representation. +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. +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 @@ -634,7 +799,6 @@ Each bitfield in a bitset can be modified through their minimal needed primitive 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. -The ``TypeKind`` used to identify Bitsets is ``TK_BITSET``. .. tabs:: @@ -659,133 +823,47 @@ The ``TypeKind`` used to identify Bitsets is ``TK_BITSET``. :start-after: //!--CPP_BITSET :end-before: //!-- -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Bitset `. +For a detailed explanation about the XML definition of this type, please refer to +:ref:`XML Bitset Types`. -.. _xtypes_complextypes: - -Complex types -^^^^^^^^^^^^^ - -In complex data models, combinations of basic types :ref:`basic types` -can be used to create intricate structures, including nested compositions such as structures within structures. -Additionally, types can be extended using inheritance to enhance flexibility. - -The following subsections describe these *complex types* and their use. - -Inheritance -""""""""""" - -.. _xtypes_structure_inheritance: - -Structures allow inheritance, exactly with the same OOP meaning. -To inherit from another structure, users must create the parent structure calling the -|DynamicTypeBuilderFactory::create_type| normally. -After the parent type is created, use the |TypeDescriptor::base_type| function from the |TypeDescriptor-api| -when creating the child structure, using the parent type as the base type. - -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. - -.. tabs:: - - .. tab:: IDL - - .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl - :start-after: //!--IDL_STRUCT_INHERITANCE - :end-before: //!-- - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_STRUCT_INHERITANCE<--> - :end-before: <--> - - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_STRUCT_INHERITANCE - :end-before: //!-- - -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Struct `. - -.. _xtypes_bitset_inheritance: - -Bitsets allows inheritance as well, exactly with the same OOP meaning. -To inherit from another bitset, users must follow the same process as with -:ref:`structures `, but using bitset types. - -.. tabs:: - - .. tab:: IDL - - .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl - :start-after: //!--IDL_BITSET_INHERITANCE - :end-before: //!-- - - .. tab:: XML - - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_BITSET_INHERITANCE<--> - :end-before: <--> - - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_BITSET_INHERITANCE - :end-before: //!-- - -For a detailed explanation about the XML definition of this type, -please refer to :ref:`Bitset `. - -Nested Types -"""""""""""" +Annotations +^^^^^^^^^^^ -.. _xtypes_nested_structures: +Custom annotations +"""""""""""""""""" -Structures can contain other structures as members. -The access to these compound members is restricted and managed by the |DynamicData-api| instance. -Users must request access calling |DynamicData::loan_value| before using them, -and release them with |DynamicData::return_loaned_value| once they finished. -The loan operation will fail if the member is already loaned and has not been released yet. +Both types and type members might be annotated using |DynamicTypeBuilder::apply_annotation| and +|DynamicTypeBuilder::apply_annotation_to_member| API respectively. -.. tabs:: +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. - .. tab:: IDL - - .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl - :start-after: //!--IDL_COMPLEX_STRUCTS - :end-before: //!-- +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: - .. tab:: XML +* `Primitive types`_ +* `String types`_ +* `Enumeration types`_ - .. literalinclude:: /../code/XMLTester.xml - :language: xml - :start-after: XML_COMPLEX_STRUCTS<--> - :end-before: <--> +.. note:: - .. tab:: C++ + Currently, wide string types are not supported as annotation parameters. - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_COMPLEX_STRUCTS - :end-before: //!-- +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. -.. _xtypes_nested_unions: +.. note:: -Unions support complex type fields. -The access to these complex type fields is restricted and managed by the |DynamicData-api| instance. -Users must request access calling |DynamicData::loan_value| before using them, -and release them with |DynamicData::return_loaned_value| once they finished. -The loan operation will fail if the fields is already loaned and has not been released yet. + Currently, custom annotations are not supported with :ref:`XML DynamicTypes `. .. tabs:: @@ -793,54 +871,16 @@ The loan operation will fail if the fields is already loaned and has not been re .. literalinclude:: /../code/DynamicTypesIDLExamples.idl :language: idl - :start-after: //!--IDL_COMPLEX_UNIONS + :start-after: //!--IDL_CUSTOM_ANNOTATION :end-before: //!-- .. tab:: XML .. literalinclude:: /../code/XMLTester.xml :language: xml - :start-after: XML_COMPLEX_UNIONS<--> + :start-after: XML_CUSTOM_ANNOTATION<--> :end-before: <--> - .. tab:: C++ - - .. literalinclude:: /../code/DDSCodeTester.cpp - :language: c++ - :start-after: //!--CPP_COMPLEX_UNIONS - :end-before: //!-- - - -For a detailed explanation about the XML definition of this types, -please refer to :ref:`Complex types `. - -Annotations -^^^^^^^^^^^ - -|DynamicTypeBuilder-api| allows applying an annotation to both current type and inner members with the functions. -To add the annotations to the types, the function |DynamicTypeBuilder::apply_annotation| is used, and -|DynamicTypeBuilder::apply_annotation_to_member| to add them to the members. - -Both functions take the :class:`AnnotationDescriptor` of the annotation to be added, -and |DynamicTypeBuilder::apply_annotation_to_member| additionally receives the ``MemberId`` of the inner member. - - -Custom annotations -"""""""""""""""""" - -|DynamicTypes| allows users to create custom annotations to add extra information to the types. - -:ref:`XMLDynamicTypes ` does not currently support custom annotations. - -.. tabs:: - - .. tab:: IDL - - .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl - :start-after: //!--IDL_CUSTOM_ANNOTATION - :end-before: //!-- - .. tab:: C++ .. literalinclude:: /../code/DDSCodeTester.cpp @@ -852,83 +892,109 @@ Custom annotations Builtin annotations """"""""""""""""""" -Beside the custom annotations created by the users, there are a number of builtin annotations. +Beside the user-defined custom annotations, there are a number of builtin annotations that have already mentioned +throughout this section. -Currently, |DynamicTypes| supports the following builtin annotations: +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 - - Behavior + - 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` - - This annotation applies to any type declaration and defines |br| - how the type is allowed to evolve. - More info in :ref:`extensibility`. + - |TypeDescriptor-api| :code:`extensibility_kind` property. + - ✅ + - ❌ + * - :code:`@external` + - |MemberDescriptor-api| :code:`is_shared` property. + - ❌ + - ❌ * - :code:`@final` - - Shortcut for :code:`@extensibility(FINAL)`. - * - :code:`@appendable` - - Shortcut for :code:`@extensibility(APPENDABLE)`. + - |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` - - Shortcut for :code:`@extensibility(MUTABLE)` - * - :code:`@key` - - Mark a member as part of the key (please refer to :ref:`dds_layer_topic_instances` |br| - for more information). - * - :code:`@Key` - - :code:`@key` alias. + - |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. -To apply the @extensibility annotation (and its shortcuts) the |TypeDescriptor-api| exposes the function -|TypeDescriptor::extensibility_kind|, that receives a :class:`ExtensibilityKind`. +.. _xtypes_complextypes: -For the @key annotation the function |MemberDescriptor::is_key| can be fount in |MemberDescriptor-api|. +Managing Complex Types Data +^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Type promotions ---------------- - -|DynamicTypes| 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. +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: -The following promotions are supported: +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. -.. list-table:: - :header-rows: 1 - :align: left +The following snippet includes an example of managing complex data using the same structure as the one defined in +`Structure types`_: - * - 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:`lonf TK_FLOAT64` - * - :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:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, - :code:`TK_FLOAT128` - * - :code:`TK_CHAR16` - - :code:`TK_INT32`, :code:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` - * - :code:`TK_BYTE` - - (any) - * - :code:`TK_BOOLEAN` - - :code:`TK_INT8`, `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` +.. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //!--CPP_COMPLEX_DATA + :end-before: //!-- diff --git a/docs/fastddsgen/dataTypes/dataTypes.rst b/docs/fastddsgen/dataTypes/dataTypes.rst index d3d7ff810..29d3f7426 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,7 +453,7 @@ Annotations -------------- The application allows the user to define and use their own annotations as defined in the -`OMG IDL 4.2 specification `_. +`OMG IDL specification `_. .. code-block:: omg-idl @@ -462,73 +463,122 @@ The application allows the user to define and use their own annotations as defin string name; }; -Additionally, the following standard annotations are builtin (recognized and passed to TypeObject when unimplemented). - -+-------------------------+--------------------------------------------------------------------------------------------+ -| Annotation | Implemented behavior | -+=========================+============================================================================================+ -| @id | Assign a 32-bit integer identifier to an element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @autoid | 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 a element.Used by enumeration's members. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @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 | Indicate that the data member must be understood by any application |br| | -| | making use of that piece of data. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @default_literal | Allow selecting one member as the default within a collection. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @default | [Unimplemented] 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 | Allow specifying a unit of measurement for the annotated element. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @bit_bound | Allow setting a size to a bitmasks_. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @external | Force the annotated element to be placed in a dedicated data space. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @nested | Allow indicating that the objects from the type under annotation will |br| | -| | always be nested within another one. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @verbatim | Allow injecting some user-provided information into what the compiler |br| | -| | will generate. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @service | Allow indicating that an interface is to be treated as a service. | -+-------------------------+--------------------------------------------------------------------------------------------+ -| @oneway | 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 | 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) 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/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 64e3a55fe..3a9b03e34 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -31,6 +31,7 @@ backports benchmarking bitfield Bitfields +bitflags bitmask bitmasks bitset @@ -43,6 +44,7 @@ bugfixes cancelled Cannonical Cardinality +caseDiscriminator CCache cdr CDR From e45882f241fe58bb24cabafe4722998423b2cdf5 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Fri, 12 Apr 2024 14:17:08 +0200 Subject: [PATCH 18/23] Refs #20631: apply remaining suggestions Signed-off-by: JLBuenoLopez-eProsima --- code/DDSCodeTester.cpp | 82 +++++++++++++++---- code/DynamicTypesIDLExamples.idl | 1 + docs/03-exports/aliases-api.include | 2 +- docs/03-exports/aliases.include | 2 +- .../dds_pim/xtypes/exception.rst | 2 +- .../domainParticipantListener.rst | 10 +-- .../createContentFilteredTopic.rst | 2 +- .../dds_layer/topic/fastddsgen/fastddsgen.rst | 16 ++-- docs/fastdds/discovery/disc_callbacks.rst | 4 +- .../simple_app/includes/dataType.rst | 4 +- .../simple_app/includes/workspace.rst | 4 +- .../simple_python_app/includes/dataType.rst | 4 +- .../simple_python_app/includes/workspace.rst | 2 + .../library_overview/includes/exec_model.rst | 39 +++++---- .../rosbag_capture/rosbag_capture.rst | 2 +- .../xml_configuration/domainparticipant.rst | 6 +- .../pubsub_app/includes/first_app.rst | 10 +-- 17 files changed, 128 insertions(+), 64 deletions(-) diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 8a7fdb0b8..bf8ac9eb3 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -181,7 +181,7 @@ 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; } } @@ -207,13 +207,21 @@ class CustomDomainParticipantListener : public DomainParticipantListener 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; } } @@ -222,13 +230,21 @@ class CustomDomainParticipantListener : public DomainParticipantListener 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; } } @@ -907,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) { @@ -920,7 +936,7 @@ 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; @@ -933,19 +949,28 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener 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 */ 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 */ 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() << + std::cout << "DataReader subscribed to topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' left the domain."; break; } @@ -957,19 +982,28 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener 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 */ 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 */ 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() << + std::cout << "DataWriter publishing under topic '" << info.info.topicName() << "' of type '" << info.info.typeName() << "' left the domain."; break; } @@ -5186,10 +5220,10 @@ void dynamictypes_examples() // Create dynamic data based on the union type DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(union_type)}; - // Set and retrieve values for the member + // 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 member + // 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); @@ -5265,10 +5299,10 @@ void dynamictypes_examples() 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 map member + // 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 values for the member + // 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); @@ -5285,6 +5319,11 @@ void dynamictypes_examples() 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()}; @@ -5305,6 +5344,15 @@ void dynamictypes_examples() 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); //!-- } { @@ -5391,7 +5439,7 @@ void xml_profiles_examples() if (RETCODE_OK == DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml")) { - // Retrieve the an instance of the desired type + // 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( @@ -6579,7 +6627,7 @@ void dds_persistence_examples() 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_INT32)); + get_primitive_type(TK_UINT32)); struct_builder->add_member(index_member_descriptor); MemberDescriptor::_ref_type message_member_descriptor {traits::make_shared()}; diff --git a/code/DynamicTypesIDLExamples.idl b/code/DynamicTypesIDLExamples.idl index e905aad69..e0aacaaf0 100644 --- a/code/DynamicTypesIDLExamples.idl +++ b/code/DynamicTypesIDLExamples.idl @@ -199,5 +199,6 @@ struct BitsetStruct @MyAnnotation(length = 5) struct AnnotatedStruct { + @MyAnnotation(length = 10) string string_var; }; //!-- diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index ea93c9714..f676f096b 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -188,7 +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_threads()` +.. |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 ` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index 88fac10be..e9dfc9f11 100644 --- a/docs/03-exports/aliases.include +++ b/docs/03-exports/aliases.include @@ -83,7 +83,7 @@ .. |MemoryManagementPolicy| replace:: :ref:`MemoryManagementPolicy` .. |DynamicTypes| replace:: :ref:`Dynamic Language Binding` -.. |TypeObject| replace:: :ref:`TypeObject` +.. |TypeObject| replace:: :ref:`TypeObject representation` .. |TypeInformation| replace:: :ref:`TypeInformation` .. |TopicDataType| replace:: :ref:`TopicDataType` diff --git a/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst b/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst index ff462282a..a34d10c67 100644 --- a/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst +++ b/docs/fastdds/api_reference/dds_pim/xtypes/exception.rst @@ -1,4 +1,4 @@ -.. _api_pim_invalidargumenterror: +.. _api_pim_xtypes_exception: .. rst-class:: api-ref diff --git a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst index 97fd79e33..fc6c753d1 100644 --- a/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst +++ b/docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst @@ -34,13 +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_data_reader_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_data_writer_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_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 b806e6c6a..f13dbe14d 100644 --- a/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst +++ b/docs/fastdds/dds_layer/topic/contentFilteredTopic/createContentFilteredTopic.rst @@ -51,7 +51,7 @@ 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 ` the TypeObject registration code is generated bu default. + When using :ref:`fastddsgen ` the TypeObject registration code is generated by default. .. literalinclude:: /../code/DDSCodeTester.cpp diff --git a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index 4625b838f..e99e53d4f 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,11 +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. -* ``-no-typeobjectsupport``: Avoids building additional files for |TypeObject| registration. -* ``-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`: 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`. @@ -54,5 +54,5 @@ Assuming the IDL file had the name *“Mytype”*, and none of the above options * 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`). -* HelloWorldCdrAux.hpp/.ipp: C++ serialization and deserialization code for the HelloWorld type. -* MyTypeTypeObjectSupport.cxx/.hpp: |TypeObject| generation and registration. +* HelloWorldCdrAux.hpp/.ipp: Auxiliary methods required by Fast CDR for type serialization and deserialization. +* 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 813dd40d0..b3de0194c 100644 --- a/docs/fastdds/discovery/disc_callbacks.rst +++ b/docs/fastdds/discovery/disc_callbacks.rst @@ -9,10 +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_data_reader_discovery-api|, -|DomainParticipantListener::on_data_writer_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/getting_started/simple_app/includes/dataType.rst b/docs/fastdds/getting_started/simple_app/includes/dataType.rst index ddfff016b..723290c73 100644 --- a/docs/fastdds/getting_started/simple_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_app/includes/dataType.rst @@ -37,7 +37,7 @@ To do this, run the following command from the ``src`` directory. .. code-block:: bash - /scripts/fastddsgen -no-typeobjectsupport HelloWorld.idl + /scripts/fastddsgen HelloWorld.idl This must have generated the following files: @@ -46,6 +46,8 @@ This must have generated the following files: * 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 8a2cdc0ab..6a92c8380 100644 --- a/docs/fastdds/getting_started/simple_app/includes/workspace.rst +++ b/docs/fastdds/getting_started/simple_app/includes/workspace.rst @@ -25,7 +25,9 @@ Subscriber application respectively. ├── 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 6511627e4..a088338a7 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst @@ -38,7 +38,7 @@ To do this, run the following command. .. code-block:: bash - /scripts/fastddsgen -python -no-typeobjectsupport HelloWorld.idl + /scripts/fastddsgen HelloWorld.idl This must have generated the following files: @@ -49,6 +49,8 @@ This must have generated the following files: * 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 9bed601b5..6569ee0b6 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/workspace.rst @@ -22,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/library_overview/includes/exec_model.rst b/docs/fastdds/library_overview/includes/exec_model.rst index 15107b2c5..ab3ac84c9 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/rosbag_capture/rosbag_capture.rst b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst index a5f393d5e..180d1bcf3 100644 --- a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst +++ b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst @@ -154,7 +154,7 @@ the TypeSupport and the example source files: 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. diff --git a/docs/fastdds/xml_configuration/domainparticipant.rst b/docs/fastdds/xml_configuration/domainparticipant.rst index b974336a4..dffd56b02 100644 --- a/docs/fastdds/xml_configuration/domainparticipant.rst +++ b/docs/fastdds/xml_configuration/domainparticipant.rst @@ -202,8 +202,10 @@ These elements allow the user to define the DomainParticipant configuration. - |ThreadSettings| for the discovery server thread. - |ThreadSettings| - - * - ```` - - |ThreadSettings| for the threads used by the TypeLookup service. + * - ```` + - |ThreadSettings| for the threads used by the builtin TypeLookup service |br| + used to discover unknown remote types. |br| + See :ref:`xtypes_discovery_matching`. - |ThreadSettings| - * - ```` diff --git a/docs/fastddsgen/pubsub_app/includes/first_app.rst b/docs/fastddsgen/pubsub_app/includes/first_app.rst index 979c1c223..11640af2f 100644 --- a/docs/fastddsgen/pubsub_app/includes/first_app.rst +++ b/docs/fastddsgen/pubsub_app/includes/first_app.rst @@ -18,13 +18,13 @@ installation followed and the operating system. .. code:: bash - /src/fastddsgen/scripts/fastddsgen -no-typeobjectsupport -example CMake HelloWorld.idl + /src/fastddsgen/scripts/fastddsgen -example CMake HelloWorld.idl - For a **stand-alone installation**, run: .. code:: bash - /scripts/fastddsgen -no-typeobjectsupport -example CMake HelloWorld.idl + /scripts/fastddsgen -example CMake HelloWorld.idl * On Windows: @@ -32,19 +32,19 @@ installation followed and the operating system. .. code:: bash - /src/fastddsgen/scripts/fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl + /src/fastddsgen/scripts/fastddsgen.bat -example CMake HelloWorld.idl - For a **stand-alone installation**, run: .. code:: bash - /scripts/fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl + /scripts/fastddsgen.bat -example CMake HelloWorld.idl - For an **installation from binaries**, run: .. code:: bash - fastddsgen.bat -no-typeobjectsupport -example CMake HelloWorld.idl + fastddsgen.bat -example CMake HelloWorld.idl .. warning:: From 3d4994a6d6a85bd113e3e077c350729acaa0b4c4 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 16 Apr 2024 10:42:11 +0200 Subject: [PATCH 19/23] Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima --- code/DDSCodeTester.cpp | 93 ++++++++------ code/DynamicTypesIDLExamples.idl | 6 +- code/XMLTester.xml | 15 +-- docs/03-exports/aliases-api.include | 34 ++--- docs/03-exports/aliases.include | 29 ++--- .../api_reference/dds_pim/topic/topic.rst | 2 - .../api_reference/dds_pim/topic/typeidv1.rst | 11 -- .../dds_pim/topic/typeobjectv1.rst | 11 -- .../dds_layer/topic/fastddsgen/fastddsgen.rst | 4 +- .../simple_app/includes/dataType.rst | 2 +- .../simple_python_app/includes/dataType.rst | 2 +- .../simple_python_app/simple_python_app.rst | 1 + .../library_overview/includes/exec_model.rst | 10 +- .../remote_type_discovery_matching.rst | 25 +++- .../rosbag_capture/rosbag_capture.rst | 7 +- .../xml_configuration/domainparticipant.rst | 2 +- .../xml_configuration/dynamic_types.rst | 120 +++++++++--------- docs/fastdds/xtypes/discovery_matching.rst | 4 +- docs/fastdds/xtypes/language_binding.rst | 56 ++++---- docs/fastddsgen/dataTypes/dataTypes.rst | 2 +- docs/spelling_wordlist.txt | 1 - 21 files changed, 221 insertions(+), 216 deletions(-) delete mode 100644 docs/fastdds/api_reference/dds_pim/topic/typeidv1.rst delete mode 100644 docs/fastdds/api_reference/dds_pim/topic/typeobjectv1.rst diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index bf8ac9eb3..e057da409 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -954,7 +954,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener 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"; /* The following line can be substituted to evaluate whether the discovered datareader should be ignored */ @@ -966,10 +966,10 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener } 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 */ + /* 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; @@ -987,7 +987,7 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener 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"; /* The following line can be substituted to evaluate whether the discovered datawriter should be ignored */ @@ -999,10 +999,10 @@ class DiscoveryDomainParticipantListener : public DomainParticipantListener } 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 */ + /* 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; @@ -1021,7 +1021,7 @@ class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListene eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info, bool& should_be_ignored) override { - static_cast(should_be_ignored); + 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( @@ -1035,7 +1035,7 @@ class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListene 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, nullptr); + dyn_type_support.register_type(participant); // Create a Topic with the remotely discovered type. Topic* topic = @@ -1069,7 +1069,7 @@ class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListene eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, bool& should_be_ignored) override { - static_cast(should_be_ignored); + 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( @@ -1083,7 +1083,7 @@ class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListene 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, nullptr); + dyn_type_support.register_type(participant); // Create a Topic with the remotely discovered type. Topic* topic = @@ -1103,6 +1103,7 @@ class RemoteDiscoveryDomainParticipantListener : public DomainParticipantListene 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) { @@ -4571,6 +4572,10 @@ void dynamictypes_examples() 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); @@ -4579,8 +4584,12 @@ void dynamictypes_examples() 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_octet"); - member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_BYTE)); + 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"); @@ -4599,14 +4608,6 @@ void dynamictypes_examples() 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_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_longlong"); member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->get_primitive_type(TK_INT64)); struct_builder->add_member(member_descriptor); @@ -4633,8 +4634,8 @@ void dynamictypes_examples() 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; + 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")); //!-- @@ -4659,6 +4660,7 @@ void dynamictypes_examples() 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()); */ @@ -4671,6 +4673,7 @@ void dynamictypes_examples() 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()); */ @@ -4708,7 +4711,7 @@ void dynamictypes_examples() 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 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")); @@ -4762,8 +4765,13 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for an enum member - MyEnum in_value = MyEnum::C; - uint32_t out_value = 0; + 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")); //!-- @@ -4824,8 +4832,8 @@ void dynamictypes_examples() DynamicData::_ref_type data {DynamicDataFactory::get_instance()->create_data(struct_type)}; // Set and retrieve values for bitmask member. - uint8_t in_value = 2; - uint8_t out_value = 0; + 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")); @@ -4908,8 +4916,8 @@ void dynamictypes_examples() 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; + 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")); //!-- @@ -4936,6 +4944,7 @@ void dynamictypes_examples() 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()); */ @@ -5024,7 +5033,8 @@ void dynamictypes_examples() 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 - array_data->set_int32_values(22, in_value); + 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); @@ -5061,6 +5071,7 @@ void dynamictypes_examples() 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()); */ @@ -5094,8 +5105,8 @@ void dynamictypes_examples() 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 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))); @@ -5158,8 +5169,8 @@ void dynamictypes_examples() 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; + 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")); //!-- @@ -5224,7 +5235,7 @@ void dynamictypes_examples() 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 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")); @@ -5280,12 +5291,12 @@ void dynamictypes_examples() // 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(0); + 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(1); + 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(); @@ -5303,7 +5314,7 @@ void dynamictypes_examples() 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 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")); @@ -5366,7 +5377,7 @@ void dynamictypes_examples() 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; + 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); @@ -5406,7 +5417,7 @@ void xml_profiles_examples() \ \ \ - \ + \ \ \ TRANSIENT_LOCAL\ @@ -6633,7 +6644,7 @@ void dds_persistence_examples() MemberDescriptor::_ref_type message_member_descriptor {traits::make_shared()}; message_member_descriptor->name("message"); message_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()-> - create_string_type(LENGTH_UNLIMITED)->build()); + create_string_type(static_cast(LENGTH_UNLIMITED))->build()); struct_builder->add_member(message_member_descriptor); // Build the type diff --git a/code/DynamicTypesIDLExamples.idl b/code/DynamicTypesIDLExamples.idl index e0aacaaf0..1c8336c82 100644 --- a/code/DynamicTypesIDLExamples.idl +++ b/code/DynamicTypesIDLExamples.idl @@ -37,15 +37,15 @@ union TypeObject switch(octet) struct PrimitivesStruct { boolean my_bool; + octet my_octet; char my_char; wchar my_wchar; - octet my_octet; + long my_long; + unsigned long my_ulong; int8 my_int8; uint8 my_uint8; short my_short; unsigned short my_ushort; - long my_long; - unsigned long my_ulong; long long my_longlong; unsigned long long my_ulonglong; float my_float; diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 06ab50df1..5ee761236 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -4280,15 +4280,15 @@ XML_PRIMITIVES<--> + - + + - - @@ -4331,9 +4331,10 @@ <--> + XML_TYPEDEF<--> - + @@ -4346,8 +4347,7 @@ XML_SEQUENCES<--> - - + <--> @@ -4360,8 +4360,7 @@ XML_MAPS<--> - - + <--> diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index f676f096b..84a1210d8 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -150,20 +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()` -.. |DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name-api| replace:: :cpp:func:`DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name()` .. |DomainParticipantFactoryQos-api| replace:: :cpp:class:`DomainParticipantFactoryQos` .. |DomainParticipantFactoryQos::entity_factory-api| replace:: :cpp:func:`entity_factory()` @@ -954,35 +954,35 @@ .. |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::loan_value| replace:: :cpp:func:`DynamicData::loan_value ` -.. |DynamicData::return_loaned_value| replace:: :cpp:func:`DynamicData::return_loaned_value ` .. |DynamicData::get_string_value| replace:: :cpp:func:`DynamicData::get_string_value ` .. |DynamicData::get_wstring_value| replace:: :cpp:func:`DynamicData::get_wstring_value ` -.. |DynamicData::set_string_value| replace:: :cpp:func:`DynamicData::set_string_value ` -.. |DynamicData::set_wstring_value| replace:: :cpp:func:`DynamicData::set_wstring_value ` -.. |DynamicData::get_boolean_value| replace:: :cpp:func:`DynamicData::get_boolean_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::get_complex_value| replace:: :cpp:func:`DynamicData::get_complex_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| replace:: :cpp:func:`DynamicTypeBuilder::apply_annotation ` .. |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::get_primitive_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::get_primitive_type ` -.. |DynamicTypeBuilderFactory::create_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type ` -.. |DynamicTypeBuilderFactory::create_type_w_type_object| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_type_w_type_object ` -.. |DynamicTypeBuilderFactory::create_string_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_string_type ` -.. |DynamicTypeBuilderFactory::create_wstring_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_wstring_type ` -.. |DynamicTypeBuilderFactory::create_sequence_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_sequence_type ` .. |DynamicTypeBuilderFactory::create_array_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_array_type ` -.. |DynamicTypeBuilderFactory::create_map_type| replace:: :cpp:func:`DynamicTypeBuilderFactory::create_map_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 ` diff --git a/docs/03-exports/aliases.include b/docs/03-exports/aliases.include index e9dfc9f11..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,24 +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` - -.. |DynamicTypes| replace:: :ref:`Dynamic Language Binding` -.. |TypeObject| replace:: :ref:`TypeObject representation` -.. |TypeInformation| replace:: :ref:`TypeInformation` - -.. |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/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/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/dds_layer/topic/fastddsgen/fastddsgen.rst b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst index e99e53d4f..b11d9031e 100644 --- a/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst +++ b/docs/fastdds/dds_layer/topic/fastddsgen/fastddsgen.rst @@ -37,7 +37,7 @@ code generation are the following: * :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`: Disables the automatic generation of the |TypeObject| registration code. +* :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 @@ -54,5 +54,5 @@ Assuming the IDL file had the name *“Mytype”*, and none of the above options * 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`). -* HelloWorldCdrAux.hpp/.ipp: Auxiliary methods required by Fast CDR for type serialization and deserialization. +* 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/getting_started/simple_app/includes/dataType.rst b/docs/fastdds/getting_started/simple_app/includes/dataType.rst index 723290c73..a9ddada72 100644 --- a/docs/fastdds/getting_started/simple_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_app/includes/dataType.rst @@ -46,7 +46,7 @@ This must have generated the following files: * 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.cxx: |TypeObject| registration code. * HelloWorldTypeObjectSupport.hpp: Header file for HelloWorldTypeObjectSupport.cxx. CMakeLists.txt 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 a088338a7..446465cdb 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst @@ -49,7 +49,7 @@ This must have generated the following files: * 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.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/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 ab3ac84c9..2a4491937 100644 --- a/docs/fastdds/library_overview/includes/exec_model.rst +++ b/docs/fastdds/library_overview/includes/exec_model.rst @@ -78,7 +78,7 @@ Transport related threads (marked as UDP, TCP and SHM types) are only created wh * - Keep Alive - TCP - One per TCP transport - - :code:`dds.tcp_keep`` + - :code:`dds.tcp_keep` - Keep alive thread for TCP connections. |br| See :ref:`transport_tcp_transportDescriptor`. * - Reception @@ -96,13 +96,13 @@ Transport related threads (marked as UDP, TCP and SHM types) are only created wh * - Watchdog - SHM - One - - :code:`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 - - :code:`dds.log`` + - :code:`dds.log` - Accumulates and writes to the appropriate |br| consumer log entries. |br| See :ref:`dds_layer_log_thread`. * - Security Logging @@ -114,13 +114,13 @@ Transport related threads (marked as UDP, TCP and SHM types) are only created wh * - Watchdog - Filewatch - One - - :code:`dds.fwatch`` + - :code:`dds.fwatch` - Tracks the status of the watched file for |br| modifications. |br| See :ref:`dds_layer_domainParticipantFactoryQos`. * - Callback - Filewatch - One - - :code:`dds.fwatch.cb`` + - :code:`dds.fwatch.cb` - Runs the registered callback when the |br| watched file changes. |br| See :ref:`dds_layer_domainParticipantFactoryQos`. * - Reception 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 index dd54f2407..77dc253dd 100644 --- 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 @@ -12,8 +12,8 @@ local participant. Prerequisites ------------- -This use case is focused on the strategy that has to be followed in order to create an endpoint in runtime in a -previously unknown topic using the information provided by the remote endpoint discovery information. +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 @@ -31,11 +31,10 @@ Remote type discovery --------------------- Following the :ref:`participant discovery phase `, the endpoint information is exchanged. -The corresponding |DomainParticipantListener::on_data_reader_discovery-api| or -|DomainParticipantListener::on_data_writer_discovery-api| callback will be called, depending on the kind of endpoint +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 remote discovered information which includes the -|TypeInformation|. +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. @@ -45,7 +44,19 @@ 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 can then be obtained and registered using |DynamicPubSubType-api|. +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 ------- diff --git a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst index 180d1bcf3..dbf6424f4 100644 --- a/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst +++ b/docs/fastdds/use_cases/rosbag_capture/rosbag_capture.rst @@ -147,7 +147,12 @@ 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 diff --git a/docs/fastdds/xml_configuration/domainparticipant.rst b/docs/fastdds/xml_configuration/domainparticipant.rst index dffd56b02..b6aadbd44 100644 --- a/docs/fastdds/xml_configuration/domainparticipant.rst +++ b/docs/fastdds/xml_configuration/domainparticipant.rst @@ -204,7 +204,7 @@ These elements allow the user to define the DomainParticipant configuration. - * - ```` - |ThreadSettings| for the threads used by the builtin TypeLookup service |br| - used to discover unknown remote types. |br| + to discover unknown remote types. |br| See :ref:`xtypes_discovery_matching`. - |ThreadSettings| - diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 7d7d2476a..9f93e11c3 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -35,7 +35,7 @@ Type definition ^^^^^^^^^^^^^^^ 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 of the types detailed below, an example of how to build the type's XML profile is provided. +For each type listed below, an example of how to build the type's XML profile is provided. * `Primitive types`_ * `String types`_ @@ -54,30 +54,30 @@ For each of the types detailed below, an example of how to build the type's XML Primitive types """"""""""""""" -Primitive types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). -Primitive types are defined by attribute :code:`type` and the possible values are listed in the table below. +Primitive types are built-in types and they should be declared as members of an aggregated type (`Structure types`_ or +`Union types`_). +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`` - - ``uint8`` + - ``int32`` + * - ``uint32`` - ``int8`` + - ``uint8`` - ``int16`` - * - ``int32`` - ``uint16`` - - ``uint32`` - - ``int64`` - * - ``uint64`` + * - ``int64`` + - ``uint64`` - ``float32`` - ``float64`` - ``float128`` -All of them are defined as follows: +All of them are declared as follows: .. tabs:: @@ -91,7 +91,7 @@ All of them are defined as follows: .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_PRIMITIVES :end-before: //!-- @@ -101,7 +101,8 @@ All of them are defined as follows: String Types """""""""""" -String Types are defined with attribute :code:`type` set to :code:`string` or :code:`wstring`. +String types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). +String types are declared 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. @@ -117,7 +118,7 @@ Please, refer to :ref:`xtypes_supportedtypes_string` for more information on str .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_STRINGS :end-before: //!-- @@ -126,15 +127,15 @@ Please, refer to :ref:`xtypes_supportedtypes_string` for more information on str Enumeration Types """"""""""""""""" -Enumeration types are defined using the :code:`` tag. +Enumeration types are declared 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`. +Enumeration literals are declared 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 dynamic language binding. + the plain (IDL) nor |DynamicTypes|. Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information on enumeration types. @@ -150,7 +151,7 @@ Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information o .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_ENUM :end-before: //!-- @@ -159,11 +160,11 @@ Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information o Bitmask Types """"""""""""" -Bitmask types are defined using the :code:`` tag. +Bitmask types are declared 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. +Bitflag elements are declared using the :code:`` tag with mandatory attribute :code:`name`. +Optionally, :code:`position` attribute might be declared to set the bitflag position within the bitmask. Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on bitmask types. .. tabs:: @@ -178,7 +179,7 @@ Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on bi .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_BITMASK :end-before: //!-- @@ -187,9 +188,11 @@ Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on bi Alias Types """"""""""" -Alias types are defined using the :code:`` tag. +Alias types are declared using the :code:`` tag. Attributes :code:`name` and :code:`type` are mandatory. -Depending on the aliased type, any other attribute might be required or optionally added. +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. .. tabs:: @@ -204,7 +207,7 @@ Please, refer to :ref:`xtypes_supportedtypes_alias` for more information on alia .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_TYPEDEF :end-before: //!-- @@ -213,13 +216,10 @@ Please, refer to :ref:`xtypes_supportedtypes_alias` for more information on alia Sequence Types """""""""""""" -Sequence Types are defined with mandatory attributes :code:`type` set to the collection's element type, and +Sequence types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). +Sequence types are declared with mandatory attributes :code:`type` set to the collection's element type, and :code:`sequenceMaxLength` used to set the maximum collection's length. - -.. important:: - - Currently, unbounded sequences cannot be defined using XML profiles. - +Unbounded sequences should set :code:`sequenceMaxLength` attribute to :code:`-1`. Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on sequence types. .. tabs:: @@ -234,7 +234,7 @@ Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on s .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_SEQUENCES :end-before: //!-- @@ -243,7 +243,8 @@ Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on s Array Types """"""""""" -Array Types are defined with mandatory attributes :code:`type` set to the collection's element type, and +Array types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). +Array types are declared 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. @@ -260,7 +261,7 @@ Please, refer to :ref:`xtypes_supportedtypes_array` for more information on arra .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_ARRAYS :end-before: //!-- @@ -269,13 +270,10 @@ Please, refer to :ref:`xtypes_supportedtypes_array` for more information on arra Map Types """"""""" -Maps Types are defined with mandatory attributes :code:`type` set to the map's value type, :code:`key_type` set to the +Map types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). +Map types are declared 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. - -.. important:: - - Currently, unbounded maps cannot be defined using XML profiles. - +Unbounded maps should set :code:`mapMaxLength` attribute to :code:`-1`. Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map types. .. tabs:: @@ -290,7 +288,7 @@ Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map ty .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_MAPS :end-before: //!-- @@ -299,9 +297,9 @@ Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map ty Structure Types """"""""""""""" -Structure types are defined using the :code:`` tag with mandatory attribute :code:`name`. +Structure types are declared 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. +XML Structure Types require at least one member declared. .. note:: @@ -309,7 +307,7 @@ XML Structure Types require at least one member defined. 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`. +Structure members are declared 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. @@ -332,7 +330,7 @@ Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_STRUCT :end-before: //!-- @@ -341,21 +339,21 @@ Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on 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 as mandatory attribute :code:``. +Union types are declared using the :code:`` tag with mandatory attribute :code:`name`. +A mandatory discriminator child must be declared 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 caseDiscriminator child using the :code:`` tag. -:code:`value` attribute is mandatory and defines the label associated with that specific caseDiscriminator. -Several labels might be defined using several caseDiscriminator elements. -Each case child must have exclusively one union member defined. +Union types also require at least one case child declared 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 declared using several :code:`` elements. +Each case child must have exclusively one union member declared. -Union members are defined using the :code:`` tag with mandatory attributes :code:`name` and :code:`type`. +Union members are declared 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. +At least one union member must be declared for the union type to be consistent. .. note:: @@ -375,7 +373,7 @@ Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_UNION :end-before: //!-- @@ -384,13 +382,13 @@ Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the Bitset Types """""""""""" -Bitset types are defined using the :code:`` tag with mandatory attribute :code:`name`. +Bitset types are declared 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. +At least one bitfield child must be declared 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. +Optionally, attributes :code:`name` and :code:`type` might be declared. 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. @@ -408,7 +406,7 @@ Please, refer to :ref:`xtypes_supportedtypes_bitset` for more information about .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_BITSET :end-before: //!-- @@ -417,7 +415,7 @@ Please, refer to :ref:`xtypes_supportedtypes_bitset` for more information about Loading XML Types profile in *Fast DDS* application ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -*Fast DDS* application can use types defined in XML configuration files once those files have been loaded into the +*Fast DDS* application can use types declared 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 diff --git a/docs/fastdds/xtypes/discovery_matching.rst b/docs/fastdds/xtypes/discovery_matching.rst index 4d6920a4b..9ae697942 100644 --- a/docs/fastdds/xtypes/discovery_matching.rst +++ b/docs/fastdds/xtypes/discovery_matching.rst @@ -20,7 +20,7 @@ On the one hand, :code:`TypeInformation` structure defined in the IDL below (ext `DDS-XTypes specification`_), is used to communicate the Topic Data Type and its dependencies. .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--TYPEINFORMATION :end-before: //!-- @@ -29,7 +29,7 @@ univocally the data type. The data type information is contained in the :code:`TypeObject` union: .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--TYPEOBJECT :end-before: //!-- diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index c74514587..3aabec50f 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -69,8 +69,9 @@ to the correct DynamicType address. DynamicTypeMember ^^^^^^^^^^^^^^^^^ -|DynamicTypeMember-api| represents a data member of a DynamicType that is in itself a DynamicType. -Consequently, the same remarks affecting DynamicTypes, also applies to DynamicTypeMembers. +|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 ^^^^^^^^^^^^^^^^^^ @@ -161,7 +162,7 @@ The example below shows how to create an structure with primitive members. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_PRIMITIVES :end-before: //!-- @@ -214,7 +215,7 @@ The following promotions are supported: * - :code:`TK_UINT32` - :code:`TK_INT64`, :code:`TK_UINT64`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` * - :code:`TK_UINT64` - - :code:`TK_FLOAT64` + - :code:`TK_FLOAT128` * - :code:`TK_FLOAT32` - :code:`TK_FLOAT64`, :code:`TK_FLOAT128` * - :code:`TK_FLOAT64` @@ -222,10 +223,10 @@ The following promotions are supported: * - :code:`TK_FLOAT128` - (none) * - :code:`TK_CHAR8` - - :code:`TK_CHAR16`, :code:`TK_INT16`, :code:`TK_INT32`, :code:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, + - :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:`int64_t`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` + - :code:`TK_INT32`, :code:`TK_INT64`, :code:`TK_FLOAT32`, :code:`TK_FLOAT64`, :code:`TK_FLOAT128` * - :code:`TK_BYTE` - (any) * - :code:`TK_BOOLEAN` @@ -238,7 +239,7 @@ The following promotions are supported: String Types ^^^^^^^^^^^^ -String Types are one-dimensional collections of characters (:code:`TK_CHAR8` or :code:`TK_CHAR16`. +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. @@ -256,7 +257,7 @@ parameter (:code:`LENGTH_UNLIMITED` is used for unbounded strings). .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_STRINGS :end-before: //!-- @@ -310,7 +311,7 @@ primitive type (and any other method promotable to that specific primitive type) .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_ENUM :end-before: //!-- @@ -363,7 +364,7 @@ In this latest case, only bitflags are going to be set (bits not named are alway .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_BITMASK :end-before: //!-- @@ -402,7 +403,7 @@ Once the |DynamicData-api| is created, information can be accessed as if working .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_TYPEDEF :end-before: //!-- @@ -431,8 +432,8 @@ 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 might be configured to set a maximum length for the collection. -Otherwise, the collection is considered to be unbounded. +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. @@ -455,7 +456,7 @@ of the element to be modified. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_SEQUENCES :end-before: //!-- @@ -485,6 +486,7 @@ 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. @@ -511,7 +513,7 @@ of the element to be modified. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_ARRAYS :end-before: //!-- @@ -548,7 +550,8 @@ Allowed key types are signed and unsigned integer types and string types. Currently, wide string keys are not supported as map keys. -Additionally, :code:`bound` property might be configured to set a maximum length for the collection. +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. @@ -558,6 +561,8 @@ This API requires the type of both the key and the value stored in the collectio 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`. @@ -567,7 +572,7 @@ For complex map values, please refer to :ref:`xtypes_complextypes`. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_MAPS :end-before: //!-- @@ -616,7 +621,7 @@ Member name is configured using |MemberDescriptor-api| :code:`name` property and 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 configured the member default value, +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`. @@ -643,7 +648,7 @@ For managing complex type members, please refer to :ref:`xtypes_complextypes`. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_STRUCT :end-before: //!-- @@ -708,7 +713,7 @@ This latest property indicates the discriminator values that select this specifi 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 configured the member default value, +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`. @@ -737,7 +742,7 @@ For managing complex type members, please refer to :ref:`xtypes_complextypes`. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_UNION :end-before: //!-- @@ -775,6 +780,11 @@ 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. @@ -805,7 +815,7 @@ modifies the involved bits instead of the full primitive value. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_BITSET :end-before: //!-- @@ -870,7 +880,7 @@ The annotation parameter value must be converted to its string representation. .. tab:: IDL .. literalinclude:: /../code/DynamicTypesIDLExamples.idl - :language: idl + :language: omg-idl :start-after: //!--IDL_CUSTOM_ANNOTATION :end-before: //!-- diff --git a/docs/fastddsgen/dataTypes/dataTypes.rst b/docs/fastddsgen/dataTypes/dataTypes.rst index 29d3f7426..0c011b5ce 100644 --- a/docs/fastddsgen/dataTypes/dataTypes.rst +++ b/docs/fastddsgen/dataTypes/dataTypes.rst @@ -483,7 +483,7 @@ annotations might be applied without the need of defining them). - ✅ * - :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) or |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. - ✅ diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 3a9b03e34..205166aba 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -44,7 +44,6 @@ bugfixes cancelled Cannonical Cardinality -caseDiscriminator CCache cdr CDR From 9bbea0d906b085f88afd1a3724d9e937708c8105 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 16 Apr 2024 10:50:10 +0200 Subject: [PATCH 20/23] Refs #20631: regenerate example types Signed-off-by: JLBuenoLopez-eProsima --- .../C++/DDSHelloWorld/src/HelloWorld.hpp | 13 +- .../src/HelloWorldPubSubTypes.cxx | 5 +- .../src/HelloWorldTypeObjectSupport.cxx | 248 ++++++++++++++++++ .../src/HelloWorldTypeObjectSupport.hpp | 54 ++++ 4 files changed, 313 insertions(+), 7 deletions(-) create mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.cxx create mode 100644 code/Examples/C++/DDSHelloWorld/src/HelloWorldTypeObjectSupport.hpp diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp b/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp index f3efa3c34..971fea8d9 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorld.hpp @@ -80,9 +80,9 @@ class HelloWorld eProsima_user_DllExport HelloWorld( const HelloWorld& x) { - m_index = x.m_index; + m_index = x.m_index; - m_message = x.m_message; + m_message = x.m_message; } @@ -105,9 +105,9 @@ class HelloWorld const HelloWorld& x) { - m_index = x.m_index; + m_index = x.m_index; - m_message = x.m_message; + m_message = x.m_message; return *this; } @@ -133,7 +133,7 @@ class HelloWorld const HelloWorld& x) const { return (m_index == x.m_index && - m_message == x.m_message); + m_message == x.m_message); } /*! @@ -174,6 +174,7 @@ class HelloWorld return m_index; } + /*! * @brief This function copies the value in member message * @param _message New value to be copied in member message @@ -212,6 +213,8 @@ class HelloWorld return m_message; } + + private: uint32_t m_index{0}; diff --git a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx index f8d9d08b7..db018e697 100644 --- a/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx +++ b/code/Examples/C++/DDSHelloWorld/src/HelloWorldPubSubTypes.cxx @@ -25,6 +25,8 @@ #include #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; @@ -219,8 +221,7 @@ bool HelloWorldPubSubType::getKey( void HelloWorldPubSubType::register_type_object_representation() const { - EPROSIMA_LOG_WARNING(XTYPES_TYPE_REPRESENTATION, - "TypeObject type representation support disabled in generated code"); + register_HelloWorld_type_objects(); } 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_ From ad0d45947157245c4268c348975ce9058018f5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez=20Moreno?= Date: Tue, 16 Apr 2024 12:03:17 +0200 Subject: [PATCH 21/23] Refs #20631: little block comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ricardo González Moreno --- docs/03-exports/aliases-api.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/03-exports/aliases-api.include b/docs/03-exports/aliases-api.include index 84a1210d8..7e23eed9f 100644 --- a/docs/03-exports/aliases-api.include +++ b/docs/03-exports/aliases-api.include @@ -951,6 +951,7 @@ .. |EDPStatic| replace:: :cpp:class:`EDPStatic ` +.. {{{ 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 ` @@ -991,6 +992,7 @@ .. |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()` From 5b859896e346c7d386e4ad4def330753a2eefa02 Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 16 Apr 2024 14:30:33 +0200 Subject: [PATCH 22/23] Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima --- .../xml_configuration/dynamic_types.rst | 58 +++++++++---------- docs/fastdds/xtypes/language_binding.rst | 2 +- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index 9f93e11c3..adf7c6661 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -77,7 +77,7 @@ Please, refer to :ref:`xtypes_supportedtypes_primitive` for more information on - ``float64`` - ``float128`` -All of them are declared as follows: +All of them are defined as follows: .. tabs:: @@ -101,8 +101,8 @@ All of them are declared as follows: String Types """""""""""" -String types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). -String types are declared with attribute :code:`type` set to :code:`string` or :code:`wstring`. +String types should be defined as members of an aggregated type (`Structure types`_ or `Union types`_). +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. @@ -127,9 +127,9 @@ Please, refer to :ref:`xtypes_supportedtypes_string` for more information on str Enumeration Types """"""""""""""""" -Enumeration types are declared using the :code:`` tag. +Enumeration types are defined using the :code:`` tag. Attribute :code:`name` and at least one :code:`` child element are mandatory. -Enumeration literals are declared using the :code:`` tag with mandatory attribute :code:`name`. +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:: @@ -160,11 +160,11 @@ Please, refer to :ref:`xtypes_supportedtypes_enumeration` for more information o Bitmask Types """"""""""""" -Bitmask types are declared using the :code:`` tag. +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 declared using the :code:`` tag with mandatory attribute :code:`name`. -Optionally, :code:`position` attribute might be declared to set the bitflag position within the bitmask. +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. .. tabs:: @@ -188,7 +188,7 @@ Please, refer to :ref:`xtypes_supportedtypes_bitmask` for more information on bi Alias Types """"""""""" -Alias types are declared using the :code:`` tag. +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` @@ -216,8 +216,8 @@ Please, refer to :ref:`xtypes_supportedtypes_alias` for more information on alia Sequence Types """""""""""""" -Sequence types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). -Sequence types are declared with mandatory attributes :code:`type` set to the collection's element type, and +Sequence types should be defined as members of an aggregated type (`Structure types`_ or `Union types`_). +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. @@ -243,8 +243,8 @@ Please, refer to :ref:`xtypes_supportedtypes_sequence` for more information on s Array Types """"""""""" -Array types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). -Array types are declared with mandatory attributes :code:`type` set to the collection's element type, and +Array types should be defined as members of an aggregated type (`Structure types`_ or `Union types`_). +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. @@ -270,8 +270,8 @@ Please, refer to :ref:`xtypes_supportedtypes_array` for more information on arra Map Types """"""""" -Map types should be declared as members of an aggregated type (`Structure types`_ or `Union types`_). -Map types are declared with mandatory attributes :code:`type` set to the map's value type, :code:`key_type` set to the +Map types should be defined as members of an aggregated type (`Structure types`_ or `Union types`_). +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. @@ -297,9 +297,9 @@ Please, refer to :ref:`xtypes_supportedtypes_map` for more information on map ty Structure Types """"""""""""""" -Structure types are declared using the :code:`` tag with mandatory attribute :code:`name`. +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 declared. +XML Structure Types require at least one member defined. .. note:: @@ -307,7 +307,7 @@ XML Structure Types require at least one member declared. content structures. Empty structures are not supported in XML Types profiles yet. -Structure members are declared using the :code:`` tag with mandatory attributes :code:`name` and :code:`type`. +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. @@ -339,21 +339,21 @@ Please, refer to :ref:`xtypes_supportedtypes_structure` for more information on Union Types """"""""""" -Union types are declared using the :code:`` tag with mandatory attribute :code:`name`. -A mandatory discriminator child must be declared using :code:`` tag. +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 declared using the :code:`` tag. +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 declared using several :code:`` elements. -Each case child must have exclusively one union member declared. +Several labels might be defined using several :code:`` elements. +Each case child must have exclusively one union member defined. -Union members are declared using the :code:`` tag with mandatory attributes :code:`name` and :code:`type`. +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 declared for the union type to be consistent. +At least one union member must be defined for the union type to be consistent. .. note:: @@ -382,13 +382,13 @@ Please, refer to :ref:`xtypes_supportedtypes_union` for more information on the Bitset Types """""""""""" -Bitset types are declared using the :code:`` tag with mandatory attribute :code:`name`. +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 declared using :code:`bitfield` tag. +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 declared. +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. @@ -415,7 +415,7 @@ Please, refer to :ref:`xtypes_supportedtypes_bitset` for more information about Loading XML Types profile in *Fast DDS* application ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -*Fast DDS* application can use types declared in XML configuration files once those files have been loaded into the +*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 diff --git a/docs/fastdds/xtypes/language_binding.rst b/docs/fastdds/xtypes/language_binding.rst index 3aabec50f..2ea446579 100644 --- a/docs/fastdds/xtypes/language_binding.rst +++ b/docs/fastdds/xtypes/language_binding.rst @@ -561,7 +561,7 @@ This API requires the type of both the key and the value stored in the collectio 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 +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. From 15abe6abad729903478f6740a22a54cf58ec529a Mon Sep 17 00:00:00 2001 From: JLBuenoLopez-eProsima Date: Tue, 16 Apr 2024 14:52:09 +0200 Subject: [PATCH 23/23] Refs #20631: apply review suggestions Signed-off-by: JLBuenoLopez-eProsima --- .../getting_started/simple_python_app/includes/dataType.rst | 2 +- docs/fastdds/xml_configuration/dynamic_types.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 446465cdb..28ae08515 100644 --- a/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst +++ b/docs/fastdds/getting_started/simple_python_app/includes/dataType.rst @@ -38,7 +38,7 @@ To do this, run the following command. .. code-block:: bash - /scripts/fastddsgen HelloWorld.idl + /scripts/fastddsgen -python HelloWorld.idl This must have generated the following files: diff --git a/docs/fastdds/xml_configuration/dynamic_types.rst b/docs/fastdds/xml_configuration/dynamic_types.rst index adf7c6661..bc5885484 100644 --- a/docs/fastdds/xml_configuration/dynamic_types.rst +++ b/docs/fastdds/xml_configuration/dynamic_types.rst @@ -77,7 +77,7 @@ Please, refer to :ref:`xtypes_supportedtypes_primitive` for more information on - ``float64`` - ``float128`` -All of them are defined as follows: +All of them are declared as follows: .. tabs::