From 02dfeb62762fc6135f4c5c6378ca277c8fbb1d9d Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 24 Sep 2024 10:03:01 +0200 Subject: [PATCH 01/18] Refs #21745. Add QoS getters from raw XML Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 25 +++ .../dds/domain/DomainParticipantFactory.hpp | 5 + include/fastdds/dds/publisher/Publisher.hpp | 6 + include/fastdds/dds/subscriber/Subscriber.hpp | 6 + src/cpp/fastdds/domain/DomainParticipant.cpp | 48 ++++- .../domain/DomainParticipantFactory.cpp | 16 ++ .../fastdds/domain/DomainParticipantImpl.cpp | 78 ++++++++ .../fastdds/domain/DomainParticipantImpl.hpp | 25 +++ src/cpp/fastdds/publisher/Publisher.cpp | 9 + src/cpp/fastdds/publisher/PublisherImpl.cpp | 18 ++ src/cpp/fastdds/publisher/PublisherImpl.hpp | 6 + src/cpp/fastdds/subscriber/Subscriber.cpp | 9 + src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 18 ++ src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 6 + src/cpp/xmlparser/XMLProfileManager.cpp | 183 ++++++++++++++++++ src/cpp/xmlparser/XMLProfileManager.h | 30 +++ 16 files changed, 484 insertions(+), 4 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index 5fae640695d..e0c45256645 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -547,6 +547,11 @@ class DomainParticipant : public Entity const std::string& profile_name, PublisherQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos, + const std::string& profile_name = "") const; + /** * This operation sets a default value of the Subscriber QoS policies that will be used for newly created * Subscriber entities in the case where the QoS policies are defaulted in the create_subscriber operation. @@ -601,6 +606,11 @@ class DomainParticipant : public Entity const std::string& profile_name, SubscriberQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos, + const std::string& profile_name = "") const; + /** * This operation sets a default value of the Topic QoS policies which will be used for newly created * Topic entities in the case where the QoS policies are defaulted in the create_topic operation. @@ -655,6 +665,11 @@ class DomainParticipant : public Entity const std::string& profile_name, TopicQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name = "") const; + /** * Fills the ReplierQos with the values of the XML profile. * @@ -666,6 +681,11 @@ class DomainParticipant : public Entity const std::string& profile_name, ReplierQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos, + const std::string& profile_name = "") const; + /** * Fills the RequesterQos with the values of the XML profile. * @@ -677,6 +697,11 @@ class DomainParticipant : public Entity const std::string& profile_name, RequesterQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos, + const std::string& profile_name = "") const; + /** * Retrieves the list of DomainParticipants that have been discovered in the domain and are not "ignored". * diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index a492fce1e09..e381aee05c1 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -229,6 +229,11 @@ class DomainParticipantFactory const std::string& profile_name, DomainParticipantQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos, + const std::string& profile_name = "") const; + /** * Fills the DomainParticipantExtendedQos with the values of the XML profile. * diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index a29deab4541..58a2274e4c4 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -342,6 +342,12 @@ class Publisher : public DomainEntity const std::string& profile_name, DataWriterQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name, + const std::string& profile_name = "") const; + /** * Returns the Publisher's handle. * diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index eba91b2c44d..373de4ecf18 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -355,6 +355,12 @@ class Subscriber : public DomainEntity const std::string& profile_name, DataReaderQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name, + const std::string& profile_name = "") const; + /** * @brief Copies TopicQos into the corresponding DataReaderQos * diff --git a/src/cpp/fastdds/domain/DomainParticipant.cpp b/src/cpp/fastdds/domain/DomainParticipant.cpp index a3839843894..e73d520a011 100644 --- a/src/cpp/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/fastdds/domain/DomainParticipant.cpp @@ -336,6 +336,14 @@ ReturnCode_t DomainParticipant::get_publisher_qos_from_profile( return impl_->get_publisher_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos, + const std::string& profile_name) const +{ + return impl_->get_publisher_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t DomainParticipant::set_default_subscriber_qos( const SubscriberQos& qos) { @@ -361,6 +369,14 @@ ReturnCode_t DomainParticipant::get_subscriber_qos_from_profile( return impl_->get_subscriber_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos, + const std::string& profile_name) const +{ + return impl_->get_subscriber_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t DomainParticipant::set_default_topic_qos( const TopicQos& qos) { @@ -386,11 +402,12 @@ ReturnCode_t DomainParticipant::get_topic_qos_from_profile( return impl_->get_topic_qos_from_profile(profile_name, qos); } -ReturnCode_t DomainParticipant::get_replier_qos_from_profile( - const std::string& profile_name, - ReplierQos& qos) const +ReturnCode_t DomainParticipant::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name) const { - return impl_->get_replier_qos_from_profile(profile_name, qos); + return impl_->get_topic_qos_from_xml(xml, qos, profile_name); } ReturnCode_t DomainParticipant::get_requester_qos_from_profile( @@ -400,6 +417,29 @@ ReturnCode_t DomainParticipant::get_requester_qos_from_profile( return impl_->get_requester_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos, + const std::string& profile_name) const +{ + return impl_->get_requester_qos_from_xml(xml, qos, profile_name); +} + +ReturnCode_t DomainParticipant::get_replier_qos_from_profile( + const std::string& profile_name, + ReplierQos& qos) const +{ + return impl_->get_replier_qos_from_profile(profile_name, qos); +} + +ReturnCode_t DomainParticipant::get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos, + const std::string& profile_name) const +{ + return impl_->get_replier_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t DomainParticipant::get_discovered_participants( std::vector& participant_handles) const { diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index eb6f9b65ffe..f596dc8a148 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -341,6 +341,22 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos, + const std::string& profile_name) const +{ + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_participant_qos_; + utils::set_qos_from_attributes(qos, attr.rtps); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile( const std::string& profile_name, DomainParticipantExtendedQos& extended_qos) const diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 8bef8e5ee16..3603be63b6c 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1044,6 +1044,22 @@ ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos, + const std::string& profile_name) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_pub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::set_default_subscriber_qos( const SubscriberQos& qos) { @@ -1092,6 +1108,22 @@ ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos, + const std::string& profile_name) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_sub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::set_default_topic_qos( const TopicQos& qos) { @@ -1140,6 +1172,22 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( + const std::string& profile_name, + TopicQos& qos, + const std::string& xml) const +{ + xmlparser::TopicAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_topic_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_topic_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_replier_qos_from_profile( const std::string& profile_name, ReplierQos& qos) const @@ -1154,6 +1202,21 @@ ReturnCode_t DomainParticipantImpl::get_replier_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos, + const std::string& profile_name) const +{ + xmlparser::ReplierAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_replier_attributes_from_xml(xml, attr, profile_name)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_requester_qos_from_profile( const std::string& profile_name, RequesterQos& qos) const @@ -1168,6 +1231,21 @@ ReturnCode_t DomainParticipantImpl::get_requester_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos, + const std::string& profile_name) const +{ + xmlparser::RequesterAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_requester_attributes_from_xml(xml, attr, profile_name)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + /* TODO bool DomainParticipantImpl::get_discovered_participants( std::vector& participant_handles) const diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp index 803f6a2b6c4..abd2a94c1f9 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp @@ -375,6 +375,11 @@ class DomainParticipantImpl const std::string& profile_name, PublisherQos& qos) const; + ReturnCode_t get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t set_default_subscriber_qos( const SubscriberQos& qos); @@ -386,6 +391,11 @@ class DomainParticipantImpl const std::string& profile_name, SubscriberQos& qos) const; + ReturnCode_t get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t set_default_topic_qos( const TopicQos& qos); @@ -397,14 +407,29 @@ class DomainParticipantImpl const std::string& profile_name, TopicQos& qos) const; + ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t get_replier_qos_from_profile( const std::string& profile_name, ReplierQos& qos) const; + ReturnCode_t get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t get_requester_qos_from_profile( const std::string& profile_name, RequesterQos& qos) const; + ReturnCode_t get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos, + const std::string& profile_name = "") const; + /* TODO bool get_discovered_participants( std::vector& participant_handles) const; diff --git a/src/cpp/fastdds/publisher/Publisher.cpp b/src/cpp/fastdds/publisher/Publisher.cpp index d42517581dd..f80642c6111 100644 --- a/src/cpp/fastdds/publisher/Publisher.cpp +++ b/src/cpp/fastdds/publisher/Publisher.cpp @@ -237,6 +237,15 @@ ReturnCode_t Publisher::get_datawriter_qos_from_profile( return impl_->get_datawriter_qos_from_profile(profile_name, qos); } +ReturnCode_t Publisher::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name, + const std::string& profile_name) const +{ + return impl_->get_datawriter_qos_from_xml(xml, qos, topic_name, profile_name); +} + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index 30a32558942..234732be004 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -474,6 +474,24 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name, + const std::string& profile_name) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_datawriter_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t PublisherImpl::copy_from_topic_qos( DataWriterQos& writer_qos, const TopicQos& topic_qos) diff --git a/src/cpp/fastdds/publisher/PublisherImpl.hpp b/src/cpp/fastdds/publisher/PublisherImpl.hpp index b8b9fdea226..6fc42a976b9 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -169,6 +169,12 @@ class PublisherImpl const std::string& profile_name, DataWriterQos& qos) const; + ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name, + const std::string& profile_name = "") const; + ReturnCode_t static copy_from_topic_qos( DataWriterQos& writer_qos, const TopicQos& topic_qos); diff --git a/src/cpp/fastdds/subscriber/Subscriber.cpp b/src/cpp/fastdds/subscriber/Subscriber.cpp index 88b058f3c4f..ad71e8134f4 100644 --- a/src/cpp/fastdds/subscriber/Subscriber.cpp +++ b/src/cpp/fastdds/subscriber/Subscriber.cpp @@ -218,6 +218,15 @@ ReturnCode_t Subscriber::get_datareader_qos_from_profile( return impl_->get_datareader_qos_from_profile(profile_name, qos); } +ReturnCode_t Subscriber::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name, + const std::string& profile_name) const +{ + return impl_->get_datareader_qos_from_xml(xml, qos, topic_name, profile_name); +} + ReturnCode_t Subscriber::copy_from_topic_qos( DataReaderQos& reader_qos, const TopicQos& topic_qos) diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 077e0ca323c..55bf9b287e0 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -436,6 +436,24 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name, + const std::string& profile_name) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, profile_name)) + { + qos = default_datareader_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t SubscriberImpl::copy_from_topic_qos( DataReaderQos& reader_qos, const TopicQos& topic_qos) diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index 9966ace8e51..ec0088d330e 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -147,6 +147,12 @@ class SubscriberImpl const std::string& profile_name, DataReaderQos& qos) const; + ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name, + const std::string& profile_name = "") const; + ReturnCode_t static copy_from_topic_qos( DataReaderQos& reader_qos, const TopicQos& topic_qos); diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 145eeeb0c94..4143ae25bec 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -49,6 +49,141 @@ sp_transport_map_t XMLProfileManager::transport_profiles_; p_dynamictype_map_t XMLProfileManager::dynamic_types_; BaseNode* XMLProfileManager::root = nullptr; +template +struct AttributesTraits; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::PARTICIPANT; + using NodePtrType = p_node_participant_t; + using NodeUniquePtrType = up_participant_t; + + static std::string name() + { + return "Participant"; + } +}; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::PUBLISHER; + using NodePtrType = p_node_publisher_t; + using NodeUniquePtrType = up_publisher_t; + + static std::string name() + { + return "Publisher"; + } +}; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::SUBSCRIBER; + using NodePtrType = p_node_subscriber_t; + using NodeUniquePtrType = up_subscriber_t; + + static std::string name() + { + return "Subscriber"; + } +}; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::TOPIC; + using NodePtrType = p_node_topic_t; + using NodeUniquePtrType = up_topic_t; + + static std::string name() + { + return "Topic"; + } +}; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::REQUESTER; + using NodePtrType = p_node_requester_t; + using NodeUniquePtrType = up_requester_t; + + static std::string name() + { + return "Requester"; + } +}; + +template<> +struct AttributesTraits +{ + static constexpr NodeType node_type = NodeType::REPLIER; + using NodePtrType = p_node_replier_t; + using NodeUniquePtrType = up_replier_t; + + static std::string name() + { + return "Replier"; + } +}; + +template +XMLP_ret fill_attributes_from_xml( + const std::string& xml, + AttributesType& atts, + const std::string& profile_name) +{ + using Traits = AttributesTraits; + + up_base_node_t root_node; + XMLP_ret loaded_ret = XMLParser::loadXML(xml.c_str(), xml.size(), root_node); + + if (!root_node || loaded_ret != XMLP_ret::XML_OK) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing string"); + return XMLP_ret::XML_ERROR; + } + + for (auto&& child: root_node->getChildren()) + { + if (Traits::node_type == child.get()->getType()) + { + typename Traits::NodePtrType node = dynamic_cast(child.get()); + + if (!node) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error casting node"); + return XMLP_ret::XML_ERROR; + } + + if (profile_name != "") + { + node_att_map_cit_t it = node->getAttributes().find(PROFILE_NAME); + if (it != node->getAttributes().end() && it->second != profile_name) + { + continue; + } + } + + typename Traits::NodeUniquePtrType node_data = node->getData(); + if (!node_data) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error retrieving node data"); + return XMLP_ret::XML_ERROR; + } + + atts = *node_data; + return XMLP_ret::XML_OK; + } + } + + EPROSIMA_LOG_ERROR(XMLPARSER, Traits::name() << " profile not found"); + return XMLP_ret::XML_ERROR; +} + XMLP_ret XMLProfileManager::fillParticipantAttributes( const std::string& profile_name, ParticipantAttributes& atts, @@ -67,6 +202,14 @@ XMLP_ret XMLProfileManager::fillParticipantAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_participant_attributes_from_xml( + const std::string& xml, + ParticipantAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + XMLP_ret XMLProfileManager::fillPublisherAttributes( const std::string& profile_name, PublisherAttributes& atts, @@ -85,6 +228,14 @@ XMLP_ret XMLProfileManager::fillPublisherAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_publisher_attributes_from_xml( + const std::string& xml, + PublisherAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + XMLP_ret XMLProfileManager::fillSubscriberAttributes( const std::string& profile_name, SubscriberAttributes& atts, @@ -103,6 +254,14 @@ XMLP_ret XMLProfileManager::fillSubscriberAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_subscriber_attributes_from_xml( + const std::string& xml, + SubscriberAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + XMLP_ret XMLProfileManager::fillTopicAttributes( const std::string& profile_name, TopicAttributes& atts) @@ -117,6 +276,14 @@ XMLP_ret XMLProfileManager::fillTopicAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_topic_attributes_from_xml( + const std::string& xml, + TopicAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + XMLP_ret XMLProfileManager::fillRequesterAttributes( const std::string& profile_name, RequesterAttributes& atts) @@ -131,6 +298,14 @@ XMLP_ret XMLProfileManager::fillRequesterAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_requester_attributes_from_xml( + const std::string& xml, + RequesterAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + XMLP_ret XMLProfileManager::fillReplierAttributes( const std::string& profile_name, ReplierAttributes& atts) @@ -145,6 +320,14 @@ XMLP_ret XMLProfileManager::fillReplierAttributes( return XMLP_ret::XML_OK; } +XMLP_ret XMLProfileManager::fill_replier_attributes_from_xml( + const std::string& xml, + ReplierAttributes& atts, + const std::string& profile_name) +{ + return fill_attributes_from_xml(xml, atts, profile_name); +} + void XMLProfileManager::getDefaultParticipantAttributes( ParticipantAttributes& participant_attributes) { diff --git a/src/cpp/xmlparser/XMLProfileManager.h b/src/cpp/xmlparser/XMLProfileManager.h index 7534690994d..93c29e7b902 100644 --- a/src/cpp/xmlparser/XMLProfileManager.h +++ b/src/cpp/xmlparser/XMLProfileManager.h @@ -148,6 +148,11 @@ class XMLProfileManager fastdds::xmlparser::ParticipantAttributes& atts, bool log_error = true); + static XMLP_ret fill_participant_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::ParticipantAttributes& atts, + const std::string& profile_name = ""); + //!Fills participant_attributes with the default values. static void getDefaultParticipantAttributes( fastdds::xmlparser::ParticipantAttributes& participant_attributes); @@ -183,6 +188,11 @@ class XMLProfileManager fastdds::xmlparser::PublisherAttributes& atts, bool log_error = true); + static XMLP_ret fill_publisher_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::PublisherAttributes& atts, + const std::string& profile_name = ""); + //!Fills publisher_attributes with the default values. static void getDefaultPublisherAttributes( fastdds::xmlparser::PublisherAttributes& publisher_attributes); @@ -199,6 +209,11 @@ class XMLProfileManager fastdds::xmlparser::SubscriberAttributes& atts, bool log_error = true); + static XMLP_ret fill_subscriber_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::SubscriberAttributes& atts, + const std::string& profile_name = ""); + //!Fills subscriber_attributes with the default values. static void getDefaultSubscriberAttributes( fastdds::xmlparser::SubscriberAttributes& subscriber_attributes); @@ -222,6 +237,11 @@ class XMLProfileManager const std::string& profile_name, TopicAttributes& atts); + static XMLP_ret fill_topic_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::TopicAttributes& atts, + const std::string& profile_name = ""); + //!Fills topic_attributes with the default values. static void getDefaultTopicAttributes( TopicAttributes& topic_attributes); @@ -245,6 +265,11 @@ class XMLProfileManager const std::string& profile_name, fastdds::xmlparser::RequesterAttributes& atts); + static XMLP_ret fill_requester_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::RequesterAttributes& atts, + const std::string& profile_name = ""); + /** * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. @@ -255,6 +280,11 @@ class XMLProfileManager const std::string& profile_name, fastdds::xmlparser::ReplierAttributes& atts); + static XMLP_ret fill_replier_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::ReplierAttributes& atts, + const std::string& profile_name = ""); + /** * Deletes the XMLProfileManager instance. * FastDDS's Domain calls this method automatically on its destructor, but From 984e26d96263e23eedb9ce93c231bea476bb3004 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 26 Sep 2024 09:05:01 +0200 Subject: [PATCH 02/18] Refs #21745. Add from_profile overloads with extra info Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 8 +++++++ include/fastdds/dds/publisher/Publisher.hpp | 5 ++++ include/fastdds/dds/subscriber/Subscriber.hpp | 5 ++++ src/cpp/fastdds/domain/DomainParticipant.cpp | 13 ++++++++++- .../fastdds/domain/DomainParticipantImpl.cpp | 23 +++++++++++++++++++ .../fastdds/domain/DomainParticipantImpl.hpp | 8 +++++++ src/cpp/fastdds/publisher/Publisher.cpp | 8 +++++++ src/cpp/fastdds/publisher/PublisherImpl.cpp | 17 ++++++++++++++ src/cpp/fastdds/publisher/PublisherImpl.hpp | 5 ++++ src/cpp/fastdds/subscriber/Subscriber.cpp | 8 +++++++ src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 17 ++++++++++++++ src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 5 ++++ 12 files changed, 121 insertions(+), 1 deletion(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index e0c45256645..751c7b93c8c 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -665,9 +665,17 @@ class DomainParticipant : public Entity const std::string& profile_name, TopicQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_profile( + const std::string& profile_name, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type, const std::string& profile_name = "") const; /** diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index 58a2274e4c4..9cc1f9344bd 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -342,6 +342,11 @@ class Publisher : public DomainEntity const std::string& profile_name, DataWriterQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile( + const std::string& profile_name, + DataWriterQos& qos, + std::string& topic_name) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 373de4ecf18..1409bbf2642 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -355,6 +355,11 @@ class Subscriber : public DomainEntity const std::string& profile_name, DataReaderQos& qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile( + const std::string& profile_name, + DataReaderQos& qos, + std::string& topic_name) const; + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/fastdds/domain/DomainParticipant.cpp b/src/cpp/fastdds/domain/DomainParticipant.cpp index e73d520a011..85d0b332afc 100644 --- a/src/cpp/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/fastdds/domain/DomainParticipant.cpp @@ -402,12 +402,23 @@ ReturnCode_t DomainParticipant::get_topic_qos_from_profile( return impl_->get_topic_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_topic_qos_from_profile( + const std::string& profile_name, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + return impl_->get_topic_qos_from_profile(profile_name, qos, topic_name, topic_data_type); +} + ReturnCode_t DomainParticipant::get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type, const std::string& profile_name) const { - return impl_->get_topic_qos_from_xml(xml, qos, profile_name); + return impl_->get_topic_qos_from_xml(xml, qos, topic_name, topic_data_type, profile_name); } ReturnCode_t DomainParticipant::get_requester_qos_from_profile( diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 3603be63b6c..51b74a7fd72 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1172,9 +1172,30 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( + const std::string& profile_name, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + xmlparser::TopicAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr)) + { + qos = default_topic_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.getTopicName(); + topic_data_type = attr.getTopicDataType(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( const std::string& profile_name, TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type, const std::string& xml) const { xmlparser::TopicAttributes attr; @@ -1182,6 +1203,8 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( { qos = default_topic_qos_; utils::set_qos_from_attributes(qos, attr); + topic_name = attr.getTopicName(); + topic_data_type = attr.getTopicDataType(); return RETCODE_OK; } diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp index abd2a94c1f9..5b6c6431cf5 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp @@ -407,9 +407,17 @@ class DomainParticipantImpl const std::string& profile_name, TopicQos& qos) const; + ReturnCode_t get_topic_qos_from_profile( + const std::string& profile_name, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; + ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type, const std::string& profile_name = "") const; ReturnCode_t get_replier_qos_from_profile( diff --git a/src/cpp/fastdds/publisher/Publisher.cpp b/src/cpp/fastdds/publisher/Publisher.cpp index f80642c6111..47abd9d3598 100644 --- a/src/cpp/fastdds/publisher/Publisher.cpp +++ b/src/cpp/fastdds/publisher/Publisher.cpp @@ -237,6 +237,14 @@ ReturnCode_t Publisher::get_datawriter_qos_from_profile( return impl_->get_datawriter_qos_from_profile(profile_name, qos); } +ReturnCode_t Publisher::get_datawriter_qos_from_profile( + const std::string& profile_name, + DataWriterQos& qos, + std::string& topic_name) const +{ + return impl_->get_datawriter_qos_from_profile(profile_name, qos, topic_name); +} + ReturnCode_t Publisher::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index 234732be004..fb50b2e2b73 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -474,6 +474,23 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( + const std::string& profile_name, + DataWriterQos& qos, + std::string& topic_name) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fillPublisherAttributes(profile_name, attr, false)) + { + qos = default_datawriter_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/publisher/PublisherImpl.hpp b/src/cpp/fastdds/publisher/PublisherImpl.hpp index 6fc42a976b9..f6cf5411521 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -169,6 +169,11 @@ class PublisherImpl const std::string& profile_name, DataWriterQos& qos) const; + ReturnCode_t get_datawriter_qos_from_profile( + const std::string& profile_name, + DataWriterQos& qos, + std::string& topic_name) const; + ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/subscriber/Subscriber.cpp b/src/cpp/fastdds/subscriber/Subscriber.cpp index ad71e8134f4..54ad98d31cd 100644 --- a/src/cpp/fastdds/subscriber/Subscriber.cpp +++ b/src/cpp/fastdds/subscriber/Subscriber.cpp @@ -218,6 +218,14 @@ ReturnCode_t Subscriber::get_datareader_qos_from_profile( return impl_->get_datareader_qos_from_profile(profile_name, qos); } +ReturnCode_t Subscriber::get_datareader_qos_from_profile( + const std::string& profile_name, + DataReaderQos& qos, + std::string& topic_name) const +{ + return impl_->get_datareader_qos_from_profile(profile_name, qos, topic_name); +} + ReturnCode_t Subscriber::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 55bf9b287e0..898d34ca77a 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -436,6 +436,23 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( + const std::string& profile_name, + DataReaderQos& qos, + std::string& topic_name) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fillSubscriberAttributes(profile_name, attr, false)) + { + qos = default_datareader_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index ec0088d330e..b64eb3fbf9c 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -147,6 +147,11 @@ class SubscriberImpl const std::string& profile_name, DataReaderQos& qos) const; + ReturnCode_t get_datareader_qos_from_profile( + const std::string& profile_name, + DataReaderQos& qos, + std::string& topic_name) const; + ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, From 48db7d953a0ef0d37d0cec129a2015ac01af7996 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 26 Sep 2024 10:19:10 +0200 Subject: [PATCH 03/18] Refs #21745. Add get_participant_extended_qos_from_xml Signed-off-by: Juan Lopez Fernandez --- .../dds/domain/DomainParticipantFactory.hpp | 5 +++++ .../fastdds/domain/DomainParticipantFactory.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index e381aee05c1..d8e54b2b72d 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -245,6 +245,11 @@ class DomainParticipantFactory const std::string& profile_name, DomainParticipantExtendedQos& extended_qos) const; + FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos, + const std::string& profile_name = "") const; + /** * Fills the DomainParticipantExtendedQos with the values of the default XML profile. * diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index f596dc8a148..50ecdb560fb 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -372,6 +372,22 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos, + const std::string& profile_name) const +{ + extended_qos = default_participant_qos_; + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, profile_name)) + { + utils::set_extended_qos_from_attributes(extended_qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_default_profile( DomainParticipantExtendedQos& extended_qos) const { From 8df184ad7637f1c9d934e5ffa0558487d7aac8ef Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 26 Sep 2024 14:45:52 +0200 Subject: [PATCH 04/18] Refs #21745. Fix typo Signed-off-by: Juan Lopez Fernandez --- src/cpp/fastdds/domain/DomainParticipantImpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 51b74a7fd72..b27680dba81 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1192,11 +1192,11 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( } ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( - const std::string& profile_name, + const std::string& xml, TopicQos& qos, std::string& topic_name, std::string& topic_data_type, - const std::string& xml) const + const std::string& profile_name) const { xmlparser::TopicAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fill_topic_attributes_from_xml(xml, attr, profile_name)) From f8b34a396824a6c6caaca9acd3d1bb753c552d38 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Fri, 27 Sep 2024 12:06:41 +0200 Subject: [PATCH 05/18] Refs #21745. Export DomainParticipant::has_active_entities Signed-off-by: Juan Lopez Fernandez --- include/fastdds/dds/domain/DomainParticipant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index 751c7b93c8c..b79f8a152af 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -936,7 +936,7 @@ class DomainParticipant : public Entity * * @return true if any, false otherwise. */ - bool has_active_entities(); + FASTDDS_EXPORTED_API bool has_active_entities(); protected: From eb2819d59e8734ebcc09e0356a686f67e230b2d7 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 1 Oct 2024 08:29:17 +0200 Subject: [PATCH 06/18] Refs #21745. Change skip condition in fill_attributes_from_xml when profile requested Signed-off-by: Juan Lopez Fernandez --- src/cpp/xmlparser/XMLProfileManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 4143ae25bec..1f9b2fce482 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -162,8 +162,9 @@ XMLP_ret fill_attributes_from_xml( if (profile_name != "") { node_att_map_cit_t it = node->getAttributes().find(PROFILE_NAME); - if (it != node->getAttributes().end() && it->second != profile_name) + if (it == node->getAttributes().end() || it->second != profile_name) { + // No profile name in this node, or different than the one requested continue; } } From f571032dedf314c244abb4e8921bdc24d1811f35 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 1 Oct 2024 09:24:24 +0200 Subject: [PATCH 07/18] Refs #21745. Add docstrings for new methods Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 51 ++++++++++++++++++ .../dds/domain/DomainParticipantFactory.hpp | 16 ++++++ include/fastdds/dds/publisher/Publisher.hpp | 17 ++++++ include/fastdds/dds/subscriber/Subscriber.hpp | 17 ++++++ src/cpp/xmlparser/XMLProfileManager.h | 54 ++++++++++++++++--- 5 files changed, 149 insertions(+), 6 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index b79f8a152af..cfddddff25c 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -547,6 +547,14 @@ class DomainParticipant : public Entity const std::string& profile_name, PublisherQos& qos) const; + /** + * Fills the PublisherQos with the first publisher profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos PublisherQos object where the qos is returned. + * @param profile_name Publisher profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos, @@ -606,6 +614,14 @@ class DomainParticipant : public Entity const std::string& profile_name, SubscriberQos& qos) const; + /** + * Fills the SubscriberQos with the first subscriber profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos SubscriberQos object where the qos is returned. + * @param profile_name Subscriber profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos, @@ -665,12 +681,31 @@ class DomainParticipant : public Entity const std::string& profile_name, TopicQos& qos) const; + /** + * Fills the TopicQos with the values of the XML profile, and also its corresponding topic and data type names (if specified). + * + * @param profile_name Topic profile name. + * @param qos TopicQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). + * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_profile( const std::string& profile_name, TopicQos& qos, std::string& topic_name, std::string& topic_data_type) const; + /** + * Fills the TopicQos with the first topic profile found in the given XML (or the one specified), and also its corresponding topic and data type names (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). + * @param profile_name Topic profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, @@ -689,6 +724,14 @@ class DomainParticipant : public Entity const std::string& profile_name, ReplierQos& qos) const; + /** + * Fills the ReplierQos with the first replier profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos ReplierQos object where the qos is returned. + * @param profile_name Replier profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos, @@ -705,6 +748,14 @@ class DomainParticipant : public Entity const std::string& profile_name, RequesterQos& qos) const; + /** + * Fills the RequesterQos with the first requester profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos RequesterQos object where the qos is returned. + * @param profile_name Requester profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos, diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index d8e54b2b72d..744fca0bea3 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -229,6 +229,14 @@ class DomainParticipantFactory const std::string& profile_name, DomainParticipantQos& qos) const; + /** + * Fills the DomainParticipantQos with the first DomainParticipant profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DomainParticipantQos object where the qos is returned. + * @param profile_name DomainParticipant profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( const std::string& xml, DomainParticipantQos& qos, @@ -245,6 +253,14 @@ class DomainParticipantFactory const std::string& profile_name, DomainParticipantExtendedQos& extended_qos) const; + /** + * Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DomainParticipantExtendedQos object where the qos is returned. + * @param profile_name DomainParticipant profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos, diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index 9cc1f9344bd..2f920ab938f 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -342,11 +342,28 @@ class Publisher : public DomainEntity const std::string& profile_name, DataWriterQos& qos) const; + /** + * Fills the DataWriterQos with the values of the XML profile, and also its corresponding topic name (if specified). + * + * @param profile_name DataWriter profile name. + * @param qos DataWriterQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile( const std::string& profile_name, DataWriterQos& qos, std::string& topic_name) const; + /** + * Fills the DataWriterQos with the first DataWriter profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param profile_name DataWriter profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 1409bbf2642..2ca78e95f75 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -355,11 +355,28 @@ class Subscriber : public DomainEntity const std::string& profile_name, DataReaderQos& qos) const; + /** + * Fills the DataReaderQos with the values of the XML profile, and also its corresponding topic name (if specified). + * + * @param profile_name DataReader profile name. + * @param qos DataReaderQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile( const std::string& profile_name, DataReaderQos& qos, std::string& topic_name) const; + /** + * Fills the DataReaderQos with the first DataReader profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param profile_name DataReader profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/xmlparser/XMLProfileManager.h b/src/cpp/xmlparser/XMLProfileManager.h index 93c29e7b902..0e44d876c76 100644 --- a/src/cpp/xmlparser/XMLProfileManager.h +++ b/src/cpp/xmlparser/XMLProfileManager.h @@ -140,14 +140,21 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillParticipantAttributes( const std::string& profile_name, fastdds::xmlparser::ParticipantAttributes& atts, bool log_error = true); + /** + * Search for the first participant profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_participant_attributes_from_xml( const std::string& xml, fastdds::xmlparser::ParticipantAttributes& atts, @@ -180,14 +187,21 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillPublisherAttributes( const std::string& profile_name, fastdds::xmlparser::PublisherAttributes& atts, bool log_error = true); + /** + * Search for the first publisher profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_publisher_attributes_from_xml( const std::string& xml, fastdds::xmlparser::PublisherAttributes& atts, @@ -201,14 +215,21 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. - * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillSubscriberAttributes( const std::string& profile_name, fastdds::xmlparser::SubscriberAttributes& atts, bool log_error = true); + /** + * Search for the first subscriber profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_subscriber_attributes_from_xml( const std::string& xml, fastdds::xmlparser::SubscriberAttributes& atts, @@ -237,6 +258,13 @@ class XMLProfileManager const std::string& profile_name, TopicAttributes& atts); + /** + * Search for the first topic profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_topic_attributes_from_xml( const std::string& xml, fastdds::xmlparser::TopicAttributes& atts, @@ -265,6 +293,13 @@ class XMLProfileManager const std::string& profile_name, fastdds::xmlparser::RequesterAttributes& atts); + /** + * Search for the first requester profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_requester_attributes_from_xml( const std::string& xml, fastdds::xmlparser::RequesterAttributes& atts, @@ -280,6 +315,13 @@ class XMLProfileManager const std::string& profile_name, fastdds::xmlparser::ReplierAttributes& atts); + /** + * Search for the first replier profile found in the given XML (or the one specified) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ static XMLP_ret fill_replier_attributes_from_xml( const std::string& xml, fastdds::xmlparser::ReplierAttributes& atts, From 66873506c8fee7158f7ef2a34a64e03327c24b93 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 2 Oct 2024 15:06:24 +0200 Subject: [PATCH 08/18] Refs #21745. Refactor fill_attributes_from_xml to parse recursively Signed-off-by: Juan Lopez Fernandez --- src/cpp/xmlparser/XMLProfileManager.cpp | 86 ++++++++++++++++++------- 1 file changed, 61 insertions(+), 25 deletions(-) diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 1f9b2fce482..596f5eefcc7 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -15,6 +15,7 @@ #include #include +#include #ifdef _WIN32 #include #else @@ -147,38 +148,73 @@ XMLP_ret fill_attributes_from_xml( return XMLP_ret::XML_ERROR; } - for (auto&& child: root_node->getChildren()) - { - if (Traits::node_type == child.get()->getType()) - { - typename Traits::NodePtrType node = dynamic_cast(child.get()); - - if (!node) + // Process node function + auto process_node = [](const up_base_node_t& node_to_process, AttributesType& atts, const std::string& profile_name) { - EPROSIMA_LOG_ERROR(XMLPARSER, "Error casting node"); - return XMLP_ret::XML_ERROR; - } + // If node type doesn't match, skip + if (Traits::node_type != node_to_process->getType()) + { + return XMLP_ret::XML_NOK; + } - if (profile_name != "") - { - node_att_map_cit_t it = node->getAttributes().find(PROFILE_NAME); - if (it == node->getAttributes().end() || it->second != profile_name) + // Cast the node to the expected type + typename Traits::NodePtrType node = dynamic_cast(node_to_process.get()); + if (!node) { - // No profile name in this node, or different than the one requested - continue; + EPROSIMA_LOG_ERROR(XMLPARSER, "Error casting node"); + return XMLP_ret::XML_ERROR; + } + + // Check profile name, if provided + if (profile_name != "") + { + node_att_map_cit_t it = node->getAttributes().find(PROFILE_NAME); + if (it == node->getAttributes().end() || it->second != profile_name) + { + // No profile name in this node, or different than the one requested + return XMLP_ret::XML_NOK; + } } - } - typename Traits::NodeUniquePtrType node_data = node->getData(); - if (!node_data) + // Retrieve node data + typename Traits::NodeUniquePtrType node_data = node->getData(); + if (!node_data) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Error retrieving node data"); + return XMLP_ret::XML_ERROR; + } + + // Fill attributes + atts = *node_data; + return XMLP_ret::XML_OK; + }; + + // Recursive function to process the root node and its children + std::function process_node_recursive; + process_node_recursive = + [&process_node, &process_node_recursive](const up_base_node_t& node_to_process, AttributesType& atts, + const std::string& profile_name) { - EPROSIMA_LOG_ERROR(XMLPARSER, "Error retrieving node data"); - return XMLP_ret::XML_ERROR; - } + XMLP_ret ret = process_node(node_to_process, atts, profile_name); + if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) + { + return ret; + } - atts = *node_data; - return XMLP_ret::XML_OK; - } + for (auto&& child: node_to_process->getChildren()) + { + ret = process_node_recursive(child, atts, profile_name); + if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) + { + return ret; + } + } + return XMLP_ret::XML_NOK; + }; + + if (XMLP_ret::XML_OK == process_node_recursive(root_node, atts, profile_name)) + { + return XMLP_ret::XML_OK; } EPROSIMA_LOG_ERROR(XMLPARSER, Traits::name() << " profile not found"); From 3522b0e3f388daaf7fffb2afe83ed66f1db44e52 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 2 Oct 2024 15:07:35 +0200 Subject: [PATCH 09/18] Refs #21745. Add more overloads and remove redundant implementations Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 13 +++++++++++ include/fastdds/dds/publisher/Publisher.hpp | 13 +++++++++++ include/fastdds/dds/subscriber/Subscriber.hpp | 13 +++++++++++ src/cpp/fastdds/domain/DomainParticipant.cpp | 8 +++++++ .../fastdds/domain/DomainParticipantImpl.cpp | 22 +++++++++++-------- .../fastdds/domain/DomainParticipantImpl.hpp | 5 +++++ src/cpp/fastdds/publisher/Publisher.cpp | 8 +++++++ src/cpp/fastdds/publisher/PublisherImpl.cpp | 20 +++++++++-------- src/cpp/fastdds/publisher/PublisherImpl.hpp | 5 +++++ src/cpp/fastdds/subscriber/Subscriber.cpp | 8 +++++++ src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 20 +++++++++-------- src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 5 +++++ 12 files changed, 113 insertions(+), 27 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index cfddddff25c..a06fdfc79fc 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -696,6 +696,19 @@ class DomainParticipant : public Entity std::string& topic_name, std::string& topic_data_type) const; + /** + * Fills the TopicQos with the first topic profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @param profile_name Topic profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name = "") const; + /** * Fills the TopicQos with the first topic profile found in the given XML (or the one specified), and also its corresponding topic and data type names (if specified). * diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index 2f920ab938f..c9f11c070fc 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -355,6 +355,19 @@ class Publisher : public DomainEntity DataWriterQos& qos, std::string& topic_name) const; + /** + * Fills the DataWriterQos with the first DataWriter profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @param profile_name DataWriter profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + const std::string& profile_name = "") const; + /** * Fills the DataWriterQos with the first DataWriter profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). * diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 2ca78e95f75..4b6a3849059 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -368,6 +368,19 @@ class Subscriber : public DomainEntity DataReaderQos& qos, std::string& topic_name) const; + /** + * Fills the DataReaderQos with the first DataReader profile found in the given XML (or the one specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @param profile_name DataReader profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + const std::string& profile_name = "") const; + /** * Fills the DataReaderQos with the first DataReader profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). * diff --git a/src/cpp/fastdds/domain/DomainParticipant.cpp b/src/cpp/fastdds/domain/DomainParticipant.cpp index 85d0b332afc..9253a71e865 100644 --- a/src/cpp/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/fastdds/domain/DomainParticipant.cpp @@ -411,6 +411,14 @@ ReturnCode_t DomainParticipant::get_topic_qos_from_profile( return impl_->get_topic_qos_from_profile(profile_name, qos, topic_name, topic_data_type); } +ReturnCode_t DomainParticipant::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name) const +{ + return impl_->get_topic_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t DomainParticipant::get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index b27680dba81..dd9a7110cd0 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1161,15 +1161,9 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( const std::string& profile_name, TopicQos& qos) const { - xmlparser::TopicAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr)) - { - qos = default_topic_qos_; - utils::set_qos_from_attributes(qos, attr); - return RETCODE_OK; - } - - return RETCODE_BAD_PARAMETER; + std::string _topic_name; + std::string _topic_data_type; + return get_topic_qos_from_profile(profile_name, qos, _topic_name, _topic_data_type); } ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( @@ -1191,6 +1185,16 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name) const +{ + std::string _topic_name; + std::string _topic_data_type; + return get_topic_qos_from_xml(xml, qos, _topic_name, _topic_data_type, profile_name); +} + ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp index 5b6c6431cf5..1925aff1fff 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp @@ -413,6 +413,11 @@ class DomainParticipantImpl std::string& topic_name, std::string& topic_data_type) const; + ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, diff --git a/src/cpp/fastdds/publisher/Publisher.cpp b/src/cpp/fastdds/publisher/Publisher.cpp index 47abd9d3598..a84d2f0172e 100644 --- a/src/cpp/fastdds/publisher/Publisher.cpp +++ b/src/cpp/fastdds/publisher/Publisher.cpp @@ -245,6 +245,14 @@ ReturnCode_t Publisher::get_datawriter_qos_from_profile( return impl_->get_datawriter_qos_from_profile(profile_name, qos, topic_name); } +ReturnCode_t Publisher::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + const std::string& profile_name) const +{ + return impl_->get_datawriter_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t Publisher::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index fb50b2e2b73..b6677f4c198 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -463,15 +463,8 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( const std::string& profile_name, DataWriterQos& qos) const { - xmlparser::PublisherAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fillPublisherAttributes(profile_name, attr, false)) - { - qos = default_datawriter_qos_; - utils::set_qos_from_attributes(qos, attr); - return RETCODE_OK; - } - - return RETCODE_BAD_PARAMETER; + std::string _topic_name; + return get_datawriter_qos_from_profile(profile_name, qos, _topic_name); } ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( @@ -491,6 +484,15 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + const std::string& profile_name) const +{ + std::string _topic_name; + return get_datawriter_qos_from_xml(xml, qos, _topic_name, profile_name); +} + ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/publisher/PublisherImpl.hpp b/src/cpp/fastdds/publisher/PublisherImpl.hpp index f6cf5411521..f3946ecbfcc 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -174,6 +174,11 @@ class PublisherImpl DataWriterQos& qos, std::string& topic_name) const; + ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, diff --git a/src/cpp/fastdds/subscriber/Subscriber.cpp b/src/cpp/fastdds/subscriber/Subscriber.cpp index 54ad98d31cd..37ff713efe6 100644 --- a/src/cpp/fastdds/subscriber/Subscriber.cpp +++ b/src/cpp/fastdds/subscriber/Subscriber.cpp @@ -226,6 +226,14 @@ ReturnCode_t Subscriber::get_datareader_qos_from_profile( return impl_->get_datareader_qos_from_profile(profile_name, qos, topic_name); } +ReturnCode_t Subscriber::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + const std::string& profile_name) const +{ + return impl_->get_datareader_qos_from_xml(xml, qos, profile_name); +} + ReturnCode_t Subscriber::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 898d34ca77a..733f294d51b 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -425,15 +425,8 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( const std::string& profile_name, DataReaderQos& qos) const { - xmlparser::SubscriberAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fillSubscriberAttributes(profile_name, attr, false)) - { - qos = default_datareader_qos_; - utils::set_qos_from_attributes(qos, attr); - return RETCODE_OK; - } - - return RETCODE_BAD_PARAMETER; + std::string _topic_name; + return get_datareader_qos_from_profile(profile_name, qos, _topic_name); } ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( @@ -453,6 +446,15 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + const std::string& profile_name) const +{ + std::string _topic_name; + return get_datareader_qos_from_xml(xml, qos, _topic_name, profile_name); +} + ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index b64eb3fbf9c..d1d23b62d01 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -152,6 +152,11 @@ class SubscriberImpl DataReaderQos& qos, std::string& topic_name) const; + ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + const std::string& profile_name = "") const; + ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, From 80a2f203e489a113eceb190197a09dacf6b8ee7f Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 2 Oct 2024 15:08:12 +0200 Subject: [PATCH 10/18] Refs #21745. Add unittests Signed-off-by: Juan Lopez Fernandez --- .../fastdds/domain/DomainParticipantImpl.hpp | 59 ++++ test/unittest/dds/participant/CMakeLists.txt | 1 + .../dds/participant/ParticipantTests.cpp | 319 ++++++++++++++++++ test/unittest/dds/publisher/CMakeLists.txt | 1 + .../unittest/dds/publisher/PublisherTests.cpp | 51 +++ test/unittest/dds/subscriber/CMakeLists.txt | 1 + .../dds/subscriber/SubscriberTests.cpp | 51 +++ test/utils/FileUtils.hpp | 51 +++ 8 files changed, 534 insertions(+) create mode 100644 test/utils/FileUtils.hpp diff --git a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp index fed9eddfb7b..6bc4bd99ae7 100644 --- a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp +++ b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp @@ -479,6 +479,14 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_publisher_qos_from_xml( + const std::string& /*xml*/, + PublisherQos& /*qos*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + ReturnCode_t set_default_subscriber_qos( const SubscriberQos& /*qos*/) { @@ -497,6 +505,14 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_subscriber_qos_from_xml( + const std::string& /*xml*/, + SubscriberQos& /*qos*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + ReturnCode_t set_default_topic_qos( const TopicQos& /*qos*/) { @@ -515,6 +531,33 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_topic_qos_from_profile( + const std::string& /*profile_name*/, + TopicQos& /*qos*/, + std::string& /*topic_name*/, + std::string& /*topic_data_type*/) const + { + return RETCODE_OK; + } + + ReturnCode_t get_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + + ReturnCode_t get_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/, + std::string& /*topic_name*/, + std::string& /*topic_data_type*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_replier_qos_from_profile( const std::string& /*profile_name*/, ReplierQos& /*qos*/) const @@ -522,6 +565,14 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_replier_qos_from_xml( + const std::string& /*xml*/, + ReplierQos& /*qos*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_requester_qos_from_profile( const std::string& /*profile_name*/, RequesterQos& /*qos*/) const @@ -529,6 +580,14 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_requester_qos_from_xml( + const std::string& /*xml*/, + RequesterQos& /*qos*/, + const std::string& /*profile_name*/) const + { + return RETCODE_OK; + } + bool contains_entity( const InstanceHandle_t& /*handle*/, bool /*recursive*/) const diff --git a/test/unittest/dds/participant/CMakeLists.txt b/test/unittest/dds/participant/CMakeLists.txt index d8644da7ea3..40952009401 100644 --- a/test/unittest/dds/participant/CMakeLists.txt +++ b/test/unittest/dds/participant/CMakeLists.txt @@ -41,6 +41,7 @@ target_compile_definitions(ParticipantTests PRIVATE target_include_directories(ParticipantTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp + ${PROJECT_SOURCE_DIR}/test/utils ) target_link_libraries(ParticipantTests fastdds fastcdr foonathan_memory GTest::gmock diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 171e34af31f..5512d88eba5 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -67,6 +67,8 @@ #include #include +#include + #include "../../common/env_var_utils.hpp" #include "../../logging/mock/MockConsumer.h" @@ -752,6 +754,88 @@ TEST(ParticipantTests, GetParticipantProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetParticipantQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_participant_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + // Get QoS given profile name + DomainParticipantQos qos; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + DomainParticipantQos qos_empty_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file + check_equivalent_qos(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + DomainParticipantQos qos_from_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + check_equivalent_qos(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos, + "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); +} + +TEST(ParticipantTests, GetParticipantExtendedQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_participant_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + // Get QoS given profile name + DomainParticipantExtendedQos qos; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos, + profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + DomainParticipantExtendedQos qos_empty_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos_empty_profile, + ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file + check_equivalent_extended_qos(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + DomainParticipantExtendedQos qos_from_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile(profile_name, + qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + check_equivalent_extended_qos(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos, + "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); +} TEST(ParticipantTests, DeleteDomainParticipant) { @@ -1992,6 +2076,53 @@ TEST(ParticipantTests, GetSubscriberProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetSubscriberQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_subscriber_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get QoS given profile name + SubscriberQos qos; + EXPECT_EQ( + participant->get_subscriber_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + SubscriberQos qos_empty_profile; + EXPECT_EQ( + participant->get_subscriber_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_subscriber_profile is assumed to be the first subscriber profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + SubscriberQos qos_from_profile; + EXPECT_EQ( + participant->get_subscriber_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + participant->get_subscriber_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, CreateSubscriberWithProfile) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2043,6 +2174,53 @@ TEST(ParticipantTests, GetPublisherProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetPublisherQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_publisher_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get QoS given profile name + PublisherQos qos; + EXPECT_EQ( + participant->get_publisher_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + PublisherQos qos_empty_profile; + EXPECT_EQ( + participant->get_publisher_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_publisher_profile is assumed to be the first publisher profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + PublisherQos qos_from_profile; + EXPECT_EQ( + participant->get_publisher_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + participant->get_publisher_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, GetReplierProfileQos) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2066,6 +2244,53 @@ TEST(ParticipantTests, GetReplierProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetReplierQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_replier_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get QoS given profile name + ReplierQos qos; + EXPECT_EQ( + participant->get_replier_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + ReplierQos qos_empty_profile; + EXPECT_EQ( + participant->get_replier_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_replier_profile is assumed to be the first replier profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + ReplierQos qos_from_profile; + EXPECT_EQ( + participant->get_replier_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + participant->get_replier_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, GetRequesterProfileQos) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2089,6 +2314,53 @@ TEST(ParticipantTests, GetRequesterProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetRequesterQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_requester_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get QoS given profile name + RequesterQos qos; + EXPECT_EQ( + participant->get_requester_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + RequesterQos qos_empty_profile; + EXPECT_EQ( + participant->get_requester_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_requester_profile is assumed to be the first requester profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + RequesterQos qos_from_profile; + EXPECT_EQ( + participant->get_requester_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + participant->get_requester_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, DeletePublisher) { DomainParticipant* participant = @@ -2215,6 +2487,53 @@ TEST(ParticipantTests, GetTopicProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetTopicQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_topic_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get QoS given profile name + TopicQos qos; + EXPECT_EQ( + participant->get_topic_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + TopicQos qos_empty_profile; + EXPECT_EQ( + participant->get_topic_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_topic_profile is assumed to be the first topic profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + TopicQos qos_from_profile; + EXPECT_EQ( + participant->get_topic_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + participant->get_topic_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, CreateTopic) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 4c789efab33..baae50dacb6 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -321,6 +321,7 @@ target_include_directories(PublisherTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp ${PROJECT_SOURCE_DIR}/thirdparty/taocpp-pegtl + ${PROJECT_SOURCE_DIR}/test/utils ) target_link_libraries(PublisherTests fastdds fastcdr foonathan_memory GTest::gmock diff --git a/test/unittest/dds/publisher/PublisherTests.cpp b/test/unittest/dds/publisher/PublisherTests.cpp index 30fbe9849bf..a24cee069ce 100644 --- a/test/unittest/dds/publisher/PublisherTests.cpp +++ b/test/unittest/dds/publisher/PublisherTests.cpp @@ -27,6 +27,8 @@ #include #include +#include + namespace eprosima { namespace fastdds { namespace dds { @@ -569,6 +571,55 @@ TEST(PublisherTests, GetDataWriterProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(PublisherTests, GetDataWriterQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_publisher_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); + ASSERT_NE(publisher, nullptr); + + // Get QoS given profile name + DataWriterQos qos; + EXPECT_EQ( + publisher->get_datawriter_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + DataWriterQos qos_empty_profile; + EXPECT_EQ( + publisher->get_datawriter_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_publisher_profile is assumed to be the first publisher profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + DataWriterQos qos_from_profile; + EXPECT_EQ( + publisher->get_datawriter_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + publisher->get_datawriter_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(participant->delete_publisher(publisher), RETCODE_OK); + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(PublisherTests, DeletePublisherWithWriters) { DomainParticipant* participant = diff --git a/test/unittest/dds/subscriber/CMakeLists.txt b/test/unittest/dds/subscriber/CMakeLists.txt index 657bb10ea5c..315dd4b887e 100644 --- a/test/unittest/dds/subscriber/CMakeLists.txt +++ b/test/unittest/dds/subscriber/CMakeLists.txt @@ -73,6 +73,7 @@ target_compile_definitions(SubscriberTests PRIVATE target_include_directories(SubscriberTests PRIVATE ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include ${PROJECT_SOURCE_DIR}/src/cpp + ${PROJECT_SOURCE_DIR}/test/utils ) target_link_libraries(SubscriberTests fastdds fastcdr foonathan_memory GTest::gmock diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index 82d27d999ff..d4c3456dcd3 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -30,6 +30,8 @@ #include #include +#include + namespace eprosima { namespace fastdds { namespace dds { @@ -593,6 +595,55 @@ TEST(SubscriberTests, GetDataReaderProfileQos) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(SubscriberTests, GetDataReaderQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + const std::string profile_name("test_subscriber_profile"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + Subscriber* subscriber = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT); + ASSERT_NE(subscriber, nullptr); + + // Get QoS given profile name + DataReaderQos qos; + EXPECT_EQ( + subscriber->get_datareader_qos_from_xml(complete_xml, qos, profile_name), + RETCODE_OK); + + // Get QoS given profile name with empty profile name (gets first one found) + DataReaderQos qos_empty_profile; + EXPECT_EQ( + subscriber->get_datareader_qos_from_xml(complete_xml, qos_empty_profile, ""), + RETCODE_OK); + + // Check they correspond to the same profile + // NOTE: test_subscriber_profile is assumed to be the first subscriber profile in the XML file + EXPECT_EQ(qos, qos_empty_profile); + + // Load profiles from XML file and get QoS given profile name + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + DataReaderQos qos_from_profile; + EXPECT_EQ( + subscriber->get_datareader_qos_from_profile(profile_name, qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(qos, qos_from_profile); + + // Test return when a non-existent profile is used + EXPECT_EQ( + subscriber->get_datareader_qos_from_xml(complete_xml, qos, "incorrect_profile_name"), + RETCODE_BAD_PARAMETER); + + // Clean up + ASSERT_EQ(participant->delete_subscriber(subscriber), RETCODE_OK); + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(SubscriberTests, DeleteSubscriberWithReaders) { DomainParticipant* participant = diff --git a/test/utils/FileUtils.hpp b/test/utils/FileUtils.hpp new file mode 100644 index 00000000000..bb85ce33edd --- /dev/null +++ b/test/utils/FileUtils.hpp @@ -0,0 +1,51 @@ +// Copyright 2024 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. +// +#ifndef _TEST_UTILS_FILEUTILS_HPP_ +#define _TEST_UTILS_FILEUTILS_HPP_ + +#include +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace testing { + +std::string load_file(const std::string& file_path) +{ + std::ifstream file(file_path); + + // Check if the file was opened successfully + if (!file.is_open()) { + throw std::runtime_error("Could not open file " + file_path); + } + + // Use a stringstream to read the file contents into a string + std::ostringstream buffer; + buffer << file.rdbuf(); + + // Close the file after reading + file.close(); + + // Return the string containing the file contents + return buffer.str(); +} + +} // namespace testing +} // namespace fastdds +} // namespace eprosima + +#endif // _TEST_UTILS_FILEUTILS_HPP_ From b1c85b2ca78ea71a86e88e9c7e2bb8946041ef0f Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 3 Oct 2024 10:37:34 +0200 Subject: [PATCH 11/18] Refs #21745. Fix docstring Signed-off-by: Juan Lopez Fernandez --- include/fastdds/dds/domain/DomainParticipantFactory.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index 744fca0bea3..9acb387211d 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -257,7 +257,7 @@ class DomainParticipantFactory * Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the given XML (or the one specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DomainParticipantExtendedQos object where the qos is returned. + * @param extended_qos DomainParticipantExtendedQos object where the qos is returned. * @param profile_name DomainParticipant profile name. Empty by default (first one found). * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ From 4a2a35db3dbceba295350950be4ece79ff5b78a6 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Thu, 3 Oct 2024 10:45:22 +0200 Subject: [PATCH 12/18] Refs #21745. Perform full DomainParticipantQos comparison in tests Signed-off-by: Juan Lopez Fernandez --- test/unittest/dds/participant/ParticipantTests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 5512d88eba5..bf8664fb949 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -775,7 +775,7 @@ TEST(ParticipantTests, GetParticipantQosFromXml) // Check they correspond to the same profile // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file - check_equivalent_qos(qos, qos_empty_profile); + EXPECT_EQ(qos, qos_empty_profile); // Load profiles from XML file and get QoS given profile name DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); @@ -785,7 +785,7 @@ TEST(ParticipantTests, GetParticipantQosFromXml) RETCODE_OK); // Check they correspond to the same profile - check_equivalent_qos(qos, qos_from_profile); + EXPECT_EQ(qos, qos_from_profile); // Test return when a non-existent profile is used EXPECT_EQ( @@ -817,7 +817,7 @@ TEST(ParticipantTests, GetParticipantExtendedQosFromXml) // Check they correspond to the same profile // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file - check_equivalent_extended_qos(qos, qos_empty_profile); + EXPECT_EQ(qos, qos_empty_profile); // Load profiles from XML file and get QoS given profile name DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); @@ -828,7 +828,7 @@ TEST(ParticipantTests, GetParticipantExtendedQosFromXml) RETCODE_OK); // Check they correspond to the same profile - check_equivalent_extended_qos(qos, qos_from_profile); + EXPECT_EQ(qos, qos_from_profile); // Test return when a non-existent profile is used EXPECT_EQ( From 5ec322040b39215235152c4816c87b348c3680bf Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 8 Oct 2024 09:31:46 +0200 Subject: [PATCH 13/18] Refs #21745. Apply suggestion Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 176 ++++++++++++-- .../dds/domain/DomainParticipantFactory.hpp | 58 ++++- include/fastdds/dds/publisher/Publisher.hpp | 60 ++++- include/fastdds/dds/subscriber/Subscriber.hpp | 60 ++++- src/cpp/fastdds/domain/DomainParticipant.cpp | 88 +++++++ .../domain/DomainParticipantFactory.cpp | 76 +++++- .../fastdds/domain/DomainParticipantImpl.cpp | 216 +++++++++++++++++- .../fastdds/domain/DomainParticipantImpl.hpp | 64 +++++- src/cpp/fastdds/publisher/Publisher.cpp | 30 +++ src/cpp/fastdds/publisher/PublisherImpl.cpp | 58 ++++- src/cpp/fastdds/publisher/PublisherImpl.hpp | 22 +- src/cpp/fastdds/subscriber/Subscriber.cpp | 30 +++ src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 58 ++++- src/cpp/fastdds/subscriber/SubscriberImpl.hpp | 22 +- src/cpp/xmlparser/XMLProfileManager.cpp | 147 ++++++++++-- src/cpp/xmlparser/XMLProfileManager.h | 96 +++++++- .../fastdds/domain/DomainParticipantImpl.hpp | 88 +++++++ .../dds/participant/ParticipantTests.cpp | 30 ++- .../unittest/dds/publisher/PublisherTests.cpp | 4 +- .../dds/subscriber/SubscriberTests.cpp | 4 +- 20 files changed, 1279 insertions(+), 108 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index a06fdfc79fc..726606a585c 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -548,17 +548,39 @@ class DomainParticipant : public Entity PublisherQos& qos) const; /** - * Fills the PublisherQos with the first publisher profile found in the given XML (or the one specified). + * Fills the PublisherQos with the first publisher profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos PublisherQos object where the qos is returned. - * @param profile_name Publisher profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const; + + /** + * Fills the PublisherQos with the publisher profile with \c profile_name to be found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos PublisherQos object where the qos is returned. + * @param profile_name Publisher profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the PublisherQos with the default publisher profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos PublisherQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const; /** * This operation sets a default value of the Subscriber QoS policies that will be used for newly created @@ -615,17 +637,39 @@ class DomainParticipant : public Entity SubscriberQos& qos) const; /** - * Fills the SubscriberQos with the first subscriber profile found in the given XML (or the one specified). + * Fills the SubscriberQos with the first subscriber profile found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos SubscriberQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const; + + /** + * Fills the SubscriberQos with the subscriber profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos SubscriberQos object where the qos is returned. - * @param profile_name Subscriber profile name. Empty by default (first one found). + * @param profile_name Subscriber profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the SubscriberQos with the default subscriber profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos SubscriberQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const; /** * This operation sets a default value of the Topic QoS policies which will be used for newly created @@ -697,26 +741,52 @@ class DomainParticipant : public Entity std::string& topic_data_type) const; /** - * Fills the TopicQos with the first topic profile found in the given XML (or the one specified). + * Fills the TopicQos with the first topic profile found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const; + + /** + * Fills the TopicQos with the first topic profile found in the provided XML, and also its corresponding topic and data type names (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; + + /** + * Fills the TopicQos with the topic profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos TopicQos object where the qos is returned. - * @param profile_name Topic profile name. Empty by default (first one found). + * @param profile_name Topic profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; /** - * Fills the TopicQos with the first topic profile found in the given XML (or the one specified), and also its corresponding topic and data type names (if specified). + * Fills the TopicQos with the topic profile with \c profile_name to be found in the provided XML, and also its corresponding topic and data type names (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). - * @param profile_name Topic profile name. Empty by default (first one found). + * @param profile_name Topic profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( @@ -724,7 +794,33 @@ class DomainParticipant : public Entity TopicQos& qos, std::string& topic_name, std::string& topic_data_type, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the TopicQos with the default topic profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const; + + /** + * Fills the TopicQos with the default topic profile found in the provided XML (if there is), and also its corresponding topic and data type names (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos TopicQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; /** * Fills the ReplierQos with the values of the XML profile. @@ -738,17 +834,39 @@ class DomainParticipant : public Entity ReplierQos& qos) const; /** - * Fills the ReplierQos with the first replier profile found in the given XML (or the one specified). + * Fills the ReplierQos with the first replier profile found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos ReplierQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const; + + /** + * Fills the ReplierQos with the replier profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos ReplierQos object where the qos is returned. - * @param profile_name Replier profile name. Empty by default (first one found). + * @param profile_name Replier profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the ReplierQos with the default replier profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos ReplierQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const; /** * Fills the RequesterQos with the values of the XML profile. @@ -762,17 +880,39 @@ class DomainParticipant : public Entity RequesterQos& qos) const; /** - * Fills the RequesterQos with the first requester profile found in the given XML (or the one specified). + * Fills the RequesterQos with the first requester profile found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos RequesterQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const; + + /** + * Fills the RequesterQos with the requester profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos RequesterQos object where the qos is returned. - * @param profile_name Requester profile name. Empty by default (first one found). + * @param profile_name Requester profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the RequesterQos with the default requester profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos RequesterQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const; /** * Retrieves the list of DomainParticipants that have been discovered in the domain and are not "ignored". diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index 9acb387211d..bd7ae5a639f 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -230,17 +230,39 @@ class DomainParticipantFactory DomainParticipantQos& qos) const; /** - * Fills the DomainParticipantQos with the first DomainParticipant profile found in the given XML (or the one specified). + * Fills the DomainParticipantQos with the first DomainParticipant profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DomainParticipantQos object where the qos is returned. - * @param profile_name DomainParticipant profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos) const; + + /** + * Fills the DomainParticipantQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DomainParticipantQos object where the qos is returned. + * @param profile_name DomainParticipant profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( const std::string& xml, DomainParticipantQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the DomainParticipantQos with the default DomainParticipant profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DomainParticipantQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos) const; /** * Fills the DomainParticipantExtendedQos with the values of the XML profile. @@ -254,17 +276,39 @@ class DomainParticipantFactory DomainParticipantExtendedQos& extended_qos) const; /** - * Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the given XML (or the one specified). + * Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the provided XML. * - * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. * @param extended_qos DomainParticipantExtendedQos object where the qos is returned. - * @param profile_name DomainParticipant profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos) const; + + /** + * Fills the DomainParticipantExtendedQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. + * @param extended_qos DomainParticipantExtendedQos object where the qos is returned. + * @param profile_name DomainParticipant profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the DomainParticipantExtendedQos with the default DomainParticipant profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. + * @param qos DomainParticipantExtendedQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos) const; /** * Fills the DomainParticipantExtendedQos with the values of the default XML profile. diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index c9f11c070fc..50b3e84f14e 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -356,32 +356,80 @@ class Publisher : public DomainEntity std::string& topic_name) const; /** - * Fills the DataWriterQos with the first DataWriter profile found in the given XML (or the one specified). + * Fills the DataWriterQos with the first DataWriter profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataWriterQos object where the qos is returned. - * @param profile_name DataWriter profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const; + + /** + * Fills the DataWriterQos with the first DataWriter profile found in the provided XML, and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const; + + /** + * Fills the DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @param profile_name DataWriter profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; /** - * Fills the DataWriterQos with the first DataWriter profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). + * Fills the DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @param profile_name DataWriter profile name. Empty by default (first one found). + * @param profile_name DataWriter profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, std::string& topic_name, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const; + + /** + * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is), and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataWriterQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const; /** * Returns the Publisher's handle. diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 4b6a3849059..1c6b594acd8 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -369,32 +369,80 @@ class Subscriber : public DomainEntity std::string& topic_name) const; /** - * Fills the DataReaderQos with the first DataReader profile found in the given XML (or the one specified). + * Fills the DataReaderQos with the first DataReader profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataReaderQos object where the qos is returned. - * @param profile_name DataReader profile name. Empty by default (first one found). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const; + + /** + * Fills the DataReaderQos with the first DataReader profile found in the provided XML, and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const; + + /** + * Fills the DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML. + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @param profile_name DataReader profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; /** - * Fills the DataReaderQos with the first DataReader profile found in the given XML (or the one specified), and also its corresponding topic name (if specified). + * Fills the DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @param profile_name DataReader profile name. Empty by default (first one found). + * @param profile_name DataReader profile name. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, std::string& topic_name, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + /** + * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const; + + /** + * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is), and also its corresponding topic name (if specified). + * + * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. + * @param qos DataReaderQos object where the qos is returned. + * @param topic_name String where the name of the topic associated to this profile is returned (if specified). + * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + */ + FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const; /** * @brief Copies TopicQos into the corresponding DataReaderQos diff --git a/src/cpp/fastdds/domain/DomainParticipant.cpp b/src/cpp/fastdds/domain/DomainParticipant.cpp index 9253a71e865..c68eeb4a95b 100644 --- a/src/cpp/fastdds/domain/DomainParticipant.cpp +++ b/src/cpp/fastdds/domain/DomainParticipant.cpp @@ -336,6 +336,13 @@ ReturnCode_t DomainParticipant::get_publisher_qos_from_profile( return impl_->get_publisher_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const +{ + return impl_->get_publisher_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos, @@ -344,6 +351,13 @@ ReturnCode_t DomainParticipant::get_publisher_qos_from_xml( return impl_->get_publisher_qos_from_xml(xml, qos, profile_name); } +ReturnCode_t DomainParticipant::get_default_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const +{ + return impl_->get_default_publisher_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::set_default_subscriber_qos( const SubscriberQos& qos) { @@ -369,6 +383,13 @@ ReturnCode_t DomainParticipant::get_subscriber_qos_from_profile( return impl_->get_subscriber_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const +{ + return impl_->get_subscriber_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos, @@ -377,6 +398,13 @@ ReturnCode_t DomainParticipant::get_subscriber_qos_from_xml( return impl_->get_subscriber_qos_from_xml(xml, qos, profile_name); } +ReturnCode_t DomainParticipant::get_default_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const +{ + return impl_->get_default_subscriber_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::set_default_topic_qos( const TopicQos& qos) { @@ -411,6 +439,22 @@ ReturnCode_t DomainParticipant::get_topic_qos_from_profile( return impl_->get_topic_qos_from_profile(profile_name, qos, topic_name, topic_data_type); } +ReturnCode_t DomainParticipant::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const +{ + return impl_->get_topic_qos_from_xml(xml, qos); +} + +ReturnCode_t DomainParticipant::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + return impl_->get_topic_qos_from_xml(xml, qos, topic_name, topic_data_type); +} + ReturnCode_t DomainParticipant::get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, @@ -429,6 +473,22 @@ ReturnCode_t DomainParticipant::get_topic_qos_from_xml( return impl_->get_topic_qos_from_xml(xml, qos, topic_name, topic_data_type, profile_name); } +ReturnCode_t DomainParticipant::get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const +{ + return impl_->get_default_topic_qos_from_xml(xml, qos); +} + +ReturnCode_t DomainParticipant::get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + return impl_->get_default_topic_qos_from_xml(xml, qos, topic_name, topic_data_type); +} + ReturnCode_t DomainParticipant::get_requester_qos_from_profile( const std::string& profile_name, RequesterQos& qos) const @@ -436,6 +496,13 @@ ReturnCode_t DomainParticipant::get_requester_qos_from_profile( return impl_->get_requester_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const +{ + return impl_->get_requester_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos, @@ -444,6 +511,13 @@ ReturnCode_t DomainParticipant::get_requester_qos_from_xml( return impl_->get_requester_qos_from_xml(xml, qos, profile_name); } +ReturnCode_t DomainParticipant::get_default_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const +{ + return impl_->get_default_requester_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_replier_qos_from_profile( const std::string& profile_name, ReplierQos& qos) const @@ -451,6 +525,13 @@ ReturnCode_t DomainParticipant::get_replier_qos_from_profile( return impl_->get_replier_qos_from_profile(profile_name, qos); } +ReturnCode_t DomainParticipant::get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const +{ + return impl_->get_replier_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos, @@ -459,6 +540,13 @@ ReturnCode_t DomainParticipant::get_replier_qos_from_xml( return impl_->get_replier_qos_from_xml(xml, qos, profile_name); } +ReturnCode_t DomainParticipant::get_default_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const +{ + return impl_->get_default_replier_qos_from_xml(xml, qos); +} + ReturnCode_t DomainParticipant::get_discovered_participants( std::vector& participant_handles) const { diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index 50ecdb560fb..ab2a8d53d51 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -341,13 +341,49 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos) const +{ + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, false)) + { + qos = default_participant_qos_; + utils::set_qos_from_attributes(qos, attr.rtps); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantFactory::get_participant_qos_from_xml( const std::string& xml, DomainParticipantQos& qos, const std::string& profile_name) const +{ + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_participant_qos_; + utils::set_qos_from_attributes(qos, attr.rtps); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantFactory::get_default_participant_qos_from_xml( + const std::string& xml, + DomainParticipantQos& qos) const { ParticipantAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_participant_attributes_from_xml(xml, attr, true)) { qos = default_participant_qos_; utils::set_qos_from_attributes(qos, attr.rtps); @@ -372,14 +408,50 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos) const +{ + extended_qos = default_participant_qos_; + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, false)) + { + utils::set_extended_qos_from_attributes(extended_qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos, const std::string& profile_name) const +{ + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + + extended_qos = default_participant_qos_; + ParticipantAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, true, profile_name)) + { + utils::set_extended_qos_from_attributes(extended_qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantFactory::get_default_participant_extended_qos_from_xml( + const std::string& xml, + DomainParticipantExtendedQos& extended_qos) const { extended_qos = default_participant_qos_; ParticipantAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_participant_attributes_from_xml(xml, attr, true)) { utils::set_extended_qos_from_attributes(extended_qos, attr); return RETCODE_OK; diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index dd9a7110cd0..f8dfe28d834 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1044,13 +1044,49 @@ ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, false)) + { + qos = default_pub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos, const std::string& profile_name) const { + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + xmlparser::PublisherAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_pub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantImpl::get_default_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_publisher_attributes_from_xml(xml, attr, true)) { qos = default_pub_qos_; utils::set_qos_from_attributes(qos, attr); @@ -1108,13 +1144,49 @@ ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, false)) + { + qos = default_sub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos, const std::string& profile_name) const { + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + xmlparser::SubscriberAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_sub_qos_; + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantImpl::get_default_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_subscriber_attributes_from_xml(xml, attr, true)) { qos = default_sub_qos_; utils::set_qos_from_attributes(qos, attr); @@ -1161,8 +1233,7 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( const std::string& profile_name, TopicQos& qos) const { - std::string _topic_name; - std::string _topic_data_type; + std::string _topic_name, _topic_data_type; return get_topic_qos_from_profile(profile_name, qos, _topic_name, _topic_data_type); } @@ -1185,13 +1256,39 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const +{ + std::string _topic_name, _topic_data_type; + return get_topic_qos_from_xml(xml, qos, _topic_name, _topic_data_type); +} + +ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + xmlparser::TopicAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_topic_attributes_from_xml(xml, attr, false)) + { + qos = default_topic_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.getTopicName(); + topic_data_type = attr.getTopicDataType(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, const std::string& profile_name) const { - std::string _topic_name; - std::string _topic_data_type; + std::string _topic_name, _topic_data_type; return get_topic_qos_from_xml(xml, qos, _topic_name, _topic_data_type, profile_name); } @@ -1202,8 +1299,41 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_xml( std::string& topic_data_type, const std::string& profile_name) const { + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + xmlparser::TopicAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_topic_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_topic_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_topic_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.getTopicName(); + topic_data_type = attr.getTopicDataType(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantImpl::get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const +{ + std::string _topic_name, _topic_data_type; + return get_default_topic_qos_from_xml(xml, qos, _topic_name, _topic_data_type); +} + +ReturnCode_t DomainParticipantImpl::get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const +{ + xmlparser::TopicAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_topic_attributes_from_xml(xml, attr, true)) { qos = default_topic_qos_; utils::set_qos_from_attributes(qos, attr); @@ -1229,13 +1359,47 @@ ReturnCode_t DomainParticipantImpl::get_replier_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const +{ + xmlparser::ReplierAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_replier_attributes_from_xml(xml, attr, false)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos, const std::string& profile_name) const { + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + xmlparser::ReplierAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_replier_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_replier_attributes_from_xml(xml, attr, true, profile_name)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantImpl::get_default_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const +{ + xmlparser::ReplierAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_replier_attributes_from_xml(xml, attr, true)) { utils::set_qos_from_attributes(qos, attr); return RETCODE_OK; @@ -1258,13 +1422,47 @@ ReturnCode_t DomainParticipantImpl::get_requester_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t DomainParticipantImpl::get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const +{ + xmlparser::RequesterAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_requester_attributes_from_xml(xml, attr, false)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t DomainParticipantImpl::get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos, const std::string& profile_name) const +{ + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(DOMAIN_PARTICIPANT, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + + xmlparser::RequesterAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_requester_attributes_from_xml(xml, attr, true, profile_name)) + { + utils::set_qos_from_attributes(qos, attr); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t DomainParticipantImpl::get_default_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const { xmlparser::RequesterAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_requester_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_requester_attributes_from_xml(xml, attr, true)) { utils::set_qos_from_attributes(qos, attr); return RETCODE_OK; diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp index 1925aff1fff..8f7777fd0ba 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp @@ -375,10 +375,18 @@ class DomainParticipantImpl const std::string& profile_name, PublisherQos& qos) const; + ReturnCode_t get_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const; + ReturnCode_t get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name ) const; + + ReturnCode_t get_default_publisher_qos_from_xml( + const std::string& xml, + PublisherQos& qos) const; ReturnCode_t set_default_subscriber_qos( const SubscriberQos& qos); @@ -391,10 +399,18 @@ class DomainParticipantImpl const std::string& profile_name, SubscriberQos& qos) const; + ReturnCode_t get_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const; + ReturnCode_t get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_subscriber_qos_from_xml( + const std::string& xml, + SubscriberQos& qos) const; ReturnCode_t set_default_topic_qos( const TopicQos& qos); @@ -413,35 +429,71 @@ class DomainParticipantImpl std::string& topic_name, std::string& topic_data_type) const; + ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const; + + ReturnCode_t get_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; + ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos, std::string& topic_name, std::string& topic_data_type, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos) const; + + ReturnCode_t get_default_topic_qos_from_xml( + const std::string& xml, + TopicQos& qos, + std::string& topic_name, + std::string& topic_data_type) const; ReturnCode_t get_replier_qos_from_profile( const std::string& profile_name, ReplierQos& qos) const; + ReturnCode_t get_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const; + ReturnCode_t get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_replier_qos_from_xml( + const std::string& xml, + ReplierQos& qos) const; ReturnCode_t get_requester_qos_from_profile( const std::string& profile_name, RequesterQos& qos) const; + ReturnCode_t get_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const; + ReturnCode_t get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_requester_qos_from_xml( + const std::string& xml, + RequesterQos& qos) const; /* TODO bool get_discovered_participants( diff --git a/src/cpp/fastdds/publisher/Publisher.cpp b/src/cpp/fastdds/publisher/Publisher.cpp index a84d2f0172e..92302869d5a 100644 --- a/src/cpp/fastdds/publisher/Publisher.cpp +++ b/src/cpp/fastdds/publisher/Publisher.cpp @@ -245,6 +245,21 @@ ReturnCode_t Publisher::get_datawriter_qos_from_profile( return impl_->get_datawriter_qos_from_profile(profile_name, qos, topic_name); } +ReturnCode_t Publisher::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const +{ + return impl_->get_datawriter_qos_from_xml(xml, qos); +} + +ReturnCode_t Publisher::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const +{ + return impl_->get_datawriter_qos_from_xml(xml, qos, topic_name); +} + ReturnCode_t Publisher::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, @@ -262,6 +277,21 @@ ReturnCode_t Publisher::get_datawriter_qos_from_xml( return impl_->get_datawriter_qos_from_xml(xml, qos, topic_name, profile_name); } +ReturnCode_t Publisher::get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const +{ + return impl_->get_default_datawriter_qos_from_xml(xml, qos); +} + +ReturnCode_t Publisher::get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const +{ + return impl_->get_default_datawriter_qos_from_xml(xml, qos, topic_name); +} + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/publisher/PublisherImpl.cpp b/src/cpp/fastdds/publisher/PublisherImpl.cpp index b6677f4c198..6a00815c24d 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.cpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.cpp @@ -484,6 +484,31 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const +{ + std::string _topic_name; + return get_datawriter_qos_from_xml(xml, qos, _topic_name); +} + +ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const +{ + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, false)) + { + qos = default_datawriter_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, @@ -498,9 +523,40 @@ ReturnCode_t PublisherImpl::get_datawriter_qos_from_xml( DataWriterQos& qos, std::string& topic_name, const std::string& profile_name) const +{ + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(PUBLISHER, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + + xmlparser::PublisherAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_datawriter_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t PublisherImpl::get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const +{ + std::string _topic_name; + return get_default_datawriter_qos_from_xml(xml, qos, _topic_name); +} + +ReturnCode_t PublisherImpl::get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const { xmlparser::PublisherAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_publisher_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_publisher_attributes_from_xml(xml, attr, true)) { qos = default_datawriter_qos_; utils::set_qos_from_attributes(qos, attr); diff --git a/src/cpp/fastdds/publisher/PublisherImpl.hpp b/src/cpp/fastdds/publisher/PublisherImpl.hpp index f3946ecbfcc..138e909d749 100644 --- a/src/cpp/fastdds/publisher/PublisherImpl.hpp +++ b/src/cpp/fastdds/publisher/PublisherImpl.hpp @@ -174,16 +174,34 @@ class PublisherImpl DataWriterQos& qos, std::string& topic_name) const; + ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const; + + ReturnCode_t get_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const; + ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos, std::string& topic_name, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos) const; + + ReturnCode_t get_default_datawriter_qos_from_xml( + const std::string& xml, + DataWriterQos& qos, + std::string& topic_name) const; ReturnCode_t static copy_from_topic_qos( DataWriterQos& writer_qos, diff --git a/src/cpp/fastdds/subscriber/Subscriber.cpp b/src/cpp/fastdds/subscriber/Subscriber.cpp index 37ff713efe6..b2ceeb8d586 100644 --- a/src/cpp/fastdds/subscriber/Subscriber.cpp +++ b/src/cpp/fastdds/subscriber/Subscriber.cpp @@ -226,6 +226,21 @@ ReturnCode_t Subscriber::get_datareader_qos_from_profile( return impl_->get_datareader_qos_from_profile(profile_name, qos, topic_name); } +ReturnCode_t Subscriber::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const +{ + return impl_->get_datareader_qos_from_xml(xml, qos); +} + +ReturnCode_t Subscriber::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const +{ + return impl_->get_datareader_qos_from_xml(xml, qos, topic_name); +} + ReturnCode_t Subscriber::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, @@ -243,6 +258,21 @@ ReturnCode_t Subscriber::get_datareader_qos_from_xml( return impl_->get_datareader_qos_from_xml(xml, qos, topic_name, profile_name); } +ReturnCode_t Subscriber::get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const +{ + return impl_->get_default_datareader_qos_from_xml(xml, qos); +} + +ReturnCode_t Subscriber::get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const +{ + return impl_->get_default_datareader_qos_from_xml(xml, qos, topic_name); +} + ReturnCode_t Subscriber::copy_from_topic_qos( DataReaderQos& reader_qos, const TopicQos& topic_qos) diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 733f294d51b..304623c1e5b 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -446,6 +446,31 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_profile( return RETCODE_BAD_PARAMETER; } +ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const +{ + std::string _topic_name; + return get_datareader_qos_from_xml(xml, qos, _topic_name); +} + +ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const +{ + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, false)) + { + qos = default_datareader_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, @@ -460,9 +485,40 @@ ReturnCode_t SubscriberImpl::get_datareader_qos_from_xml( DataReaderQos& qos, std::string& topic_name, const std::string& profile_name) const +{ + if (profile_name.empty()) + { + EPROSIMA_LOG_ERROR(SUBSCRIBER, "Provided profile name must be non-empty"); + return RETCODE_BAD_PARAMETER; + } + + xmlparser::SubscriberAttributes attr; + if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, true, profile_name)) + { + qos = default_datareader_qos_; + utils::set_qos_from_attributes(qos, attr); + topic_name = attr.topic.getTopicName(); + return RETCODE_OK; + } + + return RETCODE_BAD_PARAMETER; +} + +ReturnCode_t SubscriberImpl::get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const +{ + std::string _topic_name; + return get_default_datareader_qos_from_xml(xml, qos, _topic_name); +} + +ReturnCode_t SubscriberImpl::get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const { xmlparser::SubscriberAttributes attr; - if (XMLP_ret::XML_OK == XMLProfileManager::fill_subscriber_attributes_from_xml(xml, attr, profile_name)) + if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_subscriber_attributes_from_xml(xml, attr, true)) { qos = default_datareader_qos_; utils::set_qos_from_attributes(qos, attr); diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp index d1d23b62d01..2b1dc582fe7 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.hpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.hpp @@ -152,16 +152,34 @@ class SubscriberImpl DataReaderQos& qos, std::string& topic_name) const; + ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const; + + ReturnCode_t get_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const; + ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, - const std::string& profile_name = "") const; + const std::string& profile_name) const; ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos, std::string& topic_name, - const std::string& profile_name = "") const; + const std::string& profile_name) const; + + ReturnCode_t get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos) const; + + ReturnCode_t get_default_datareader_qos_from_xml( + const std::string& xml, + DataReaderQos& qos, + std::string& topic_name) const; ReturnCode_t static copy_from_topic_qos( DataReaderQos& reader_qos, diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 596f5eefcc7..4854c73e1b4 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -135,7 +135,8 @@ template XMLP_ret fill_attributes_from_xml( const std::string& xml, AttributesType& atts, - const std::string& profile_name) + const std::function::NodePtrType)>& node_filter, + bool fulfill_xsd) { using Traits = AttributesTraits; @@ -149,7 +150,7 @@ XMLP_ret fill_attributes_from_xml( } // Process node function - auto process_node = [](const up_base_node_t& node_to_process, AttributesType& atts, const std::string& profile_name) + auto process_node = [&](const up_base_node_t& node_to_process, AttributesType& atts) { // If node type doesn't match, skip if (Traits::node_type != node_to_process->getType()) @@ -165,15 +166,10 @@ XMLP_ret fill_attributes_from_xml( return XMLP_ret::XML_ERROR; } - // Check profile name, if provided - if (profile_name != "") + // If node doesn't match the filter, skip + if (!node_filter(node)) { - node_att_map_cit_t it = node->getAttributes().find(PROFILE_NAME); - if (it == node->getAttributes().end() || it->second != profile_name) - { - // No profile name in this node, or different than the one requested - return XMLP_ret::XML_NOK; - } + return XMLP_ret::XML_NOK; } // Retrieve node data @@ -190,12 +186,11 @@ XMLP_ret fill_attributes_from_xml( }; // Recursive function to process the root node and its children - std::function process_node_recursive; + std::function process_node_recursive; process_node_recursive = - [&process_node, &process_node_recursive](const up_base_node_t& node_to_process, AttributesType& atts, - const std::string& profile_name) + [&process_node, &process_node_recursive](const up_base_node_t& node_to_process, AttributesType& atts) { - XMLP_ret ret = process_node(node_to_process, atts, profile_name); + XMLP_ret ret = process_node(node_to_process, atts); if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) { return ret; @@ -203,7 +198,7 @@ XMLP_ret fill_attributes_from_xml( for (auto&& child: node_to_process->getChildren()) { - ret = process_node_recursive(child, atts, profile_name); + ret = process_node_recursive(child, atts); if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) { return ret; @@ -212,7 +207,30 @@ XMLP_ret fill_attributes_from_xml( return XMLP_ret::XML_NOK; }; - if (XMLP_ret::XML_OK == process_node_recursive(root_node, atts, profile_name)) + std::reference_wrapper node_to_process = root_node; + if (fulfill_xsd) + { + if (NodeType::ROOT == root_node ->getType()) + { + for (auto&& child: root_node->getChildren()) + { + if (NodeType::PROFILES == child ->getType()) + { + node_to_process = child; + break; + } + } + } + + // Abort if profiles tag is not found according to XSD + if (NodeType::PROFILES != node_to_process.get()->getType()) + { + EPROSIMA_LOG_ERROR(XMLPARSER, "Provided XML literal does not contain profiles"); + return XMLP_ret::XML_ERROR; + } + } + + if (XMLP_ret::XML_OK == process_node_recursive(node_to_process, atts)) { return XMLP_ret::XML_OK; } @@ -221,6 +239,37 @@ XMLP_ret fill_attributes_from_xml( return XMLP_ret::XML_ERROR; } +template +XMLP_ret fill_attributes_from_xml( + const std::string& xml, + AttributesType& atts, + bool fulfill_xsd, + const std::string& profile_name) +{ + auto node_filter = [&profile_name](typename AttributesTraits::NodePtrType node) -> bool { + if (!profile_name.empty()) + { + auto it = node->getAttributes().find(PROFILE_NAME); + return (it != node->getAttributes().end() && it->second == profile_name); + } + return true; + }; + return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); +} + +template +XMLP_ret fill_default_attributes_from_xml( + const std::string& xml, + AttributesType& atts, + bool fulfill_xsd) +{ + auto node_filter = [](typename AttributesTraits::NodePtrType node) -> bool { + auto it = node->getAttributes().find(DEFAULT_PROF); + return (it != node->getAttributes().end() && it->second == "true"); + }; + return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); +} + XMLP_ret XMLProfileManager::fillParticipantAttributes( const std::string& profile_name, ParticipantAttributes& atts, @@ -242,9 +291,18 @@ XMLP_ret XMLProfileManager::fillParticipantAttributes( XMLP_ret XMLProfileManager::fill_participant_attributes_from_xml( const std::string& xml, ParticipantAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_participant_attributes_from_xml( + const std::string& xml, + ParticipantAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } XMLP_ret XMLProfileManager::fillPublisherAttributes( @@ -268,9 +326,18 @@ XMLP_ret XMLProfileManager::fillPublisherAttributes( XMLP_ret XMLProfileManager::fill_publisher_attributes_from_xml( const std::string& xml, PublisherAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_publisher_attributes_from_xml( + const std::string& xml, + PublisherAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } XMLP_ret XMLProfileManager::fillSubscriberAttributes( @@ -294,9 +361,18 @@ XMLP_ret XMLProfileManager::fillSubscriberAttributes( XMLP_ret XMLProfileManager::fill_subscriber_attributes_from_xml( const std::string& xml, SubscriberAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_subscriber_attributes_from_xml( + const std::string& xml, + SubscriberAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } XMLP_ret XMLProfileManager::fillTopicAttributes( @@ -316,9 +392,18 @@ XMLP_ret XMLProfileManager::fillTopicAttributes( XMLP_ret XMLProfileManager::fill_topic_attributes_from_xml( const std::string& xml, TopicAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_topic_attributes_from_xml( + const std::string& xml, + TopicAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } XMLP_ret XMLProfileManager::fillRequesterAttributes( @@ -338,9 +423,18 @@ XMLP_ret XMLProfileManager::fillRequesterAttributes( XMLP_ret XMLProfileManager::fill_requester_attributes_from_xml( const std::string& xml, RequesterAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_requester_attributes_from_xml( + const std::string& xml, + RequesterAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } XMLP_ret XMLProfileManager::fillReplierAttributes( @@ -360,9 +454,18 @@ XMLP_ret XMLProfileManager::fillReplierAttributes( XMLP_ret XMLProfileManager::fill_replier_attributes_from_xml( const std::string& xml, ReplierAttributes& atts, + bool fulfill_xsd, const std::string& profile_name) { - return fill_attributes_from_xml(xml, atts, profile_name); + return fill_attributes_from_xml(xml, atts, fulfill_xsd, profile_name); +} + +XMLP_ret XMLProfileManager::fill_default_replier_attributes_from_xml( + const std::string& xml, + ReplierAttributes& atts, + bool fulfill_xsd) +{ + return fill_default_attributes_from_xml(xml, atts, fulfill_xsd); } void XMLProfileManager::getDefaultParticipantAttributes( diff --git a/src/cpp/xmlparser/XMLProfileManager.h b/src/cpp/xmlparser/XMLProfileManager.h index 0e44d876c76..64a5ecafc7e 100644 --- a/src/cpp/xmlparser/XMLProfileManager.h +++ b/src/cpp/xmlparser/XMLProfileManager.h @@ -149,17 +149,31 @@ class XMLProfileManager bool log_error = true); /** - * Search for the first participant profile found in the given XML (or the one specified) and fill the structure. + * Search for the first participant profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_participant_attributes_from_xml( const std::string& xml, fastdds::xmlparser::ParticipantAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default participant profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_participant_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::ParticipantAttributes& atts, + bool fulfill_xsd); + //!Fills participant_attributes with the default values. static void getDefaultParticipantAttributes( fastdds::xmlparser::ParticipantAttributes& participant_attributes); @@ -196,17 +210,31 @@ class XMLProfileManager bool log_error = true); /** - * Search for the first publisher profile found in the given XML (or the one specified) and fill the structure. + * Search for the first publisher profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_publisher_attributes_from_xml( const std::string& xml, fastdds::xmlparser::PublisherAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default publisher profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_publisher_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::PublisherAttributes& atts, + bool fulfill_xsd); + //!Fills publisher_attributes with the default values. static void getDefaultPublisherAttributes( fastdds::xmlparser::PublisherAttributes& publisher_attributes); @@ -224,17 +252,31 @@ class XMLProfileManager bool log_error = true); /** - * Search for the first subscriber profile found in the given XML (or the one specified) and fill the structure. + * Search for the first subscriber profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_subscriber_attributes_from_xml( const std::string& xml, fastdds::xmlparser::SubscriberAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default subscriber profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_subscriber_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::SubscriberAttributes& atts, + bool fulfill_xsd); + //!Fills subscriber_attributes with the default values. static void getDefaultSubscriberAttributes( fastdds::xmlparser::SubscriberAttributes& subscriber_attributes); @@ -259,17 +301,31 @@ class XMLProfileManager TopicAttributes& atts); /** - * Search for the first topic profile found in the given XML (or the one specified) and fill the structure. + * Search for the first topic profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_topic_attributes_from_xml( const std::string& xml, fastdds::xmlparser::TopicAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default topic profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_topic_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::TopicAttributes& atts, + bool fulfill_xsd); + //!Fills topic_attributes with the default values. static void getDefaultTopicAttributes( TopicAttributes& topic_attributes); @@ -294,17 +350,31 @@ class XMLProfileManager fastdds::xmlparser::RequesterAttributes& atts); /** - * Search for the first requester profile found in the given XML (or the one specified) and fill the structure. + * Search for the first requester profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_requester_attributes_from_xml( const std::string& xml, fastdds::xmlparser::RequesterAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default requester profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_requester_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::RequesterAttributes& atts, + bool fulfill_xsd); + /** * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. @@ -316,17 +386,31 @@ class XMLProfileManager fastdds::xmlparser::ReplierAttributes& atts); /** - * Search for the first replier profile found in the given XML (or the one specified) and fill the structure. + * Search for the first replier profile found in the provided XML (or the one specified) and fill the structure. * @param xml Raw XML string containing the profile to be used to fill the structure. * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. * @param profile_name Name for the profile to be used to fill the structure. Empty by default (first one found). * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fill_replier_attributes_from_xml( const std::string& xml, fastdds::xmlparser::ReplierAttributes& atts, + bool fulfill_xsd, const std::string& profile_name = ""); + /** + * Search for the default replier profile found in the provided XML (if there is) and fill the structure. + * @param xml Raw XML string containing the profile to be used to fill the structure. + * @param atts Structure to be filled. + * @param fulfill_xsd Whether the given \c xml should fulfill the XSD schema. + * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. + */ + static XMLP_ret fill_default_replier_attributes_from_xml( + const std::string& xml, + fastdds::xmlparser::ReplierAttributes& atts, + bool fulfill_xsd); + /** * Deletes the XMLProfileManager instance. * FastDDS's Domain calls this method automatically on its destructor, but diff --git a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp index 6bc4bd99ae7..b210c2359b6 100644 --- a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp +++ b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp @@ -479,6 +479,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_publisher_qos_from_xml( + const std::string& /*xml*/, + PublisherQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_publisher_qos_from_xml( const std::string& /*xml*/, PublisherQos& /*qos*/, @@ -487,6 +494,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_default_publisher_qos_from_xml( + const std::string& /*xml*/, + PublisherQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t set_default_subscriber_qos( const SubscriberQos& /*qos*/) { @@ -505,6 +519,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_subscriber_qos_from_xml( + const std::string& /*xml*/, + SubscriberQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_subscriber_qos_from_xml( const std::string& /*xml*/, SubscriberQos& /*qos*/, @@ -513,6 +534,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_default_subscriber_qos_from_xml( + const std::string& /*xml*/, + SubscriberQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t set_default_topic_qos( const TopicQos& /*qos*/) { @@ -540,6 +568,22 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/) const + { + return RETCODE_OK; + } + + ReturnCode_t get_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/, + std::string& /*topic_name*/, + std::string& /*topic_data_type*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_topic_qos_from_xml( const std::string& /*xml*/, TopicQos& /*qos*/, @@ -558,6 +602,22 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_default_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/) const + { + return RETCODE_OK; + } + + ReturnCode_t get_default_topic_qos_from_xml( + const std::string& /*xml*/, + TopicQos& /*qos*/, + std::string& /*topic_name*/, + std::string& /*topic_data_type*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_replier_qos_from_profile( const std::string& /*profile_name*/, ReplierQos& /*qos*/) const @@ -565,6 +625,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_replier_qos_from_xml( + const std::string& /*xml*/, + ReplierQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_replier_qos_from_xml( const std::string& /*xml*/, ReplierQos& /*qos*/, @@ -573,6 +640,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_default_replier_qos_from_xml( + const std::string& /*xml*/, + ReplierQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_requester_qos_from_profile( const std::string& /*profile_name*/, RequesterQos& /*qos*/) const @@ -580,6 +654,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_requester_qos_from_xml( + const std::string& /*xml*/, + RequesterQos& /*qos*/) const + { + return RETCODE_OK; + } + ReturnCode_t get_requester_qos_from_xml( const std::string& /*xml*/, RequesterQos& /*qos*/, @@ -588,6 +669,13 @@ class DomainParticipantImpl return RETCODE_OK; } + ReturnCode_t get_default_requester_qos_from_xml( + const std::string& /*xml*/, + RequesterQos& /*qos*/) const + { + return RETCODE_OK; + } + bool contains_entity( const InstanceHandle_t& /*handle*/, bool /*recursive*/) const diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index bf8664fb949..a4028aff6dd 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -767,10 +767,10 @@ TEST(ParticipantTests, GetParticipantQosFromXml) DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) DomainParticipantQos qos_empty_profile; EXPECT_EQ( - DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos_empty_profile, ""), + DomainParticipantFactory::get_instance()->get_participant_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile @@ -808,12 +808,10 @@ TEST(ParticipantTests, GetParticipantExtendedQosFromXml) profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) DomainParticipantExtendedQos qos_empty_profile; EXPECT_EQ( - DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos_empty_profile, - ""), - RETCODE_OK); + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file @@ -2094,10 +2092,10 @@ TEST(ParticipantTests, GetSubscriberQosFromXml) participant->get_subscriber_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) SubscriberQos qos_empty_profile; EXPECT_EQ( - participant->get_subscriber_qos_from_xml(complete_xml, qos_empty_profile, ""), + participant->get_subscriber_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile @@ -2192,10 +2190,10 @@ TEST(ParticipantTests, GetPublisherQosFromXml) participant->get_publisher_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) PublisherQos qos_empty_profile; EXPECT_EQ( - participant->get_publisher_qos_from_xml(complete_xml, qos_empty_profile, ""), + participant->get_publisher_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile @@ -2262,10 +2260,10 @@ TEST(ParticipantTests, GetReplierQosFromXml) participant->get_replier_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) ReplierQos qos_empty_profile; EXPECT_EQ( - participant->get_replier_qos_from_xml(complete_xml, qos_empty_profile, ""), + participant->get_replier_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile @@ -2332,10 +2330,10 @@ TEST(ParticipantTests, GetRequesterQosFromXml) participant->get_requester_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) RequesterQos qos_empty_profile; EXPECT_EQ( - participant->get_requester_qos_from_xml(complete_xml, qos_empty_profile, ""), + participant->get_requester_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile @@ -2505,10 +2503,10 @@ TEST(ParticipantTests, GetTopicQosFromXml) participant->get_topic_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) TopicQos qos_empty_profile; EXPECT_EQ( - participant->get_topic_qos_from_xml(complete_xml, qos_empty_profile, ""), + participant->get_topic_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile diff --git a/test/unittest/dds/publisher/PublisherTests.cpp b/test/unittest/dds/publisher/PublisherTests.cpp index a24cee069ce..6cf863fb1ff 100644 --- a/test/unittest/dds/publisher/PublisherTests.cpp +++ b/test/unittest/dds/publisher/PublisherTests.cpp @@ -590,10 +590,10 @@ TEST(PublisherTests, GetDataWriterQosFromXml) publisher->get_datawriter_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) DataWriterQos qos_empty_profile; EXPECT_EQ( - publisher->get_datawriter_qos_from_xml(complete_xml, qos_empty_profile, ""), + publisher->get_datawriter_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index d4c3456dcd3..b3e67e492fb 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -614,10 +614,10 @@ TEST(SubscriberTests, GetDataReaderQosFromXml) subscriber->get_datareader_qos_from_xml(complete_xml, qos, profile_name), RETCODE_OK); - // Get QoS given profile name with empty profile name (gets first one found) + // Get QoS without providing profile name (gets first one found) DataReaderQos qos_empty_profile; EXPECT_EQ( - subscriber->get_datareader_qos_from_xml(complete_xml, qos_empty_profile, ""), + subscriber->get_datareader_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile From dd0aced4911f60942e663c8d88b11f9be316e3c9 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 8 Oct 2024 12:21:42 +0200 Subject: [PATCH 14/18] Refs #21745. Add a clarifying docstring note to get_default methods Signed-off-by: Juan Lopez Fernandez --- include/fastdds/dds/domain/DomainParticipant.hpp | 12 ++++++++++++ .../fastdds/dds/domain/DomainParticipantFactory.hpp | 4 ++++ include/fastdds/dds/publisher/Publisher.hpp | 4 ++++ include/fastdds/dds/subscriber/Subscriber.hpp | 4 ++++ 4 files changed, 24 insertions(+) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index 726606a585c..3da698b92e9 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -574,6 +574,8 @@ class DomainParticipant : public Entity /** * Fills the PublisherQos with the default publisher profile found in the provided XML (if there is). * + * @note This method does not update the default publisher qos (returned by \c get_default_publisher_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos PublisherQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -663,6 +665,8 @@ class DomainParticipant : public Entity /** * Fills the SubscriberQos with the default subscriber profile found in the provided XML (if there is). * + * @note This method does not update the default subscriber qos (returned by \c get_default_subscriber_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos SubscriberQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -799,6 +803,8 @@ class DomainParticipant : public Entity /** * Fills the TopicQos with the default topic profile found in the provided XML (if there is). * + * @note This method does not update the default topic qos (returned by \c get_default_topic_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos TopicQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -810,6 +816,8 @@ class DomainParticipant : public Entity /** * Fills the TopicQos with the default topic profile found in the provided XML (if there is), and also its corresponding topic and data type names (if specified). * + * @note This method does not update the default topic qos (returned by \c get_default_topic_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). @@ -860,6 +868,8 @@ class DomainParticipant : public Entity /** * Fills the ReplierQos with the default replier profile found in the provided XML (if there is). * + * @note This method does not update the default replier qos. + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos ReplierQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -906,6 +916,8 @@ class DomainParticipant : public Entity /** * Fills the RequesterQos with the default requester profile found in the provided XML (if there is). * + * @note This method does not update the default requester qos. + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos RequesterQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index bd7ae5a639f..d763c2ee274 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -256,6 +256,8 @@ class DomainParticipantFactory /** * Fills the DomainParticipantQos with the default DomainParticipant profile found in the provided XML (if there is). * + * @note This method does not update the default participant qos (returned by \c get_default_participant_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DomainParticipantQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -302,6 +304,8 @@ class DomainParticipantFactory /** * Fills the DomainParticipantExtendedQos with the default DomainParticipant profile found in the provided XML (if there is). * + * @note This method does not update the default participant extended qos. + * * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. * @param qos DomainParticipantExtendedQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index 50b3e84f14e..90fdb93a8c7 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -410,6 +410,8 @@ class Publisher : public DomainEntity /** * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is). * + * @note This method does not update the default datawriter qos (returned by \c get_default_datawriter_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataWriterQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -421,6 +423,8 @@ class Publisher : public DomainEntity /** * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is), and also its corresponding topic name (if specified). * + * @note This method does not update the default datawriter qos (returned by \c get_default_datawriter_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 1c6b594acd8..d37a4427854 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -423,6 +423,8 @@ class Subscriber : public DomainEntity /** * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is). * + * @note This method does not update the default datareader qos (returned by \c get_default_datareader_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataReaderQos object where the qos is returned. * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. @@ -434,6 +436,8 @@ class Subscriber : public DomainEntity /** * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is), and also its corresponding topic name (if specified). * + * @note This method does not update the default datareader qos (returned by \c get_default_datareader_qos). + * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. * @param qos DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). From 657445657ae31ac9c0789fcb25ab5ca2a9bf3989 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 8 Oct 2024 12:22:06 +0200 Subject: [PATCH 15/18] Refs #21745. Add unittests for new get_default methods Signed-off-by: Juan Lopez Fernandez --- .../dds/participant/ParticipantTests.cpp | 192 ++++++++++++++++++ .../dds/profiles/test_xml_profile.xml | 8 +- .../unittest/dds/publisher/PublisherTests.cpp | 36 ++++ .../dds/subscriber/SubscriberTests.cpp | 36 ++++ 4 files changed, 269 insertions(+), 3 deletions(-) diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index a4028aff6dd..ec13cab627e 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -794,6 +794,32 @@ TEST(ParticipantTests, GetParticipantQosFromXml) RETCODE_BAD_PARAMETER); } +TEST(ParticipantTests, GetDefaultParticipantQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + // Get default QoS from XML + DomainParticipantQos default_qos; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_default_participant_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + DomainParticipantFactory::get_instance()->set_default_participant_qos(PARTICIPANT_QOS_DEFAULT); + DomainParticipantQos default_qos_from_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_default_participant_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); +} + TEST(ParticipantTests, GetParticipantExtendedQosFromXml) { const std::string xml_filename("test_xml_profile.xml"); @@ -835,6 +861,22 @@ TEST(ParticipantTests, GetParticipantExtendedQosFromXml) RETCODE_BAD_PARAMETER); } +TEST(ParticipantTests, GetDefaultParticipantExtendedQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + // Get default QoS from XML + DomainParticipantExtendedQos default_qos; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_default_participant_extended_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // NOTE: cannot load profiles file and compare with default value as + // DomainParticipantFactory::get_default_participant_extended_qos is currently unavailable +} + TEST(ParticipantTests, DeleteDomainParticipant) { DomainParticipant* participant = @@ -2121,6 +2163,40 @@ TEST(ParticipantTests, GetSubscriberQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetDefaultSubscriberQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get default QoS from XML + SubscriberQos default_qos; + EXPECT_EQ( + participant->get_default_subscriber_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + participant->set_default_subscriber_qos(SUBSCRIBER_QOS_DEFAULT); + SubscriberQos default_qos_from_profile; + EXPECT_EQ( + participant->get_default_subscriber_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, CreateSubscriberWithProfile) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2219,6 +2295,40 @@ TEST(ParticipantTests, GetPublisherQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetDefaultPublisherQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get default QoS from XML + PublisherQos default_qos; + EXPECT_EQ( + participant->get_default_publisher_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + participant->set_default_publisher_qos(PUBLISHER_QOS_DEFAULT); + PublisherQos default_qos_from_profile; + EXPECT_EQ( + participant->get_default_publisher_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, GetReplierProfileQos) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2289,6 +2399,30 @@ TEST(ParticipantTests, GetReplierQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetDefaultReplierQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get default QoS from XML + ReplierQos default_qos; + EXPECT_EQ( + participant->get_default_replier_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // NOTE: cannot load profiles file and compare with default value as + // DomainParticipant::get_default_replier_qos is currently unavailable + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, GetRequesterProfileQos) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); @@ -2359,6 +2493,30 @@ TEST(ParticipantTests, GetRequesterQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetDefaultRequesterQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get default QoS from XML + RequesterQos default_qos; + EXPECT_EQ( + participant->get_default_requester_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // NOTE: cannot load profiles file and compare with default value as + // DomainParticipant::get_default_requester_qos is currently unavailable + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, DeletePublisher) { DomainParticipant* participant = @@ -2532,6 +2690,40 @@ TEST(ParticipantTests, GetTopicQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(ParticipantTests, GetDefaultTopicQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + + // Get default QoS from XML + TopicQos default_qos; + EXPECT_EQ( + participant->get_default_topic_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + participant->set_default_topic_qos(TOPIC_QOS_DEFAULT); + TopicQos default_qos_from_profile; + EXPECT_EQ( + participant->get_default_topic_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); + + // Clean up + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(ParticipantTests, CreateTopic) { DomainParticipantFactory::get_instance()->load_XML_profiles_file("test_xml_profile.xml"); diff --git a/test/unittest/dds/profiles/test_xml_profile.xml b/test/unittest/dds/profiles/test_xml_profile.xml index a30d84ab1b0..483b2bf090e 100644 --- a/test/unittest/dds/profiles/test_xml_profile.xml +++ b/test/unittest/dds/profiles/test_xml_profile.xml @@ -730,7 +730,7 @@ - + KEEP_LAST 20 @@ -746,7 +746,8 @@ + reply_type="reply_type" + is_default_profile="true"> request_topic_name reply_topic_name @@ -768,7 +769,8 @@ + reply_type="reply_type" + is_default_profile="true"> request_topic_name reply_topic_name diff --git a/test/unittest/dds/publisher/PublisherTests.cpp b/test/unittest/dds/publisher/PublisherTests.cpp index 6cf863fb1ff..dcb449ad3c9 100644 --- a/test/unittest/dds/publisher/PublisherTests.cpp +++ b/test/unittest/dds/publisher/PublisherTests.cpp @@ -620,6 +620,42 @@ TEST(PublisherTests, GetDataWriterQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(PublisherTests, GetDefaultDataWriterQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); + ASSERT_NE(publisher, nullptr); + + // Get default QoS from XML + DataWriterQos default_qos; + EXPECT_EQ( + publisher->get_default_datawriter_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + publisher->set_default_datawriter_qos(DATAWRITER_QOS_DEFAULT); + DataWriterQos default_qos_from_profile; + EXPECT_EQ( + publisher->get_default_datawriter_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); + + // Clean up + ASSERT_EQ(participant->delete_publisher(publisher), RETCODE_OK); + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(PublisherTests, DeletePublisherWithWriters) { DomainParticipant* participant = diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index b3e67e492fb..178913383d5 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -644,6 +644,42 @@ TEST(SubscriberTests, GetDataReaderQosFromXml) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +TEST(PublisherTests, GetDefaultDataReaderQosFromXml) +{ + const std::string xml_filename("test_xml_profile.xml"); + + std::string complete_xml = testing::load_file(xml_filename); + + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); + ASSERT_NE(participant, nullptr); + Subscriber* subscriber = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT); + ASSERT_NE(subscriber, nullptr); + + // Get default QoS from XML + DataReaderQos default_qos; + EXPECT_EQ( + subscriber->get_default_datareader_qos_from_xml(complete_xml, default_qos), + RETCODE_OK); + + // Load profiles from XML file and get default QoS after resetting its value + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + // NOTE: At the time of this writing, the only way to reset the default qos after loading an XML is to do as follows + DomainParticipantFactory::get_instance()->load_profiles(); + subscriber->set_default_datareader_qos(DATAREADER_QOS_DEFAULT); + DataReaderQos default_qos_from_profile; + EXPECT_EQ( + subscriber->get_default_datareader_qos(default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); + + // Clean up + ASSERT_EQ(participant->delete_subscriber(subscriber), RETCODE_OK); + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + TEST(SubscriberTests, DeleteSubscriberWithReaders) { DomainParticipant* participant = From f6fe520db919ff98884123d2225b584a631b4806 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Tue, 8 Oct 2024 12:58:33 +0200 Subject: [PATCH 16/18] Refs #21745. Apply suggestions Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 132 +++++++++--------- .../dds/domain/DomainParticipantFactory.hpp | 46 +++--- include/fastdds/dds/publisher/Publisher.hpp | 44 +++--- include/fastdds/dds/subscriber/Subscriber.hpp | 44 +++--- .../domain/DomainParticipantFactory.cpp | 8 +- src/cpp/xmlparser/XMLProfileManager.h | 8 +- 6 files changed, 141 insertions(+), 141 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index 3da698b92e9..ae77c779a2c 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -537,10 +537,10 @@ class DomainParticipant : public Entity PublisherQos& qos) const; /** - * Fills the PublisherQos with the values of the XML profile. + * Fills the @ref PublisherQos with the values of the XML profile. * * @param profile_name Publisher profile name. - * @param qos PublisherQos object where the qos is returned. + * @param qos @ref PublisherQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_profile( @@ -548,23 +548,23 @@ class DomainParticipant : public Entity PublisherQos& qos) const; /** - * Fills the PublisherQos with the first publisher profile found in the provided XML. + * Fills the @ref PublisherQos with the first publisher profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos PublisherQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref PublisherQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( const std::string& xml, PublisherQos& qos) const; /** - * Fills the PublisherQos with the publisher profile with \c profile_name to be found in the provided XML. + * Fills the @ref PublisherQos with the publisher profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos PublisherQos object where the qos is returned. + * @param qos @ref PublisherQos object where the qos is returned. * @param profile_name Publisher profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_xml( const std::string& xml, @@ -572,13 +572,13 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the PublisherQos with the default publisher profile found in the provided XML (if there is). + * Fills the @ref PublisherQos with the default publisher profile found in the provided XML (if there is). * * @note This method does not update the default publisher qos (returned by \c get_default_publisher_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos PublisherQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref PublisherQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_publisher_qos_from_xml( const std::string& xml, @@ -628,10 +628,10 @@ class DomainParticipant : public Entity SubscriberQos& qos) const; /** - * Fills the SubscriberQos with the values of the XML profile. + * Fills the @ref SubscriberQos with the values of the XML profile. * * @param profile_name Subscriber profile name. - * @param qos SubscriberQos object where the qos is returned. + * @param qos @ref SubscriberQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_profile( @@ -639,23 +639,23 @@ class DomainParticipant : public Entity SubscriberQos& qos) const; /** - * Fills the SubscriberQos with the first subscriber profile found in the provided XML. + * Fills the @ref SubscriberQos with the first subscriber profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos SubscriberQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref SubscriberQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( const std::string& xml, SubscriberQos& qos) const; /** - * Fills the SubscriberQos with the subscriber profile with \c profile_name to be found in the provided XML. + * Fills the @ref SubscriberQos with the subscriber profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos SubscriberQos object where the qos is returned. + * @param qos @ref SubscriberQos object where the qos is returned. * @param profile_name Subscriber profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_xml( const std::string& xml, @@ -663,13 +663,13 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the SubscriberQos with the default subscriber profile found in the provided XML (if there is). + * Fills the @ref SubscriberQos with the default subscriber profile found in the provided XML (if there is). * * @note This method does not update the default subscriber qos (returned by \c get_default_subscriber_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos SubscriberQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref SubscriberQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_subscriber_qos_from_xml( const std::string& xml, @@ -719,10 +719,10 @@ class DomainParticipant : public Entity TopicQos& qos) const; /** - * Fills the TopicQos with the values of the XML profile. + * Fills the @ref TopicQos with the values of the XML profile. * * @param profile_name Topic profile name. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_profile( @@ -730,10 +730,10 @@ class DomainParticipant : public Entity TopicQos& qos) const; /** - * Fills the TopicQos with the values of the XML profile, and also its corresponding topic and data type names (if specified). + * Fills the @ref TopicQos with the values of the XML profile, and also its corresponding topic and data type names (if specified). * * @param profile_name Topic profile name. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. @@ -745,24 +745,24 @@ class DomainParticipant : public Entity std::string& topic_data_type) const; /** - * Fills the TopicQos with the first topic profile found in the provided XML. + * Fills the @ref TopicQos with the first topic profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref TopicQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, TopicQos& qos) const; /** - * Fills the TopicQos with the first topic profile found in the provided XML, and also its corresponding topic and data type names (if specified). + * Fills the @ref TopicQos with the first topic profile found in the provided XML, and also its corresponding topic and data type names (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, @@ -771,12 +771,12 @@ class DomainParticipant : public Entity std::string& topic_data_type) const; /** - * Fills the TopicQos with the topic profile with \c profile_name to be found in the provided XML. + * Fills the @ref TopicQos with the topic profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @param profile_name Topic profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, @@ -784,14 +784,14 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the TopicQos with the topic profile with \c profile_name to be found in the provided XML, and also its corresponding topic and data type names (if specified). + * Fills the @ref TopicQos with the topic profile with \c profile_name to be found in the provided XML, and also its corresponding topic and data type names (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). * @param profile_name Topic profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_xml( const std::string& xml, @@ -801,28 +801,28 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the TopicQos with the default topic profile found in the provided XML (if there is). + * Fills the @ref TopicQos with the default topic profile found in the provided XML (if there is). * * @note This method does not update the default topic qos (returned by \c get_default_topic_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref TopicQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_topic_qos_from_xml( const std::string& xml, TopicQos& qos) const; /** - * Fills the TopicQos with the default topic profile found in the provided XML (if there is), and also its corresponding topic and data type names (if specified). + * Fills the @ref TopicQos with the default topic profile found in the provided XML (if there is), and also its corresponding topic and data type names (if specified). * * @note This method does not update the default topic qos (returned by \c get_default_topic_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos TopicQos object where the qos is returned. + * @param qos @ref TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_topic_qos_from_xml( const std::string& xml, @@ -831,10 +831,10 @@ class DomainParticipant : public Entity std::string& topic_data_type) const; /** - * Fills the ReplierQos with the values of the XML profile. + * Fills the @ref ReplierQos with the values of the XML profile. * * @param profile_name Replier profile name. - * @param qos ReplierQos object where the qos is returned. + * @param qos @ref ReplierQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_profile( @@ -842,23 +842,23 @@ class DomainParticipant : public Entity ReplierQos& qos) const; /** - * Fills the ReplierQos with the first replier profile found in the provided XML. + * Fills the @ref ReplierQos with the first replier profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos ReplierQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref ReplierQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( const std::string& xml, ReplierQos& qos) const; /** - * Fills the ReplierQos with the replier profile with \c profile_name to be found in the provided XML. + * Fills the @ref ReplierQos with the replier profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos ReplierQos object where the qos is returned. + * @param qos @ref ReplierQos object where the qos is returned. * @param profile_name Replier profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_xml( const std::string& xml, @@ -866,23 +866,23 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the ReplierQos with the default replier profile found in the provided XML (if there is). + * Fills the @ref ReplierQos with the default replier profile found in the provided XML (if there is). * * @note This method does not update the default replier qos. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos ReplierQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref ReplierQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_replier_qos_from_xml( const std::string& xml, ReplierQos& qos) const; /** - * Fills the RequesterQos with the values of the XML profile. + * Fills the @ref RequesterQos with the values of the XML profile. * * @param profile_name Requester profile name. - * @param qos RequesterQos object where the qos is returned. + * @param qos @ref RequesterQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_profile( @@ -890,23 +890,23 @@ class DomainParticipant : public Entity RequesterQos& qos) const; /** - * Fills the RequesterQos with the first requester profile found in the provided XML. + * Fills the @ref RequesterQos with the first requester profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos RequesterQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref RequesterQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( const std::string& xml, RequesterQos& qos) const; /** - * Fills the RequesterQos with the requester profile with \c profile_name to be found in the provided XML. + * Fills the @ref RequesterQos with the requester profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos RequesterQos object where the qos is returned. + * @param qos @ref RequesterQos object where the qos is returned. * @param profile_name Requester profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_xml( const std::string& xml, @@ -914,13 +914,13 @@ class DomainParticipant : public Entity const std::string& profile_name) const; /** - * Fills the RequesterQos with the default requester profile found in the provided XML (if there is). + * Fills the @ref RequesterQos with the default requester profile found in the provided XML (if there is). * * @note This method does not update the default requester qos. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos RequesterQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref RequesterQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_requester_qos_from_xml( const std::string& xml, diff --git a/include/fastdds/dds/domain/DomainParticipantFactory.hpp b/include/fastdds/dds/domain/DomainParticipantFactory.hpp index d763c2ee274..16512d0ddec 100644 --- a/include/fastdds/dds/domain/DomainParticipantFactory.hpp +++ b/include/fastdds/dds/domain/DomainParticipantFactory.hpp @@ -219,10 +219,10 @@ class DomainParticipantFactory const DomainParticipantQos& qos); /** - * Fills the DomainParticipantQos with the values of the XML profile. + * Fills the @ref DomainParticipantQos with the values of the XML profile. * * @param profile_name DomainParticipant profile name. - * @param qos DomainParticipantQos object where the qos is returned. + * @param qos @ref DomainParticipantQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_profile( @@ -230,23 +230,23 @@ class DomainParticipantFactory DomainParticipantQos& qos) const; /** - * Fills the DomainParticipantQos with the first DomainParticipant profile found in the provided XML. + * Fills the @ref DomainParticipantQos with the first DomainParticipant profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DomainParticipantQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DomainParticipantQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( const std::string& xml, DomainParticipantQos& qos) const; /** - * Fills the DomainParticipantQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. + * Fills the @ref DomainParticipantQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DomainParticipantQos object where the qos is returned. + * @param qos @ref DomainParticipantQos object where the qos is returned. * @param profile_name DomainParticipant profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml( const std::string& xml, @@ -254,20 +254,20 @@ class DomainParticipantFactory const std::string& profile_name) const; /** - * Fills the DomainParticipantQos with the default DomainParticipant profile found in the provided XML (if there is). + * Fills the @ref DomainParticipantQos with the default DomainParticipant profile found in the provided XML (if there is). * * @note This method does not update the default participant qos (returned by \c get_default_participant_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DomainParticipantQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DomainParticipantQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_qos_from_xml( const std::string& xml, DomainParticipantQos& qos) const; /** - * Fills the DomainParticipantExtendedQos with the values of the XML profile. + * Fills the @ref DomainParticipantExtendedQos with the values of the XML profile. * * @param profile_name DomainParticipant profile name. * @param extended_qos DomainParticipantExtendedQos object where the domain and qos are returned. @@ -278,23 +278,23 @@ class DomainParticipantFactory DomainParticipantExtendedQos& extended_qos) const; /** - * Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the provided XML. + * Fills the @ref DomainParticipantExtendedQos with the first DomainParticipant profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. - * @param extended_qos DomainParticipantExtendedQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param extended_qos @ref DomainParticipantExtendedQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos) const; /** - * Fills the DomainParticipantExtendedQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. + * Fills the @ref DomainParticipantExtendedQos with the DomainParticipant profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. - * @param extended_qos DomainParticipantExtendedQos object where the qos is returned. + * @param extended_qos @ref DomainParticipantExtendedQos object where the qos is returned. * @param profile_name DomainParticipant profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml( const std::string& xml, @@ -302,22 +302,22 @@ class DomainParticipantFactory const std::string& profile_name) const; /** - * Fills the DomainParticipantExtendedQos with the default DomainParticipant profile found in the provided XML (if there is). + * Fills the @ref DomainParticipantExtendedQos with the default DomainParticipant profile found in the provided XML (if there is). * * @note This method does not update the default participant extended qos. * * @param xml Raw XML string containing the profile to be used to fill the \c extended_qos structure. - * @param qos DomainParticipantExtendedQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param extended_qos @ref DomainParticipantExtendedQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos) const; /** - * Fills the DomainParticipantExtendedQos with the values of the default XML profile. + * Fills the @ref DomainParticipantExtendedQos with the values of the default XML profile. * - * @param extended_qos DomainParticipantExtendedQos object where the domain and qos are returned. + * @param extended_qos @ref DomainParticipantExtendedQos object where the domain and qos are returned. * @return RETCODE_OK */ FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_default_profile( diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index 90fdb93a8c7..a144f8ab0dd 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -332,10 +332,10 @@ class Publisher : public DomainEntity const fastdds::dds::TopicQos& topic_qos); /** - * Fills the DataWriterQos with the values of the XML profile. + * Fills the @ref DataWriterQos with the values of the XML profile. * * @param profile_name DataWriter profile name. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile( @@ -343,10 +343,10 @@ class Publisher : public DomainEntity DataWriterQos& qos) const; /** - * Fills the DataWriterQos with the values of the XML profile, and also its corresponding topic name (if specified). + * Fills the @ref DataWriterQos with the values of the XML profile, and also its corresponding topic name (if specified). * * @param profile_name DataWriter profile name. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ @@ -356,23 +356,23 @@ class Publisher : public DomainEntity std::string& topic_name) const; /** - * Fills the DataWriterQos with the first DataWriter profile found in the provided XML. + * Fills the @ref DataWriterQos with the first DataWriter profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DataWriterQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos) const; /** - * Fills the DataWriterQos with the first DataWriter profile found in the provided XML, and also its corresponding topic name (if specified). + * Fills the @ref DataWriterQos with the first DataWriter profile found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, @@ -380,12 +380,12 @@ class Publisher : public DomainEntity std::string& topic_name) const; /** - * Fills the DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML. + * Fills the @ref DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @param profile_name DataWriter profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, @@ -393,13 +393,13 @@ class Publisher : public DomainEntity const std::string& profile_name) const; /** - * Fills the DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). + * Fills the @ref DataWriterQos with the DataWriter profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param profile_name DataWriter profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml( const std::string& xml, @@ -408,27 +408,27 @@ class Publisher : public DomainEntity const std::string& profile_name) const; /** - * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is). + * Fills the @ref DataWriterQos with the default DataWriter profile found in the provided XML (if there is). * * @note This method does not update the default datawriter qos (returned by \c get_default_datawriter_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DataWriterQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml( const std::string& xml, DataWriterQos& qos) const; /** - * Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is), and also its corresponding topic name (if specified). + * Fills the @ref DataWriterQos with the default DataWriter profile found in the provided XML (if there is), and also its corresponding topic name (if specified). * * @note This method does not update the default datawriter qos (returned by \c get_default_datawriter_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataWriterQos object where the qos is returned. + * @param qos @ref DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml( const std::string& xml, diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index d37a4427854..3475074e7c1 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -345,10 +345,10 @@ class Subscriber : public DomainEntity DataReaderQos& qos) const; /** - * Fills the DataReaderQos with the values of the XML profile. + * Fills the @ref DataReaderQos with the values of the XML profile. * * @param profile_name DataReader profile name. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile( @@ -356,10 +356,10 @@ class Subscriber : public DomainEntity DataReaderQos& qos) const; /** - * Fills the DataReaderQos with the values of the XML profile, and also its corresponding topic name (if specified). + * Fills the @ref DataReaderQos with the values of the XML profile, and also its corresponding topic name (if specified). * * @param profile_name DataReader profile name. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. */ @@ -369,23 +369,23 @@ class Subscriber : public DomainEntity std::string& topic_name) const; /** - * Fills the DataReaderQos with the first DataReader profile found in the provided XML. + * Fills the @ref DataReaderQos with the first DataReader profile found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DataReaderQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos) const; /** - * Fills the DataReaderQos with the first DataReader profile found in the provided XML, and also its corresponding topic name (if specified). + * Fills the @ref DataReaderQos with the first DataReader profile found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, @@ -393,12 +393,12 @@ class Subscriber : public DomainEntity std::string& topic_name) const; /** - * Fills the DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML. + * Fills the @ref DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML. * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @param profile_name DataReader profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, @@ -406,13 +406,13 @@ class Subscriber : public DomainEntity const std::string& profile_name) const; /** - * Fills the DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). + * Fills the @ref DataReaderQos with the DataReader profile with \c profile_name to be found in the provided XML, and also its corresponding topic name (if specified). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param profile_name DataReader profile name. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml( const std::string& xml, @@ -421,27 +421,27 @@ class Subscriber : public DomainEntity const std::string& profile_name) const; /** - * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is). + * Fills the @ref DataReaderQos with the default DataReader profile found in the provided XML (if there is). * * @note This method does not update the default datareader qos (returned by \c get_default_datareader_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @param qos @ref DataReaderQos object where the qos is returned. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml( const std::string& xml, DataReaderQos& qos) const; /** - * Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is), and also its corresponding topic name (if specified). + * Fills the @ref DataReaderQos with the default DataReader profile found in the provided XML (if there is), and also its corresponding topic name (if specified). * * @note This method does not update the default datareader qos (returned by \c get_default_datareader_qos). * * @param xml Raw XML string containing the profile to be used to fill the \c qos structure. - * @param qos DataReaderQos object where the qos is returned. + * @param qos @ref DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK on success. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK on success. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml( const std::string& xml, diff --git a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp index ab2a8d53d51..a1000e7db93 100644 --- a/src/cpp/fastdds/domain/DomainParticipantFactory.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantFactory.cpp @@ -397,10 +397,10 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_profile const std::string& profile_name, DomainParticipantExtendedQos& extended_qos) const { - extended_qos = default_participant_qos_; ParticipantAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr, false)) { + extended_qos = default_participant_qos_; utils::set_extended_qos_from_attributes(extended_qos, attr); return RETCODE_OK; } @@ -412,10 +412,10 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( const std::string& xml, DomainParticipantExtendedQos& extended_qos) const { - extended_qos = default_participant_qos_; ParticipantAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, false)) { + extended_qos = default_participant_qos_; utils::set_extended_qos_from_attributes(extended_qos, attr); return RETCODE_OK; } @@ -434,10 +434,10 @@ ReturnCode_t DomainParticipantFactory::get_participant_extended_qos_from_xml( return RETCODE_BAD_PARAMETER; } - extended_qos = default_participant_qos_; ParticipantAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fill_participant_attributes_from_xml(xml, attr, true, profile_name)) { + extended_qos = default_participant_qos_; utils::set_extended_qos_from_attributes(extended_qos, attr); return RETCODE_OK; } @@ -449,10 +449,10 @@ ReturnCode_t DomainParticipantFactory::get_default_participant_extended_qos_from const std::string& xml, DomainParticipantExtendedQos& extended_qos) const { - extended_qos = default_participant_qos_; ParticipantAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fill_default_participant_attributes_from_xml(xml, attr, true)) { + extended_qos = default_participant_qos_; utils::set_extended_qos_from_attributes(extended_qos, attr); return RETCODE_OK; } diff --git a/src/cpp/xmlparser/XMLProfileManager.h b/src/cpp/xmlparser/XMLProfileManager.h index 64a5ecafc7e..76e2931d9ed 100644 --- a/src/cpp/xmlparser/XMLProfileManager.h +++ b/src/cpp/xmlparser/XMLProfileManager.h @@ -140,7 +140,7 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults @c true. * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillParticipantAttributes( @@ -182,7 +182,7 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param qos Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults @c true. * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillDomainParticipantFactoryQos( @@ -201,7 +201,7 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults @c true. * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillPublisherAttributes( @@ -243,7 +243,7 @@ class XMLProfileManager * Search for the profile specified and fill the structure. * @param profile_name Name for the profile to be used to fill the structure. * @param atts Structure to be filled. - * @param log_error Flag to log an error if the profile_name is not found. Defaults true. + * @param log_error Flag to log an error if the profile_name is not found. Defaults @c true. * @return XMLP_ret::XML_OK on success, XMLP_ret::XML_ERROR in other case. */ static XMLP_ret fillSubscriberAttributes( From b1f8ad118b9debeac00ef284afe18f632d1e40e3 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 9 Oct 2024 09:25:21 +0200 Subject: [PATCH 17/18] Refs #21745. Apply more suggestions Signed-off-by: Juan Lopez Fernandez --- .../fastdds/dds/domain/DomainParticipant.hpp | 12 +-- include/fastdds/dds/publisher/Publisher.hpp | 4 +- include/fastdds/dds/subscriber/Subscriber.hpp | 4 +- .../dds/participant/ParticipantTests.cpp | 102 +++++++++++++++++- .../unittest/dds/publisher/PublisherTests.cpp | 12 +++ .../dds/subscriber/SubscriberTests.cpp | 12 +++ test/utils/FileUtils.hpp | 6 +- 7 files changed, 136 insertions(+), 16 deletions(-) diff --git a/include/fastdds/dds/domain/DomainParticipant.hpp b/include/fastdds/dds/domain/DomainParticipant.hpp index ae77c779a2c..08ae18e291e 100644 --- a/include/fastdds/dds/domain/DomainParticipant.hpp +++ b/include/fastdds/dds/domain/DomainParticipant.hpp @@ -541,7 +541,7 @@ class DomainParticipant : public Entity * * @param profile_name Publisher profile name. * @param qos @ref PublisherQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_publisher_qos_from_profile( const std::string& profile_name, @@ -632,7 +632,7 @@ class DomainParticipant : public Entity * * @param profile_name Subscriber profile name. * @param qos @ref SubscriberQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_subscriber_qos_from_profile( const std::string& profile_name, @@ -723,7 +723,7 @@ class DomainParticipant : public Entity * * @param profile_name Topic profile name. * @param qos @ref TopicQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_profile( const std::string& profile_name, @@ -736,7 +736,7 @@ class DomainParticipant : public Entity * @param qos @ref TopicQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). * @param topic_data_type String where the name of the topic data type associated to this profile is returned (if specified). - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_topic_qos_from_profile( const std::string& profile_name, @@ -835,7 +835,7 @@ class DomainParticipant : public Entity * * @param profile_name Replier profile name. * @param qos @ref ReplierQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_replier_qos_from_profile( const std::string& profile_name, @@ -883,7 +883,7 @@ class DomainParticipant : public Entity * * @param profile_name Requester profile name. * @param qos @ref RequesterQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_requester_qos_from_profile( const std::string& profile_name, diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index a144f8ab0dd..3458e3fe41d 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -336,7 +336,7 @@ class Publisher : public DomainEntity * * @param profile_name DataWriter profile name. * @param qos @ref DataWriterQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile( const std::string& profile_name, @@ -348,7 +348,7 @@ class Publisher : public DomainEntity * @param profile_name DataWriter profile name. * @param qos @ref DataWriterQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile( const std::string& profile_name, diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 3475074e7c1..077fc4f9f7e 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -349,7 +349,7 @@ class Subscriber : public DomainEntity * * @param profile_name DataReader profile name. * @param qos @ref DataReaderQos object where the qos is returned. - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile( const std::string& profile_name, @@ -361,7 +361,7 @@ class Subscriber : public DomainEntity * @param profile_name DataReader profile name. * @param qos @ref DataReaderQos object where the qos is returned. * @param topic_name String where the name of the topic associated to this profile is returned (if specified). - * @return RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise. + * @return @ref RETCODE_OK if the profile exists. @ref RETCODE_BAD_PARAMETER otherwise. */ FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile( const std::string& profile_name, diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index ec13cab627e..32b7b6def4a 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -874,7 +874,19 @@ TEST(ParticipantTests, GetDefaultParticipantExtendedQosFromXml) RETCODE_OK); // NOTE: cannot load profiles file and compare with default value as - // DomainParticipantFactory::get_default_participant_extended_qos is currently unavailable + // DomainParticipantFactory::get_default_participant_extended_qos is currently unavailable. However, we will + // instead load the profile we know is the default one and compare with it. + + // Load profiles from XML file and get default QoS (knowing its profile name) + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + DomainParticipantExtendedQos default_qos_from_profile; + EXPECT_EQ( + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile("test_default_participant_profile", + default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); } TEST(ParticipantTests, DeleteDomainParticipant) @@ -2123,6 +2135,12 @@ TEST(ParticipantTests, GetSubscriberQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2169,6 +2187,12 @@ TEST(ParticipantTests, GetDefaultSubscriberQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2255,6 +2279,12 @@ TEST(ParticipantTests, GetPublisherQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2301,6 +2331,12 @@ TEST(ParticipantTests, GetDefaultPublisherQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2359,6 +2395,12 @@ TEST(ParticipantTests, GetReplierQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2405,6 +2447,12 @@ TEST(ParticipantTests, GetDefaultReplierQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2417,7 +2465,19 @@ TEST(ParticipantTests, GetDefaultReplierQosFromXml) RETCODE_OK); // NOTE: cannot load profiles file and compare with default value as - // DomainParticipant::get_default_replier_qos is currently unavailable + // DomainParticipant::get_default_replier_qos is currently unavailable. However, we will + // instead load the profile we know is the default one and compare with it. + + // Load profiles from XML file and get default QoS (knowing its profile name) + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + ReplierQos default_qos_from_profile; + EXPECT_EQ( + participant->get_replier_qos_from_profile("test_replier_profile", + default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); // Clean up ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); @@ -2453,6 +2513,12 @@ TEST(ParticipantTests, GetRequesterQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2499,6 +2565,12 @@ TEST(ParticipantTests, GetDefaultRequesterQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2511,7 +2583,19 @@ TEST(ParticipantTests, GetDefaultRequesterQosFromXml) RETCODE_OK); // NOTE: cannot load profiles file and compare with default value as - // DomainParticipant::get_default_requester_qos is currently unavailable + // DomainParticipant::get_default_requester_qos is currently unavailable. However, we will + // instead load the profile we know is the default one and compare with it. + + // Load profiles from XML file and get default QoS (knowing its profile name) + DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); + RequesterQos default_qos_from_profile; + EXPECT_EQ( + participant->get_requester_qos_from_profile("test_requester_profile", + default_qos_from_profile), + RETCODE_OK); + + // Check they correspond to the same profile + EXPECT_EQ(default_qos, default_qos_from_profile); // Clean up ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); @@ -2650,6 +2734,12 @@ TEST(ParticipantTests, GetTopicQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); @@ -2696,6 +2786,12 @@ TEST(ParticipantTests, GetDefaultTopicQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant( (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); diff --git a/test/unittest/dds/publisher/PublisherTests.cpp b/test/unittest/dds/publisher/PublisherTests.cpp index dcb449ad3c9..064c1372318 100644 --- a/test/unittest/dds/publisher/PublisherTests.cpp +++ b/test/unittest/dds/publisher/PublisherTests.cpp @@ -578,6 +578,12 @@ TEST(PublisherTests, GetDataWriterQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); ASSERT_NE(participant, nullptr); @@ -626,6 +632,12 @@ TEST(PublisherTests, GetDefaultDataWriterQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); ASSERT_NE(participant, nullptr); diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index 178913383d5..02cdfa3d727 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -602,6 +602,12 @@ TEST(SubscriberTests, GetDataReaderQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); ASSERT_NE(participant, nullptr); @@ -650,6 +656,12 @@ TEST(PublisherTests, GetDefaultDataReaderQosFromXml) std::string complete_xml = testing::load_file(xml_filename); + // Disable created auxiliar entities to avoid polluting traffic + DomainParticipantFactoryQos factory_qos; + DomainParticipantFactory::get_instance()->get_qos(factory_qos); + factory_qos.entity_factory().autoenable_created_entities = false; + DomainParticipantFactory::get_instance()->set_qos(factory_qos); + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT); ASSERT_NE(participant, nullptr); diff --git a/test/utils/FileUtils.hpp b/test/utils/FileUtils.hpp index bb85ce33edd..d6ead1ff64f 100644 --- a/test/utils/FileUtils.hpp +++ b/test/utils/FileUtils.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -#ifndef _TEST_UTILS_FILEUTILS_HPP_ -#define _TEST_UTILS_FILEUTILS_HPP_ +#ifndef TEST_UTILS__FILEUTILS_HPP +#define TEST_UTILS__FILEUTILS_HPP #include #include @@ -48,4 +48,4 @@ std::string load_file(const std::string& file_path) } // namespace fastdds } // namespace eprosima -#endif // _TEST_UTILS_FILEUTILS_HPP_ +#endif // TEST_UTILS__FILEUTILS_HPP From 14439b52d5400114d25c7f4a71c97e33597544c7 Mon Sep 17 00:00:00 2001 From: Juan Lopez Fernandez Date: Wed, 9 Oct 2024 09:30:39 +0200 Subject: [PATCH 18/18] Refs #21745. Uncrustify Signed-off-by: Juan Lopez Fernandez --- src/cpp/xmlparser/XMLProfileManager.cpp | 36 +++++++++++-------- .../dds/participant/ParticipantTests.cpp | 11 +++--- test/utils/FileUtils.hpp | 6 ++-- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/cpp/xmlparser/XMLProfileManager.cpp b/src/cpp/xmlparser/XMLProfileManager.cpp index 4854c73e1b4..0e21b1d9369 100644 --- a/src/cpp/xmlparser/XMLProfileManager.cpp +++ b/src/cpp/xmlparser/XMLProfileManager.cpp @@ -64,6 +64,7 @@ struct AttributesTraits { return "Participant"; } + }; template<> @@ -77,6 +78,7 @@ struct AttributesTraits { return "Publisher"; } + }; template<> @@ -90,6 +92,7 @@ struct AttributesTraits { return "Subscriber"; } + }; template<> @@ -103,6 +106,7 @@ struct AttributesTraits { return "Topic"; } + }; template<> @@ -116,6 +120,7 @@ struct AttributesTraits { return "Requester"; } + }; template<> @@ -129,6 +134,7 @@ struct AttributesTraits { return "Replier"; } + }; template @@ -210,11 +216,11 @@ XMLP_ret fill_attributes_from_xml( std::reference_wrapper node_to_process = root_node; if (fulfill_xsd) { - if (NodeType::ROOT == root_node ->getType()) + if (NodeType::ROOT == root_node->getType()) { for (auto&& child: root_node->getChildren()) { - if (NodeType::PROFILES == child ->getType()) + if (NodeType::PROFILES == child->getType()) { node_to_process = child; break; @@ -246,14 +252,15 @@ XMLP_ret fill_attributes_from_xml( bool fulfill_xsd, const std::string& profile_name) { - auto node_filter = [&profile_name](typename AttributesTraits::NodePtrType node) -> bool { - if (!profile_name.empty()) - { - auto it = node->getAttributes().find(PROFILE_NAME); - return (it != node->getAttributes().end() && it->second == profile_name); - } - return true; - }; + auto node_filter = [&profile_name](typename AttributesTraits::NodePtrType node) -> bool + { + if (!profile_name.empty()) + { + auto it = node->getAttributes().find(PROFILE_NAME); + return (it != node->getAttributes().end() && it->second == profile_name); + } + return true; + }; return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); } @@ -263,10 +270,11 @@ XMLP_ret fill_default_attributes_from_xml( AttributesType& atts, bool fulfill_xsd) { - auto node_filter = [](typename AttributesTraits::NodePtrType node) -> bool { - auto it = node->getAttributes().find(DEFAULT_PROF); - return (it != node->getAttributes().end() && it->second == "true"); - }; + auto node_filter = [](typename AttributesTraits::NodePtrType node) -> bool + { + auto it = node->getAttributes().find(DEFAULT_PROF); + return (it != node->getAttributes().end() && it->second == "true"); + }; return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); } diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 32b7b6def4a..e7901befe50 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -837,7 +837,8 @@ TEST(ParticipantTests, GetParticipantExtendedQosFromXml) // Get QoS without providing profile name (gets first one found) DomainParticipantExtendedQos qos_empty_profile; EXPECT_EQ( - DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, qos_empty_profile), RETCODE_OK); + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_xml(complete_xml, + qos_empty_profile), RETCODE_OK); // Check they correspond to the same profile // NOTE: test_participant_profile is assumed to be the first participant profile in the XML file @@ -870,7 +871,8 @@ TEST(ParticipantTests, GetDefaultParticipantExtendedQosFromXml) // Get default QoS from XML DomainParticipantExtendedQos default_qos; EXPECT_EQ( - DomainParticipantFactory::get_instance()->get_default_participant_extended_qos_from_xml(complete_xml, default_qos), + DomainParticipantFactory::get_instance()->get_default_participant_extended_qos_from_xml(complete_xml, + default_qos), RETCODE_OK); // NOTE: cannot load profiles file and compare with default value as @@ -881,8 +883,9 @@ TEST(ParticipantTests, GetDefaultParticipantExtendedQosFromXml) DomainParticipantFactory::get_instance()->load_XML_profiles_file(xml_filename); DomainParticipantExtendedQos default_qos_from_profile; EXPECT_EQ( - DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile("test_default_participant_profile", - default_qos_from_profile), + DomainParticipantFactory::get_instance()->get_participant_extended_qos_from_profile( + "test_default_participant_profile", + default_qos_from_profile), RETCODE_OK); // Check they correspond to the same profile diff --git a/test/utils/FileUtils.hpp b/test/utils/FileUtils.hpp index d6ead1ff64f..7d71530c71a 100644 --- a/test/utils/FileUtils.hpp +++ b/test/utils/FileUtils.hpp @@ -24,12 +24,14 @@ namespace eprosima { namespace fastdds { namespace testing { -std::string load_file(const std::string& file_path) +std::string load_file( + const std::string& file_path) { std::ifstream file(file_path); // Check if the file was opened successfully - if (!file.is_open()) { + if (!file.is_open()) + { throw std::runtime_error("Could not open file " + file_path); }