Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20543] Create Participant with default profile (use environment XML configuration) #725

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,31 @@ void dds_domain_examples()
//!--
}

{
//DDS_CREATE_DOMAINPARTICIPANT_DEFAULT_PROFILE
// Create a DomainParticipant using the environment profile and no Listener
DomainParticipant* participant =
DomainParticipantFactory::get_instance()->create_participant_with_default_profile();
if (nullptr == participant)
{
// Error
return;
}

// Create a DomainParticipant using the environment profile and a custom Listener.
// CustomDomainParticipantListener inherits from DomainParticipantListener.
CustomDomainParticipantListener custom_listener;
DomainParticipant* participant_with_custom_listener =
DomainParticipantFactory::get_instance()->create_participant_with_default_profile(
&custom_listener, StatusMask::none());
if (nullptr == participant_with_custom_listener)
{
// Error
return;
}
//!--
}

{
//DDS_CHANGE_DOMAINPARTICIPANTQOS
// Create a DomainParticipant with default DomainParticipantQos
Expand Down Expand Up @@ -6460,6 +6485,11 @@ void pubsub_api_example_create_entities()
DomainParticipantFactory::get_instance()->create_participant(0, PARTICIPANT_QOS_DEFAULT);
//!--

//PUBSUB_API_CREATE_DEFAULT_PARTICIPANT
DomainParticipant* default_participant =
DomainParticipantFactory::get_instance()->create_participant_with_default_profile();
//!--

//PUBSUB_API_CREATE_PUBLISHER
Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT);
//!--
Expand Down
1 change: 1 addition & 0 deletions docs/03-exports/aliases-api.include
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
.. |DomainParticipant::disable-monitor-service-api| replace:: :cpp:func:`disable_monitor_service()<eprosima::fastdds::dds::DomainParticipant::disable_monitor_service>`

.. |DomainParticipantFactory-api| replace:: :cpp:class:`DomainParticipantFactory<eprosima::fastdds::dds::DomainParticipantFactory>`
.. |DomainParticipantFactory::create_participant_with_default_profile-api| replace:: :cpp:func:`create_participant_with_default_profile()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_default_profile>`
.. |DomainParticipantFactory::create_participant_with_profile-api| replace:: :cpp:func:`create_participant_with_profile()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant_with_profile>`
.. |DomainParticipantFactory::create_participant-api| replace:: :cpp:func:`create_participant()<eprosima::fastdds::dds::DomainParticipantFactory::create_participant>`
.. |DomainParticipantFactory::delete_participant-api| replace:: :cpp:func:`delete_participant()<eprosima::fastdds::dds::DomainParticipantFactory::delete_participant>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,42 @@ It is advisable to check that the returned value is a valid pointer.
:end-before: //!
:dedent: 8

.. _dds_layer_domainParticipant_creation_default_profile:

Default profile DomainParticipant creation
------------------------------------------

If there is a profile already exported in the environment (please refer to :ref:`xml_profiles` for related
information), creating a DomainParticipant with the
|DomainParticipantFactory::create_participant_with_default_profile-api| member function on the
:ref:`dds_layer_domainParticipantFactory` singleton would use that settings to configure the participant.
If the profile has not been exported, the DomainParticipant will be created with the default values per
:ref:`dds_layer_domainParticipantQos`, and ``0`` as |DomainId-api|.

Optional arguments are:

* A Listener derived from :ref:`dds_layer_domainParticipantListener`, implementing the callbacks
that will be triggered in response to events and state changes on the DomainParticipant.
By default empty callbacks are used.

* A |StatusMask-api| that activates or deactivates triggering of individual callbacks on the
:ref:`dds_layer_domainParticipantListener`.
By default all events are enabled.

|DomainParticipantFactory::create_participant_with_default_profile-api| will return a null pointer if there was an
error during the operation.
It is advisable to check that the returned value is a valid pointer.

.. note::

XML profiles must have been loaded previously. See :ref:`xml_profiles`.

.. literalinclude:: /../code/DDSCodeTester.cpp
:language: c++
:start-after: //DDS_CREATE_DOMAINPARTICIPANT_DEFAULT_PROFILE
:end-before: //!
:dedent: 8

.. _dds_layer_domainParticipant_deletion:

Deleting a DomainParticipant
Expand Down
5 changes: 5 additions & 0 deletions docs/fastdds/xml_configuration/making_xml_profiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ if founded.
:end-before: //!--
:dedent: 8

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

.. warning::

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