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 fa5c721868d..38dc97a7122 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