Skip to content

Commit 07bf119

Browse files
Create Participant with default profile (use environment XML configuration) (#725)
Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
1 parent fe8b04b commit 07bf119

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

code/DDSCodeTester.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,31 @@ void dds_domain_examples()
392392
//!--
393393
}
394394

395+
{
396+
//DDS_CREATE_DOMAINPARTICIPANT_DEFAULT_PROFILE
397+
// Create a DomainParticipant using the environment profile and no Listener
398+
DomainParticipant* participant =
399+
DomainParticipantFactory::get_instance()->create_participant_with_default_profile();
400+
if (nullptr == participant)
401+
{
402+
// Error
403+
return;
404+
}
405+
406+
// Create a DomainParticipant using the environment profile and a custom Listener.
407+
// CustomDomainParticipantListener inherits from DomainParticipantListener.
408+
CustomDomainParticipantListener custom_listener;
409+
DomainParticipant* participant_with_custom_listener =
410+
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(
411+
&custom_listener, StatusMask::none());
412+
if (nullptr == participant_with_custom_listener)
413+
{
414+
// Error
415+
return;
416+
}
417+
//!--
418+
}
419+
395420
{
396421
//DDS_CHANGE_DOMAINPARTICIPANTQOS
397422
// Create a DomainParticipant with default DomainParticipantQos
@@ -6460,6 +6485,11 @@ void pubsub_api_example_create_entities()
64606485
DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
64616486
//!--
64626487

6488+
//PUBSUB_API_CREATE_DEFAULT_PARTICIPANT
6489+
DomainParticipant* default_participant =
6490+
DomainParticipantFactory::get_instance()->create_participant_with_default_profile();
6491+
//!--
6492+
64636493
//PUBSUB_API_CREATE_PUBLISHER
64646494
Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT);
64656495
//!--

docs/03-exports/aliases-api.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
.. |DomainParticipant::disable-monitor-service-api| replace:: :cpp:func:`disable_monitor_service()<eprosima::fastdds::dds::DomainParticipant::disable_monitor_service>`
151151

152152
.. |DomainParticipantFactory-api| replace:: :cpp:class:`DomainParticipantFactory<eprosima::fastdds::dds::DomainParticipantFactory>`
153+
.. |DomainParticipantFactory::create_participant_with_default_profile-api| replace:: :cpp:func:`create_participant_with_default_profile()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_default_profile>`
153154
.. |DomainParticipantFactory::create_participant_with_profile-api| replace:: :cpp:func:`create_participant_with_profile()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_profile>`
154155
.. |DomainParticipantFactory::create_participant-api| replace:: :cpp:func:`create_participant()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant>`
155156
.. |DomainParticipantFactory::delete_participant-api| replace:: :cpp:func:`delete_participant()<eprosima::fastdds::dds::DomainParticipantFactory::delete_participant>`

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,42 @@ It is advisable to check that the returned value is a valid pointer.
8888
:end-before: //!
8989
:dedent: 8
9090

91+
.. _dds_layer_domainParticipant_creation_default_profile:
92+
93+
Default profile DomainParticipant creation
94+
------------------------------------------
95+
96+
If there is a profile already exported in the environment (please refer to :ref:`xml_profiles` for related
97+
information), creating a DomainParticipant with the
98+
|DomainParticipantFactory::create_participant_with_default_profile-api| member function on the
99+
:ref:`dds_layer_domainParticipantFactory` singleton would use that settings to configure the participant.
100+
If the profile has not been exported, the DomainParticipant will be created with the default values per
101+
:ref:`dds_layer_domainParticipantQos`, and ``0`` as |DomainId-api|.
102+
103+
Optional arguments are:
104+
105+
* A Listener derived from :ref:`dds_layer_domainParticipantListener`, implementing the callbacks
106+
that will be triggered in response to events and state changes on the DomainParticipant.
107+
By default empty callbacks are used.
108+
109+
* A |StatusMask-api| that activates or deactivates triggering of individual callbacks on the
110+
:ref:`dds_layer_domainParticipantListener`.
111+
By default all events are enabled.
112+
113+
|DomainParticipantFactory::create_participant_with_default_profile-api| will return a null pointer if there was an
114+
error during the operation.
115+
It is advisable to check that the returned value is a valid pointer.
116+
117+
.. note::
118+
119+
XML profiles must have been loaded previously. See :ref:`xml_profiles`.
120+
121+
.. literalinclude:: /../code/DDSCodeTester.cpp
122+
:language: c++
123+
:start-after: //DDS_CREATE_DOMAINPARTICIPANT_DEFAULT_PROFILE
124+
:end-before: //!
125+
:dedent: 8
126+
91127
.. _dds_layer_domainParticipant_deletion:
92128

93129
Deleting a DomainParticipant

docs/fastdds/xml_configuration/making_xml_profiles.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ if founded.
6464
:end-before: //!--
6565
:dedent: 8
6666

67+
For simplicity, the |DomainParticipantFactory::create_participant_with_default_profile-api| method takes the default
68+
profile set in the environment to create a participant.
69+
It requires the XML profile to have been already loaded.
70+
Please, refer to :ref:`xml_profiles` for further information regarding loading profiles.
71+
6772
.. warning::
6873

6974
It is worth mentioning that if the same XML profile file is loaded multiple times, the second loading of

0 commit comments

Comments
 (0)