Skip to content

Commit fab21b5

Browse files
Add QoS getters from raw XML (#928)
* Refs #21745. Update documentation Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> * Refs #21745. Remove collapse option Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> * Refs #21745. Piggyback: minor update to DDS-Record-Replay tutorial Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com> --------- Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
1 parent 343836e commit fab21b5

File tree

6 files changed

+125
-32
lines changed

6 files changed

+125
-32
lines changed

code/DDSCodeTester.cpp

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5844,6 +5844,41 @@ void xml_profiles_examples()
58445844
}
58455845
//!--
58465846
}
5847+
{
5848+
//XML-GET-QOS-FROM-XML
5849+
DomainParticipant* participant =
5850+
DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
5851+
5852+
Topic* topic =
5853+
participant->create_topic("TopicName", "DataTypeName", TOPIC_QOS_DEFAULT);
5854+
5855+
Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT);
5856+
5857+
// Load XML as string data buffer
5858+
std::string xml_profile =
5859+
"\
5860+
<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\
5861+
<dds>\
5862+
<profiles xmlns=\"http://www.eprosima.com\" >\
5863+
<data_writer profile_name=\"test_datawriter_profile\" is_default_profile=\"true\">\
5864+
<qos>\
5865+
<durability>\
5866+
<kind>TRANSIENT_LOCAL</kind>\
5867+
</durability>\
5868+
</qos>\
5869+
</data_writer>\
5870+
</profiles>\
5871+
</dds>\
5872+
";
5873+
5874+
// Extract Qos from XML
5875+
DataWriterQos qos;
5876+
if (RETCODE_OK == publisher->get_datawriter_qos_from_xml(xml_profile, qos, "test_datawriter_profile"))
5877+
{
5878+
// Modify extracted qos and use it to create DDS entities
5879+
}
5880+
//!--
5881+
}
58475882
}
58485883

58495884
void dds_transport_examples ()
@@ -7704,28 +7739,6 @@ bool dds_permissions_test(
77047739
return false;
77057740
}
77067741

