13.1.2.1. DomainParticipant

class eprosima::fastdds::dds::DomainParticipant : public eprosima::fastdds::dds::Entity

Class DomainParticipant used to group Publishers and Subscribers into a single working unit.

Public Functions

ReturnCode_t get_qos(DomainParticipantQos &qos) const

This operation returns the value of the DomainParticipant QoS policies

Return

RETCODE_OK

Parameters

const DomainParticipantQos &get_qos() const

This operation returns the value of the DomainParticipant QoS policies.

Return

A reference to the DomainParticipantQos

ReturnCode_t enable() override

This operation enables the DomainParticipant.

Return

RETCODE_OK

ReturnCode_t set_qos(const DomainParticipantQos &qos) const

This operation sets the value of the DomainParticipant QoS policies.

Return

RETCODE_IMMUTABLE_POLICY if any of the Qos cannot be changed, RETCODE_INCONSISTENT_POLICY if the Qos is not self consistent and RETCODE_OK if the qos is changed correctly.

Parameters

ReturnCode_t set_listener(DomainParticipantListener *listener)

Modifies the DomainParticipantListener, sets the mask to StatusMask::all()

Return

RETCODE_OK

Parameters

ReturnCode_t set_listener(DomainParticipantListener *listener, const StatusMask &mask)

Modifies the DomainParticipantListener.

Return

RETCODE_OK

Parameters

const DomainParticipantListener *get_listener() const

Allows accessing the DomainParticipantListener.

Return

DomainParticipantListener pointer

