CoreDX DDS Modern C++ API
DomainParticipant Use Cases

Create a Participant

Exploring the numerous DomainParticipant constructors:

DomainParticipant with all default QoS policies, no listener, on domain '0'.

#include <dds/domain/ddsdomain.hpp>

Creating a DomainParticipant that is not enabled automatically.

#include <dds/domain/ddsdomain.hpp>
/* turn off DomainParticipantFactory autoenable */
dds::domain::DomainParticipant participant( 0 ); // 'not-enabled'

DomainParticipant with modified QoS policies, no listener, on domain '0'.

DomainParticipant with modified QoS policies, and a listener, on domain '0'.

#include <dds/domain/ddsdomain.hpp>
class ExampleDpListener : public dds::domain::NoOpDomainParticipantListener { ... };
dds::domain::DomainParticipantListener * dpListener = new ExampleDpListener;

Lookup a Participant

To find an existing DomainParticipant use the dds::domain::find() operation.

#include <dds/domain/ddsdomain.hpp>
{
participant.retain(); // make this participant persist beyond the scope
}
dds::domain::DomainParticipant dp = dds::domain::find( 0 );

Use a Participant

#include <dds/domain/ddsdomain.hpp>
uint32_t domain_id = participant.domain_id(); // query for the domain id
dds::domain::DomainParticpiantListener * listener = participant.listener() // access the listener
participant.assert_liveliness(); // assert liveliness of the participant
dds::core::Time now = participant.current_time(); // query for current time

Destroy a Participant

To clean up a DomainParticipant, simply let the last reference go out of scope.

#include <dds/domain/ddsdomain.hpp>
{
// 'participant' is the only reference, so the participant is destroyed as the scope exits
}

A 'retained' participant persists beyond the scope of its reference[s]. To destroy it, obtain a reference and call 'close':

#include <dds/domain/ddsdomain.hpp>
{
participant.retain(); // make this participant persist beyond the scope
}
dds::domain::DomainParticipant dp = dds::domain::find( 0 );
dp.close();

© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.