Skip to content

Latest commit

 

History

History
111 lines (77 loc) · 4.42 KB

createDomainParticipant.rst

File metadata and controls

111 lines (77 loc) · 4.42 KB

Creating a DomainParticipant

Creation of a :ref:`dds_layer_domainParticipant` is done with the |DomainParticipantFactory::create_participant-api| member function on the :ref:`dds_layer_domainParticipantFactory` singleton, that acts as a factory for the DomainParticipant.

Mandatory arguments are:

Optional arguments are:

Warning

Following the DDSI-RTPS V2.2 standard (Section 9.6.1.1), the default ports are calculated depending on the |DomainId-api|, as it is explained in section :ref:`listening_locators_defaultPorts`. Thus, it is encouraged to use |DomainId-api| lower than 200 (over |DomainId-api| 233 default port assign will fail consistently).

|DomainParticipantFactory::create_participant-api| will return a null pointer if there was an error during the operation, e.g. if the provided QoS is not compatible or is not supported. It is advisable to check that the returned value is a valid pointer.

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


Profile based creation of a DomainParticipant

Instead of using a DomainParticipantQos, the name of a profile can be used to create a DomainParticipant with the |DomainParticipantFactory::create_participant_with_profile-api| member function on the :ref:`dds_layer_domainParticipantFactory` singleton.

Mandatory arguments are:

Optional arguments are:

|DomainParticipantFactory::create_participant_with_profile-api| will return a null pointer if there was an error during the operation, e.g if the provided QoS is not compatible or is not supported. It is advisable to check that the returned value is a valid pointer.

Note

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

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

Deleting a DomainParticipant

A DomainParticipant can be deleted with the |DomainParticipantFactory::delete_participant-api| member function on the :ref:`dds_layer_domainParticipantFactory` singleton.

Note

A DomainParticipant can only be deleted if all Entities belonging to the participant (Publisher, Subscriber or Topic) have already been deleted. Otherwise, the function will issue an error and the DomainParticipant will not be deleted. This can be performed by using the |DomainParticipant::delete_contained_entities-api| member function of the :ref:`dds_layer_domainParticipant`.

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