Publisher *create_publisher(const PublisherQos &qos, PublisherListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Publisher in this Participant.

Return

Pointer to the created Publisher.

Parameters
  • qos: QoS of the Publisher.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

Publisher *create_publisher_with_profile(const std::string &profile_name, PublisherListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Publisher in this Participant.

Return

Pointer to the created Publisher.

Parameters
  • profile_name: Publisher profile name.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

ReturnCode_t delete_publisher(Publisher *publisher)

Deletes an existing Publisher.

Return

RETCODE_PRECONDITION_NOT_MET if the publisher does not belong to this participant or if it has active DataWriters, RETCODE_OK if it is correctly deleted and RETCODE_ERROR otherwise.

Parameters
  • publisher: to be deleted.

Subscriber *create_subscriber(const SubscriberQos &qos, SubscriberListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Subscriber in this Participant.

Return

Pointer to the created Subscriber.

Parameters
  • qos: QoS of the Subscriber.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

Subscriber *create_subscriber_with_profile(const std::string &profile_name, SubscriberListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Subscriber in this Participant.

Return

Pointer to the created Subscriber.

Parameters
  • profile_name: Subscriber profile name.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

ReturnCode_t delete_subscriber(Subscriber *subscriber)

Deletes an existing Subscriber.

Return

RETCODE_PRECONDITION_NOT_MET if the subscriber does not belong to this participant or if it has active DataReaders, RETCODE_OK if it is correctly deleted and RETCODE_ERROR otherwise.

Parameters
  • subscriber: to be deleted.

ReturnCode_t register_type(TypeSupport type, const std::string &type_name)

Register a type in this participant.

Return

RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there is another TypeSupport with the same name and RETCODE_OK if it is correctly registered.

Parameters
  • type: TypeSupport.

  • type_name: The name that will be used to identify the Type.

ReturnCode_t register_type(TypeSupport type)

Register a type in this participant.

Return

RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there is another TypeSupport with the same name and RETCODE_OK if it is correctly registered.

Parameters

ReturnCode_t unregister_type(const std::string &typeName)

Unregister a type in this participant.

Return

RETCODE_BAD_PARAMETER if the size of the name is 0, RERCODE_PRECONDITION_NOT_MET if there are entities using that TypeSupport and RETCODE_OK if it is correctly unregistered.

Parameters
  • typeName: Name of the type

Topic *create_topic(const std::string &topic_name, const std::string &type_name, const TopicQos &qos, TopicListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Topic in this Participant.

Return

Pointer to the created Topic.

Parameters
  • topic_name: Name of the Topic.

  • type_name: Data type of the Topic.

  • qos: QoS of the Topic.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

Topic *create_topic_with_profile(const std::string &topic_name, const std::string &type_name, const std::string &profile_name, TopicListener *listener = nullptr, const StatusMask &mask = StatusMask::all())

Create a Topic in this Participant.

Return

Pointer to the created Topic.

Parameters
  • topic_name: Name of the Topic.

  • type_name: Data type of the Topic.

  • profile_name: Topic profile name.

  • listener: Pointer to the listener (default: nullptr)

  • mask: StatusMask that holds statuses the listener responds to (default: all)

ReturnCode_t delete_topic(Topic *topic)

Deletes an existing Topic.

Return

RETCODE_BAD_PARAMETER if the topic passed is a nullptr, RETCODE_PRECONDITION_NOT_MET if the topic does not belong to this participant or if it is referenced by any entity and ETCODE_OK if the Topic was deleted.

Parameters
  • topic: to be deleted.

TopicDescription *lookup_topicdescription(const std::string &topic_name) const

Looks up an existing, locally created TopicDescription, based on its name. May be called on a disabled participant.

Return

Pointer to the topic description, if it has been created locally. Otherwise, nullptr is returned.

Remark

UNSAFE. It is unsafe to lookup a topic description while another thread is creating a topic.

Parameters

DomainId_t get_domain_id() const

This operation retrieves the domain_id used to create the DomainParticipant. The domain_id identifies the DDS domain to which the DomainParticipant belongs.

Return

The Participant’s domain_id

ReturnCode_t assert_liveliness()

This operation manually asserts the liveliness of the DomainParticipant. This is used in combination with the LIVELINESS QoS policy to indicate to the Service that the entity remains active.

This operation needs to only be used if the DomainParticipant contains DataWriter entities with the LIVELINESS set to MANUAL_BY_PARTICIPANT and it only affects the liveliness of those DataWriter entities. Otherwise, it has no effect.

Note

Writing data via the write operation on a DataWriter asserts liveliness on the DataWriter itself and its DomainParticipant. Consequently the use of assert_liveliness is only needed if the application is not writing data regularly.

Return

RETCODE_OK if the liveliness was asserted, RETCODE_ERROR otherwise.

ReturnCode_t set_default_publisher_qos(const PublisherQos &qos)

This operation sets a default value of the Publisher QoS policies which will be used for newly created Publisher entities in the case where the QoS policies are defaulted in the create_publisher operation.

This operation will check that the resulting policies are self consistent; if they are not, the operation will have no effect and return false.

The special value PUBLISHER_QOS_DEFAULT may be passed to this operation to indicate that the default QoS should be reset back to the initial values the factory would use, that is the values that would be used if the set_default_publisher_qos operation had never been called.

Return

RETCODE_INCONSISTENT_POLICY if the Qos is not self consistent and RETCODE_OK if the qos is changed correctly.

Parameters

const PublisherQos &get_default_publisher_qos() const

This operation retrieves the default value of the Publisher QoS, that is, the QoS policies which will be used for newly created Publisher entities in the case where the QoS policies are defaulted in the create_publisher operation.

The values retrieved get_default_publisher_qos will match the set of values specified on the last successful call to set_default_publisher_qos, or else, if the call was never made, the default values.

Return

Current default publisher qos.

ReturnCode_t get_default_publisher_qos(PublisherQos &qos) const

This operation retrieves the default value of the Publisher QoS, that is, the QoS policies which will be used for newly created Publisher entities in the case where the QoS policies are defaulted in the create_publisher operation.

The values retrieved get_default_publisher_qos will match the set of values specified on the last successful call to set_default_publisher_qos, or else, if the call was never made, the default values.

Return

RETCODE_OK

Parameters
  • qos: PublisherQos reference where the default_publisher_qos is returned

ReturnCode_t set_default_subscriber_qos(const SubscriberQos &qos)

This operation sets a default value of the Subscriber QoS policies that will be used for newly created Subscriber entities in the case where the QoS policies are defaulted in the create_subscriber operation.

This operation will check that the resulting policies are self consistent; if they are not, the operation will have no effect and return false.

The special value SUBSCRIBER_QOS_DEFAULT may be passed to this operation to indicate that the default QoS should be reset back to the initial values the factory would use, that is the values that would be used if the set_default_subscriber_qos operation had never been called.

Return

RETCODE_INCONSISTENT_POLICY if the Qos is not self consistent and RETCODE_OK if the qos is changed correctly.

Parameters

const SubscriberQos &get_default_subscriber_qos() const

This operation retrieves the default value of the Subscriber QoS, that is, the QoS policies which will be used for newly created Subscriber entities in the case where the QoS policies are defaulted in the create_subscriber operation.

The values retrieved get_default_subscriber_qos will match the set of values specified on the last successful call to set_default_subscriber_qos, or else, if the call was never made, the default values.

Return

Current default subscriber qos.

ReturnCode_t get_default_subscriber_qos(SubscriberQos &qos) const

This operation retrieves the default value of the Subscriber QoS, that is, the QoS policies which will be used for newly created Subscriber entities in the case where the QoS policies are defaulted in the create_subscriber operation.

The values retrieved get_default_subscriber_qos will match the set of values specified on the last successful call to set_default_subscriber_qos, or else, if the call was never made, the default values.

Return

RETCODE_OK

Parameters
  • qos: SubscriberQos reference where the default_subscriber_qos is returned

ReturnCode_t set_default_topic_qos(const TopicQos &qos)

This operation sets a default value of the Topic QoS policies which will be used for newly created Topic entities in the case where the QoS policies are defaulted in the create_topic operation.

This operation will check that the resulting policies are self consistent; if they are not, the operation will have no effect and return INCONSISTENT_POLICY.

The special value TOPIC_QOS_DEFAULT may be passed to this operation to indicate that the default QoS should be reset back to the initial values the factory would use, that is the values that would be used if the set_default_topic_qos operation had never been called.

Return

RETCODE_INCONSISTENT_POLICY if the Qos is not self consistent and RETCODE_OK if the qos is changed correctly.

Parameters

const TopicQos &get_default_topic_qos() const

This operation retrieves the default value of the Topic QoS, that is, the QoS policies that will be used for newly created Topic entities in the case where the QoS policies are defaulted in the create_topic operation.

The values retrieved get_default_topic_qos will match the set of values specified on the last successful call to set_default_topic_qos, or else, TOPIC_QOS_DEFAULT if the call was never made.

Return

Current default topic qos.

ReturnCode_t get_default_topic_qos(TopicQos &qos) const

This operation retrieves the default value of the Topic QoS, that is, the QoS policies that will be used for newly created Topic entities in the case where the QoS policies are defaulted in the create_topic operation.

The values retrieved get_default_topic_qos will match the set of values specified on the last successful call to set_default_topic_qos, or else, TOPIC_QOS_DEFAULT if the call was never made.

Return

RETCODE_OK

Parameters
  • qos: TopicQos reference where the default_topic_qos is returned

bool contains_entity(const fastrtps::rtps::InstanceHandle_t &handle, bool recursive = true) const

This operation checks whether or not the given handle represents an Entity that was created from the DomainParticipant.

Return

True if entity is contained. False otherwise.

Parameters

ReturnCode_t get_current_time(fastrtps::Time_t &current_time) const

This operation returns the current value of the time that the service uses to time-stamp data-writes and to set the reception-timestamp for the data-updates it receives.

Return

RETCODE_OK

Parameters
  • current_time: Time_t reference where the current time is returned

TypeSupport find_type(const std::string &type_name) const

This method gives access to a registered type based on its name.

Return

TypeSupport corresponding to the type_name

Parameters
  • type_name: Name of the type

const fastrtps::rtps::InstanceHandle_t &get_instance_handle() const

Returns the DomainParticipant’s handle.

Return

InstanceHandle of this DomainParticipant.

const fastrtps::rtps::GUID_t &guid() const

Getter for the Participant GUID.

Return

A reference to the GUID

std::vector<std::string> get_participant_names() const

Getter for the participant names.

Return

Vector with the names

bool new_remote_endpoint_discovered(const fastrtps::rtps::GUID_t &partguid, uint16_t userId, fastrtps::rtps::EndpointKind_t kind)

This method can be used when using a StaticEndpointDiscovery mechanism different that the one included in FastRTPS, for example when communicating with other implementations. It indicates the Participant that an Endpoint from the XML has been discovered and should be activated.

Return

True if correctly found and activated.

Parameters
  • partguid: Participant GUID_t.

  • userId: User defined ID as shown in the XML file.

  • kind: EndpointKind (WRITER or READER)

fastrtps::rtps::ResourceEvent &get_resource_event() const

Getter for the resource event.

Return

A reference to the resource event

fastrtps::rtps::SampleIdentity get_type_dependencies(const fastrtps::types::TypeIdentifierSeq &in) const

When a DomainParticipant receives an incomplete list of TypeIdentifiers in a PublicationBuiltinTopicData or SubscriptionBuiltinTopicData, it may request the additional type dependencies by invoking the getTypeDependencies operation.

Return

SampleIdentity

Parameters
  • in: TypeIdentifier sequence

fastrtps::rtps::SampleIdentity get_types(const fastrtps::types::TypeIdentifierSeq &in) const

A DomainParticipant may invoke the operation getTypes to retrieve the TypeObjects associated with a list of TypeIdentifiers.

Return

SampleIdentity

Parameters
  • in: TypeIdentifier sequence

ReturnCode_t register_remote_type(const fastrtps::types::TypeInformation &type_information, const std::string &type_name, std::function<void(const std::string &name, const fastrtps::types::DynamicType_ptr type)> &callback)

Helps the user to solve all dependencies calling internally to the typelookup service and registers the resulting dynamic type. The registration will be perform asynchronously and the user will be notified through the given callback, which receives the type_name as unique argument. If the type is already registered, the function will return true, but the callback will not be called. If the given type_information is enough to build the type without using the typelookup service, it will return true and the callback will be never called.

Return

true if type is already available (callback will not be called). false if type isn’t available yet (the callback will be called if negotiation is success, and ignored in other case).

Parameters
  • type_information:

  • type_name:

  • callback:

~DomainParticipant()

Destructor.

bool has_active_entities()

Check if the Participant has any Publisher, Subscriber or Topic.

Return

true if any, false otherwise.