RTI Connext Modern C++ API
Version 7.3.0
Participant Use Cases
Programming How-To's
Working with domain participants.
Working with domain participants.
Turning off auto-enable of newly created participant(s)
Change the value of the
ENTITY_FACTORY
for the DomainParticipantFactory
The following #includes are needed for the examples on this page
#include <dds/domain/ddsdomain.hpp>
Setting up a DomainParticipant
How to create DomainParticipants with each of the available constructors
// Creating a DomainParticipants on domain 0, with default Qos, and no
// listener
dds::domain::DomainParticipant
participant1(0) ;
// Creating a DomainParticipants with a non-default QoS values
dds::domain::qos::DomainParticipantQos
qos;
// Set the initial peers.
// The peers stored in initial_peers are merely potential peers--there is
// no requirement that the peer DomainParticipants are actually up and
// running or even will eventually exist. The Connext discovery process
// will try to contact all potential peer participants in the list
// periodically using unicast transports.
const
char
* initial_peers_array[] = {
"host1"
,
"10.10.30.192"
,
"1@localhost"
,
"2@host2"
,
"my://"
,
/* all unicast addrs on transport plugins with alias "my" */
"2@shmem://"
,
/* shared memory */
"FF00:ABCD::0"
,
"1@FF00:0:1234::0"
,
"225.1.2.3"
,
"3@225.1.0.55"
,
"FAA0::0#0/0/R"
};
const
dds::core::StringSeq
initial_peers_list(initial_peers_array, initial_peers_array+11);
// Add the initial peers list to the DiscoveryQosPolicy while modifying
// the participant's qos inline
qos <<
rti::core::policy::Discovery
().
initial_peers
(initial_peers_list);
// Creating a DomainParticipants on domain 1 with modified QoS
dds::domain::DomainParticipant
participant2(1, qos);
// Creating a DomainParticipants on domain 2, with modified QoS, and a
// listener
auto
listener = std::make_shared<ExampleParticipantListener>();
dds::domain::DomainParticipant
participant3(2, qos, listener);
// Creating a DomainParticipants on domain 3, with modified QoS, a listener
// and a data_available() status mask
dds::domain::DomainParticipant
participant4(
3,
qos,
listener,
dds::core::status::StatusMask::data_available
());
dds::core::status::StatusMask::data_available
static const StatusMask data_available()
One or more new data samples have been received.
Definition:
State.hpp:269
dds::domain::DomainParticipant
<<reference-type>> Container for all dds::core::Entity objects.
Definition:
TDomainParticipant.hpp:63
dds::domain::qos::DomainParticipantQos
<<value-type>> Container of the QoS policies that a dds::domain::DomainParticipant supports
Definition:
DomainParticipantQosImpl.hpp:75
rti::core::policy::Discovery
<<extension>> Configures entity discovery
Definition:
rti/core/policy/CorePolicy.hpp:2530
rti::core::policy::Discovery::initial_peers
Discovery & initial_peers(const dds::core::StringSeq &the_initial_peers)
Sets the initial list of peers that the discovery mechanism will contact to announce this DomainParti...
dds::core::StringSeq
std::vector< std::string > StringSeq
A vector of strings.
Definition:
dds/core/types.hpp:59
Setting the DomainParticipantFactoryQos so that participants are created disabled (optional)
dds::domain::qos::DomainParticipantFactoryQos
qos;
qos <<
dds::core::policy::EntityFactory::ManuallyEnable
();
dds::domain::DomainParticipant::participant_factory_qos
(qos);
dds::core::policy::EntityFactory::ManuallyEnable
static TEntityFactory ManuallyEnable()
Creates EntityFactory(false)
Definition:
TCorePolicy.hpp:966
dds::domain::DomainParticipant::participant_factory_qos
static dds::domain::qos::DomainParticipantFactoryQos participant_factory_qos()
Get the current dds::domain::qos::DomainParticipantFactoryQos.
Definition:
TDomainParticipant.hpp:379
dds::domain::qos::DomainParticipantFactoryQos
<<value-type>> Container of the QoS policies that do not apply to a specific entity
Definition:
DomainParticipantFactoryQosImpl.hpp:55
Looking up DomainParticipants
Lookup DomainParticipants by domain id
// Create and retain two DomainParticipants on domain 0 and one on domain 1
create_and_retain_participant(0);
create_and_retain_participant(0);
create_and_retain_participant(1);
// We don't have any references to the created DomainParticipants but we
// can look them up using the domain id they were created on
// If there is more than one participant on the same domain then this
// operation will return only one of them. It is unspecified which one it
// will return
dds::domain::DomainParticipant
participant1 =
dds::domain::find
(0);
dds::domain::DomainParticipant
participant2 =
dds::domain::find
(1);
dds::domain::find
DomainParticipant find(int32_t domain_id)
Locates an existing dds::domain::DomainParticipant.
Tearing down a Participant
See
Tearing Down An Entity
for eamples of the various ways to teardown a Participant
Finalizing the factory
Finalizing the factory
// The DomainParticipantFactory is a singleton that the C++ API uses
// implicitly to create participants. RTI Connext provides
// dds::domain::DomainParticipant::finalize_participant_factory()
// for users who want to release memory used by the participant factory.
dds::domain::DomainParticipant::finalize_participant_factory
();
dds::domain::DomainParticipant::finalize_participant_factory
static void finalize_participant_factory()
Finalize the DomainParticipantFactory.
Definition:
TDomainParticipant.hpp:396