7707-
bool dds_rosbag_example()
7708-
{
7709-
//CREATE THE PARTICIPANT
7710-
DomainParticipant* participant_;
7711-
Topic* topic_;
7712-
TypeSupport type_;
7713-
7714-
participant_ = DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
7715-
7716-
//CREATE THE TOPIC FOR ROSBAG
7717-
topic_ = participant_->create_topic(
7718-
"rt/HelloWorldTopic",
7719-
type_.get_type_name(),
7720-
TOPIC_QOS_DEFAULT);
7721-
if (topic_ == nullptr)
7722-
{
7723-
return false;
7724-
}
7725-
//!
7726-
return true;
7727-
}
7728-
77297742
void pubsub_api_example_create_entities()
77307743
{
77317744
//PUBSUB_API_CREATE_PARTICIPANT

docs/03-exports/aliases-api.include

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,21 @@
140140
.. |DomainParticipant::set_default_subscriber_qos-api| replace:: :cpp:func:`set_default_subscriber_qos()<eprosima::fastdds::dds::DomainParticipant::set_default_subscriber_qos>`
141141
.. |DomainParticipant::set_default_topic_qos-api| replace:: :cpp:func:`set_default_topic_qos()<eprosima::fastdds::dds::DomainParticipant::set_default_topic_qos>`
142142
.. |DomainParticipant::get_qos-api| replace:: :cpp:func:`DomainParticipant::get_qos()<eprosima::fastdds::dds::DomainParticipant::get_qos>`
143-
.. |DomainParticipant::get_publisher_qos_from_profile| replace:: :cpp:func:`get_publisher_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_publisher_qos_from_profile>`
144-
.. |DomainParticipant::get_subscriber_qos_from_profile| replace:: :cpp:func:`get_subscriber_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_subscriber_qos_from_profile>`
145-
.. |DomainParticipant::get_topic_qos_from_profile| replace:: :cpp:func:`get_topic_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_topic_qos_from_profile>`
143+
.. |DomainParticipant::get_publisher_qos_from_profile-api| replace:: :cpp:func:`get_publisher_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_publisher_qos_from_profile>`
144+
.. |DomainParticipant::get_publisher_qos_from_xml-api| replace:: :cpp:func:`get_publisher_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_publisher_qos_from_xml>`
145+
.. |DomainParticipant::get_default_publisher_qos_from_xml-api| replace:: :cpp:func:`get_default_publisher_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_default_publisher_qos_from_xml>`
146+
.. |DomainParticipant::get_subscriber_qos_from_profile-api| replace:: :cpp:func:`get_subscriber_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_subscriber_qos_from_profile>`
147+
.. |DomainParticipant::get_subscriber_qos_from_xml-api| replace:: :cpp:func:`get_subscriber_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_subscriber_qos_from_xml>`
148+
.. |DomainParticipant::get_default_subscriber_qos_from_xml-api| replace:: :cpp:func:`get_default_subscriber_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_default_subscriber_qos_from_xml>`
149+
.. |DomainParticipant::get_topic_qos_from_profile-api| replace:: :cpp:func:`get_topic_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_topic_qos_from_profile>`
150+
.. |DomainParticipant::get_topic_qos_from_xml-api| replace:: :cpp:func:`get_topic_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_topic_qos_from_xml>`
151+
.. |DomainParticipant::get_default_topic_qos_from_xml-api| replace:: :cpp:func:`get_default_topic_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_default_topic_qos_from_xml>`
152+
.. |DomainParticipant::get_requester_qos_from_profile-api| replace:: :cpp:func:`get_requester_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_requester_qos_from_profile>`
153+
.. |DomainParticipant::get_requester_qos_from_xml-api| replace:: :cpp:func:`get_requester_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_requester_qos_from_xml>`
154+
.. |DomainParticipant::get_default_requester_qos_from_xml-api| replace:: :cpp:func:`get_default_requester_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_default_requester_qos_from_xml>`
155+
.. |DomainParticipant::get_replier_qos_from_profile-api| replace:: :cpp:func:`get_replier_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_replier_qos_from_profile>`
156+
.. |DomainParticipant::get_replier_qos_from_xml-api| replace:: :cpp:func:`get_replier_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_replier_qos_from_xml>`
157+
.. |DomainParticipant::get_default_replier_qos_from_xml-api| replace:: :cpp:func:`get_default_replier_qos_from_xml()<eprosima::fastdds::dds::DomainParticipant::get_default_replier_qos_from_xml>`
146158
.. |DomainParticipant::set_qos-api| replace:: :cpp:func:`DomainParticipant::set_qos()<eprosima::fastdds::dds::DomainParticipant::set_qos>`
147159
.. |DomainParticipant::delete_contained_entities-api| replace:: :cpp:func:`delete_contained_entities()<eprosima::fastdds::dds::DomainParticipant::delete_contained_entities>`
148160
.. |DomainParticipant::create_topic_with_profile-api| replace:: :cpp:func:`create_topic_with_profile()<eprosima::fastdds::dds::DomainParticipant::create_topic_with_profile>`
@@ -151,7 +163,9 @@
151163
.. |DomainParticipant::enable-monitor-service-api| replace:: :cpp:func:`enable_monitor_service()<eprosima::fastdds::dds::DomainParticipant::enable_monitor_service>`
152164
.. |DomainParticipant::disable-monitor-service-api| replace:: :cpp:func:`disable_monitor_service()<eprosima::fastdds::dds::DomainParticipant::disable_monitor_service>`
153165

154-
.. |DomainParticipant::get_participant_qos_from_profile| replace:: :cpp:func:`get_participant_qos_from_profile()<eprosima::fastdds::dds::DomainParticipant::get_participant_qos_from_profile>`
166+
.. |DomainParticipantFactory::get_participant_qos_from_profile-api| replace:: :cpp:func:`get_participant_qos_from_profile()<eprosima::fastdds::dds::DomainParticipantFactory::get_participant_qos_from_profile>`
167+
.. |DomainParticipantFactory::get_participant_qos_from_xml-api| replace:: :cpp:func:`get_participant_qos_from_xml()<eprosima::fastdds::dds::DomainParticipantFactory::get_participant_qos_from_xml>`
168+
.. |DomainParticipantFactory::get_default_participant_qos_from_xml-api| replace:: :cpp:func:`get_default_participant_qos_from_xml()<eprosima::fastdds::dds::DomainParticipantFactory::get_default_participant_qos_from_xml>`
155169
.. |DomainParticipantFactory-api| replace:: :cpp:class:`DomainParticipantFactory<eprosima::fastdds::dds::DomainParticipantFactory>`
156170
.. |DomainParticipantFactory::check_xml_static_discovery-api| replace:: :cpp:func:`DomainParticipantFactory::check_xml_static_discovery()<eprosima::fastdds::dds::DomainParticipantFactory::check_xml_static_discovery>`
157171
.. |DomainParticipantFactory::create_participant_with_default_profile-api| replace:: :cpp:func:`create_participant_with_default_profile()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_default_profile>`
@@ -162,6 +176,8 @@
162176
.. |DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name-api| replace:: :cpp:func:`DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name()<eprosima::fastdds::dds::DomainParticipantFactory::get_dynamic_type_builder_from_xml_by_name>`
163177
.. |DomainParticipantFactory::get_instance-api| replace:: :cpp:func:`get_instance()<eprosima::fastdds::dds::DomainParticipantFactory::get_instance>`
164178
.. |DomainParticipantFactory::get_participant_extended_qos_from_profile-api| replace:: :cpp:func:`get_participant_extended_qos_from_profile()<eprosima::fastdds::dds::DomainParticipantFactory::get_participant_extended_qos_from_profile>`
179+
.. |DomainParticipantFactory::get_participant_extended_qos_from_xml-api| replace:: :cpp:func:`get_participant_extended_qos_from_xml()<eprosima::fastdds::dds::DomainParticipantFactory::get_participant_extended_qos_from_xml>`
180+
.. |DomainParticipantFactory::get_default_participant_extended_qos_from_xml-api| replace:: :cpp:func:`get_default_participant_extended_qos_from_xml()<eprosima::fastdds::dds::DomainParticipantFactory::get_default_participant_extended_qos_from_xml>`
165181
.. |DomainParticipantFactory::load_XML_profiles_file-api| replace:: :cpp:func:`load_XML_profiles_file()<eprosima::fastdds::dds::DomainParticipantFactory::load_XML_profiles_file>`
166182
.. |DomainParticipantFactory::load_XML_profiles_string-api| replace:: :cpp:func:`load_XML_profiles_string()<eprosima::fastdds::dds::DomainParticipantFactory::load_XML_profiles_string>`
167183
.. |DomainParticipantFactory::set_default_participant_qos-api| replace:: :cpp:func:`set_default_participant_qos()<eprosima::fastdds::dds::DomainParticipantFactory::set_default_participant_qos>`
@@ -222,7 +238,9 @@
222238
.. |Publisher::create_datawriter-api| replace:: :cpp:func:`create_datawriter()<eprosima::fastdds::dds::Publisher::create_datawriter>`
223239
.. |Publisher::delete_datawriter-api| replace:: :cpp:func:`delete_datawriter()<eprosima::fastdds::dds::Publisher::delete_datawriter>`
224240
.. |Publisher::get_default_datawriter_qos-api| replace:: :cpp:func:`get_default_datawriter_qos()<eprosima::fastdds::dds::Publisher::get_default_datawriter_qos>`
225-
.. |Publisher::get_datawriter_qos_from_profile| replace:: :cpp:func:`get_datawriter_qos_from_profile()<eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_profile>`
241+
.. |Publisher::get_datawriter_qos_from_profile-api| replace:: :cpp:func:`get_datawriter_qos_from_profile()<eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_profile>`
242+
.. |Publisher::get_datawriter_qos_from_xml-api| replace:: :cpp:func:`get_datawriter_qos_from_xml()<eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_xml>`
243+
.. |Publisher::get_default_datawriter_qos_from_xml-api| replace:: :cpp:func:`get_default_datawriter_qos_from_xml()<eprosima::fastdds::dds::Publisher::get_default_datawriter_qos_from_xml>`
226244
.. |Publisher::get_qos-api| replace:: :cpp:func:`get_qos()<eprosima::fastdds::dds::Publisher::get_qos>`
227245
.. |Publisher::set_default_datawriter_qos-api| replace:: :cpp:func:`set_default_datawriter_qos()<eprosima::fastdds::dds::Publisher::set_default_datawriter_qos>`
228246
.. |Publisher::set_qos-api| replace:: :cpp:func:`Publisher::set_qos()<eprosima::fastdds::dds::Publisher::set_qos>`
@@ -246,7 +264,9 @@
246264
.. |Subscriber::get_datareaders-api| replace:: :cpp:func:`Subscriber::get_datareaders()<eprosima::fastdds::dds::Subscriber::get_datareaders>`
247265
.. |Subscriber::get_default_datareader_qos-api| replace:: :cpp:func:`get_default_datareader_qos()<eprosima::fastdds::dds::Subscriber::get_default_datareader_qos>`
248266
.. |Subscriber::set_default_datareader_qos-api| replace:: :cpp:func:`set_default_datareader_qos()<eprosima::fastdds::dds::Subscriber::set_default_datareader_qos>`
249-
.. |Subscriber::get_datareader_qos_from_profile| replace:: :cpp:func:`get_datareader_qos_from_profile()<eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_profile>`
267+
.. |Subscriber::get_datareader_qos_from_profile-api| replace:: :cpp:func:`get_datareader_qos_from_profile()<eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_profile>`
268+
.. |Subscriber::get_datareader_qos_from_xml-api| replace:: :cpp:func:`get_datareader_qos_from_xml()<eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_xml>`
269+
.. |Subscriber::get_default_datareader_qos_from_xml-api| replace:: :cpp:func:`get_default_datareader_qos_from_xml()<eprosima::fastdds::dds::Subscriber::get_default_datareader_qos_from_xml>`
250270
.. |Subscriber::create_datareader-api| replace:: :cpp:func:`create_datareader()<eprosima::fastdds::dds::Subscriber::create_datareader>`
251271
.. |Subscriber::delete_datareader-api| replace:: :cpp:func:`delete_datareader()<eprosima::fastdds::dds::Subscriber::delete_datareader>`
252272
.. |Subscriber::create_datareader_with_profile-api| replace:: :cpp:func:`create_datareader_with_profile()<eprosima::fastdds::dds::Subscriber::create_datareader_with_profile>`

docs/fastdds/dds_layer/domain/domainParticipant/domainParticipant.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,7 @@ the |DomainParticipant-api| from |DomainParticipantQos-api|.
178178
:start-after: //DDS_CHANGE_DOMAINPARTICIPANTEXTENDEDQOS
179179
:end-before: //!
180180
:dedent: 8
181+
182+
It is also possible to fill a |DomainParticipantExtendedQos-api| object directly from a raw XML string without the need
183+
to previously load any profile.
184+
Please refer to :ref:`loading_raw_xml_profiles` section for more information.

docs/fastdds/use_cases/dds_record_and_replay/dds_record_and_replay.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ Stop the recorder with ``Ctrl+C`` and check that the MCAP file exists.
9494
Next Steps
9595
==========
9696

97-
The usage of the DDS Remote Controller and DDS Replay tools follows
98-
the same steps as the DDS Recorder tool.
97+
Once having finished a recording session, it is possible to play it back by using **DDS Replay tool**, as shown
98+
in `this tutorial <https://dds-recorder.readthedocs.io/en/latest/rst/replaying/getting_started/usage_example.html>`_.
9999

100100
For further information, please refer to the
101101
`eProsima DDS Record and Replay documentation

docs/fastdds/use_cases/use_cases.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ with distributed systems:
9090
and how to take full advantage of *Fast DDS* wide set of capabilities in a ROS 2 project.
9191

9292
+ :ref:`dds_record_and_replay`.
93-
Instructions on how to tune your application to be able to record and replay your DDS messages using ROS 2 rosbag2
94-
package.
93+
Instructions on how to tune your application to be able to record and replay your DDS messages using
94+
`eProsima DDS Record and Replay <https://github.com/eProsima/DDS-Record-Replay>`_.
9595

9696
+ :ref:`use-case-request-reply`.
9797
Although *Fast DDS* provides a *Publisher-Subscriber* communication protocol, it offers a mechanism to use

docs/fastdds/xml_configuration/making_xml_profiles.rst

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,62 @@ Please, refer to :ref:`xml_profiles` for further information regarding loading p
7878

7979
To load dynamic types from XML files see the :ref:`Usage` subsection of :ref:`xmldynamictypes`.
8080

81+
.. _loading_raw_xml_profiles:
82+
83+
Get QoS from raw XML profiles
84+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85+
86+
Although the :ref:`standard procedure <loadingapplyingprofiles>` is to first load XML profiles, and then create entities
87+
given the profile name of choice, it is also possible to get the desired QoS from the XML profile directly so it can be
88+
modified before being used.
89+
For this purpose, the following public methods are available:
90+
91+
- |DomainParticipantFactory-api|
92+
93+
- |DomainParticipantFactory::get_participant_qos_from_xml-api|
94+
- |DomainParticipantFactory::get_default_participant_qos_from_xml-api|
95+
- |DomainParticipantFactory::get_participant_extended_qos_from_xml-api|
96+
- |DomainParticipantFactory::get_default_participant_extended_qos_from_xml-api|
97+
98+
- |DomainParticipant-api|
99+
100+
- |DomainParticipant::get_publisher_qos_from_xml-api|
101+
- |DomainParticipant::get_default_publisher_qos_from_xml-api|
102+
- |DomainParticipant::get_subscriber_qos_from_xml-api|
103+
- |DomainParticipant::get_default_subscriber_qos_from_xml-api|
104+
- |DomainParticipant::get_topic_qos_from_xml-api|
105+
- |DomainParticipant::get_default_topic_qos_from_xml-api|
106+
- |DomainParticipant::get_requester_qos_from_xml-api|
107+
- |DomainParticipant::get_default_requester_qos_from_xml-api|
108+
- |DomainParticipant::get_replier_qos_from_xml-api|
109+
- |DomainParticipant::get_default_replier_qos_from_xml-api|
110+
111+
- |Publisher-api|
112+
113+
- |Publisher::get_datawriter_qos_from_xml-api|
114+
- |Publisher::get_default_datawriter_qos_from_xml-api|
115+
116+
- |Subscriber-api|
117+
118+
- |Subscriber::get_datareader_qos_from_xml-api|
119+
- |Subscriber::get_default_datareader_qos_from_xml-api|
120+
121+
For each :code:`qos` kind there exists two method versions; with and without :code:`profile_name` argument.
122+
When provided, the method searches for the given profile name in the loaded XML profiles,
123+
and results in error if not found.
124+
When not provided, the method fills the provided :code:`qos` object with the first retrieved profile of the
125+
pertinent kind, and results in error when none found.
126+
In addition, there exists another method version which looks for the default profile of the pertinent kind
127+
in the provided XML string.
128+
129+
Following is an example of how to get the QoS from a raw XML profile and modify it before creating a new entity.
130+
131+
.. literalinclude:: /../code/DDSCodeTester.cpp
132+
:language: cpp
133+
:start-after: //XML-GET-QOS-FROM-XML
134+
:end-before: //!--
135+
:dedent: 8
136+
81137
.. _rootedvsstandalone:
82138

83139
Rooted vs Standalone profiles definition

0 commit comments

Comments
 (0)