18.1.2.1. DomainParticipant

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

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

Subclassed by eprosima::fastdds::statistics::dds::DomainParticipant

Public Functions

virtual ~DomainParticipant()

Destructor.

ReturnCode_t get_qos(DomainParticipantQos &qos) const

This operation returns the value of the DomainParticipant QoS policies

Parameters

qosDomainParticipantQos reference where the qos is going to be returned

Returns

RETCODE_OK

const DomainParticipantQos &get_qos() const

This operation returns the value of the DomainParticipant QoS policies.

Returns

A reference to the DomainParticipantQos

ReturnCode_t set_qos(const DomainParticipantQos &qos) const

This operation sets the value of the DomainParticipant QoS policies.

Parameters

qosDomainParticipantQos to be set

Returns

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.

const DomainParticipantListener *get_listener() const

Allows accessing the DomainParticipantListener.

Returns

DomainParticipantListener pointer

ReturnCode_t set_listener(DomainParticipantListener *listener)

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

Warning

Do not call this method from a DomainParticipantListener callback.

Parameters

listener – New value for the DomainParticipantListener

Returns

RETCODE_OK if successful, RETCODE_ERROR otherwise.

ReturnCode_t set_listener(DomainParticipantListener *listener, const std::chrono::seconds timeout)

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

Warning

Do not call this method from a DomainParticipantListener callback.

Parameters
  • listener – New value for the DomainParticipantListener

  • timeout – Maximum time to wait for executing callbacks to finish.

Returns

RETCODE_OK if successful, RETCODE_ERROR if failed (timeout expired).

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

Modifies the DomainParticipantListener.

Warning

Do not call this method from a DomainParticipantListener callback.

Parameters
Returns

RETCODE_OK if successful, RETCODE_ERROR otherwise.

ReturnCode_t set_listener(DomainParticipantListener *listener, const StatusMask &mask, const std::chrono::seconds timeout)

Modifies the DomainParticipantListener.

Warning

Do not call this method from a DomainParticipantListener callback.

Parameters
  • listener – New value for the DomainParticipantListener

  • maskStatusMask that holds statuses the listener responds to

  • timeout – Maximum time to wait for executing callbacks to finish.

Returns

RETCODE_OK if successful, RETCODE_ERROR if failed (timeout expired)

virtual ReturnCode_t enable() override

This operation enables the DomainParticipant.

Returns

RETCODE_OK

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

Create a Publisher in this Participant.

Parameters
  • qos – QoS of the Publisher.

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

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

Returns

Pointer to the created Publisher.

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

Create a Publisher in this Participant.

Parameters
  • profile_namePublisher profile name.

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

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

Returns

Pointer to the created Publisher.

ReturnCode_t delete_publisher(const Publisher *publisher)

Deletes an existing Publisher.

Parameters

publisher – to be deleted.

Returns

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.

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

Create a Subscriber in this Participant.

Parameters
  • qos – QoS of the Subscriber.

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

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

Returns

Pointer to the created Subscriber.

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

Create a Subscriber in this Participant.

Parameters
  • profile_nameSubscriber profile name.

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

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

Returns

Pointer to the created Subscriber.

ReturnCode_t delete_subscriber(const Subscriber *subscriber)

Deletes an existing Subscriber.

Parameters

subscriber – to be deleted.

Returns

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.

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.

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)

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

Returns

Pointer to the created Topic.

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.

Parameters
  • topic_name – Name of the Topic.

  • type_name – Data type of the Topic.

  • profile_nameTopic profile name.

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

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

Returns

Pointer to the created Topic.

ReturnCode_t delete_topic(const Topic *topic)

Deletes an existing Topic.

Parameters

topic – to be deleted.

Returns

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 RETCODE_OK if the Topic was deleted.

ContentFilteredTopic *create_contentfilteredtopic(const std::string &name, Topic *related_topic, const std::string &filter_expression, const std::vector<std::string> &expression_parameters)

Create a ContentFilteredTopic in this Participant.

Parameters
  • name – Name of the ContentFilteredTopic

  • related_topic – Related Topic to being subscribed

  • filter_expression – Logic expression to create filter

  • expression_parameters – Parameters to filter content

Returns

Pointer to the created ContentFilteredTopic.

Returns

nullptr if related_topic does not belong to this participant.

Returns

nullptr if a topic with the specified name has already been created.

Returns

nullptr if a filter cannot be created with the specified filter_expression and expression_parameters.

ContentFilteredTopic *create_contentfilteredtopic(const std::string &name, Topic *related_topic, const std::string &filter_expression, const std::vector<std::string> &expression_parameters, const char *filter_class_name)

Create a ContentFilteredTopic in this Participant using a custom filter.

Parameters
  • name – Name of the ContentFilteredTopic

  • related_topic – Related Topic to being subscribed

  • filter_expression – Logic expression to create filter

  • expression_parameters – Parameters to filter content

  • filter_class_name – Name of the filter class to use

Returns

Pointer to the created ContentFilteredTopic.

Returns

nullptr if related_topic does not belong to this participant.

Returns

nullptr if a topic with the specified name has already been created.

Returns

nullptr if a filter cannot be created with the specified filter_expression and expression_parameters.

Returns

nullptr if the specified filter_class_name has not been registered.

ReturnCode_t delete_contentfilteredtopic(const ContentFilteredTopic *a_contentfilteredtopic)

Deletes an existing ContentFilteredTopic.

Parameters

a_contentfilteredtopicContentFilteredTopic to be deleted

Returns

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 RETCODE_OK if the ContentFilteredTopic was deleted.

MultiTopic *create_multitopic(const std::string &name, const std::string &type_name, const std::string &subscription_expression, const std::vector<std::string> &expression_parameters)

Create a MultiTopic in this Participant.

Parameters
  • name – Name of the MultiTopic

  • type_name – Result type of the MultiTopic

  • subscription_expression – Logic expression to combine filter

  • expression_parameters – Parameters to subscription content

Returns

Pointer to the created ContentFilteredTopic, nullptr in error case

ReturnCode_t delete_multitopic(const MultiTopic *a_multitopic)

Deletes an existing MultiTopic.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

a_multitopic – MultiTopic to be deleted

Returns

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 RETCODE_OK if the Topic was deleted.

Topic *find_topic(const std::string &topic_name, const fastrtps::Duration_t &timeout)

Gives access to an existing (or ready to exist) enabled Topic. It should be noted that the returned Topic is a local object that acts as a proxy to designate the global concept of topic. Topics obtained by means of find_topic, must also be deleted by means of delete_topic so that the local resources can be released. If a Topic is obtained multiple times by means of find_topic or create_topic, it must also be deleted that same number of times using delete_topic.

Parameters
  • topic_nameTopic name

  • timeout – Maximum time to wait for the Topic

Returns

Pointer to the existing Topic, nullptr in case of error or timeout

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.

Remark

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

Parameters

topic_name – Name of the TopicDescription to search for.

Returns

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

const Subscriber *get_builtin_subscriber() const

Allows access to the builtin Subscriber.

Returns

Pointer to the builtin Subscriber, nullptr in error case

ReturnCode_t ignore_participant(const InstanceHandle_t &handle)

Locally ignore a remote domain participant.

Note

This action is not reversible.

Parameters

handle – Identifier of the remote participant to ignore

Returns

RETURN_OK code if everything correct, RETCODE_BAD_PARAMENTER otherwise

ReturnCode_t ignore_topic(const InstanceHandle_t &handle)

Locally ignore a topic.

Note

This action is not reversible.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

handle – Identifier of the topic to ignore

Returns

RETURN_OK code if everything correct, error code otherwise

ReturnCode_t ignore_publication(const InstanceHandle_t &handle)

Locally ignore a remote datawriter.

Note

This action is not reversible.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

handle – Identifier of the datawriter to ignore

Returns

RETURN_OK code if everything correct, error code otherwise

ReturnCode_t ignore_subscription(const InstanceHandle_t &handle)

Locally ignore a remote datareader.

Note

This action is not reversible.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

handle – Identifier of the datareader to ignore

Returns

RETURN_OK code if everything correct, error code otherwise

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.

Returns

The Participant’s domain_id

ReturnCode_t delete_contained_entities()

Deletes all the entities that were created by means of the “create” methods

Returns

RETURN_OK code if everything correct, error code otherwise

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.

Returns

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.

Parameters

qosPublisherQos to be set

Returns

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

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.

Returns

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.

Parameters

qosPublisherQos reference where the default_publisher_qos is returned

Returns

RETCODE_OK

ReturnCode_t get_publisher_qos_from_profile(const std::string &profile_name, PublisherQos &qos) const

Fills the PublisherQos with the values of the XML profile.

Parameters
Returns

RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise.

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.

Parameters

qosSubscriberQos to be set

Returns

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

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.

Returns

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.

Parameters

qosSubscriberQos reference where the default_subscriber_qos is returned

Returns

RETCODE_OK

ReturnCode_t get_subscriber_qos_from_profile(const std::string &profile_name, SubscriberQos &qos) const

Fills the SubscriberQos with the values of the XML profile.

Parameters
Returns

RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise.

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.

Parameters

qosTopicQos to be set

Returns

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

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.

Returns

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.

Parameters

qosTopicQos reference where the default_topic_qos is returned

Returns

RETCODE_OK

ReturnCode_t get_topic_qos_from_profile(const std::string &profile_name, TopicQos &qos) const

Fills the TopicQos with the values of the XML profile.

Parameters
  • profile_nameTopic profile name.

  • qosTopicQos object where the qos is returned.

Returns

RETCODE_OK if the profile exists. RETCODE_BAD_PARAMETER otherwise.

ReturnCode_t get_discovered_participants(std::vector<InstanceHandle_t> &participant_handles) const

Retrieves the list of DomainParticipants that have been discovered in the domain and are not “ignored”.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

participant_handles[out] Reference to the vector where discovered participants will be returned

Returns

RETCODE_OK if everything correct, error code otherwise

ReturnCode_t get_discovered_participant_data(builtin::ParticipantBuiltinTopicData &participant_data, const InstanceHandle_t &participant_handle) const

Retrieves the DomainParticipant data of a discovered not ignored participant.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters
  • participant_data[out] Reference to the ParticipantBuiltinTopicData object to return the data

  • participant_handle – InstanceHandle of DomainParticipant to retrieve the data from

Returns

RETCODE_OK if everything correct, PRECONDITION_NOT_MET if participant does not exist

ReturnCode_t get_discovered_topics(std::vector<InstanceHandle_t> &topic_handles) const

Retrieves the list of topics that have been discovered in the domain and are not “ignored”.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters

topic_handles[out] Reference to the vector where discovered topics will be returned

Returns

RETCODE_OK if everything correct, error code otherwise

ReturnCode_t get_discovered_topic_data(builtin::TopicBuiltinTopicData &topic_data, const InstanceHandle_t &topic_handle) const

Retrieves the Topic data of a discovered not ignored topic.

Warning

Not supported yet. Currently returns RETCODE_UNSUPPORTED

Parameters
  • topic_data[out] Reference to the TopicBuiltinTopicData object to return the data

  • topic_handle – InstanceHandle of Topic to retrieve the data from

Returns

RETCODE_OK if everything correct, PRECONDITION_NOT_MET if topic does not exist

bool contains_entity(const InstanceHandle_t &a_handle, bool recursive = true) const

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

Parameters
Returns

True if entity is contained. False otherwise.

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.

Parameters

current_time – Time_t reference where the current time is returned

Returns

RETCODE_OK

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

Register a type in this participant.

Parameters
  • typeTypeSupport.

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

Returns

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.

ReturnCode_t register_type(TypeSupport type)

Register a type in this participant.

Parameters

typeTypeSupport.

Returns

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.

ReturnCode_t unregister_type(const std::string &typeName)

Unregister a type in this participant.

Parameters

typeName – Name of the type

Returns

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.

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

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

Parameters

type_name – Name of the type

Returns

TypeSupport corresponding to the type_name

const InstanceHandle_t &get_instance_handle() const

Returns the DomainParticipant’s handle.

Returns

InstanceHandle of this DomainParticipant.

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

Getter for the Participant GUID.

Returns

A reference to the GUID

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

Getter for the participant names.

Returns

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.

Parameters
  • partguid – Participant GUID_t.

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

  • kind – EndpointKind (WRITER or READER)

Returns

True if correctly found and activated.

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

Getter for the resource event.

Pre

The DomainParticipant is enabled.

Returns

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.

Parameters

in – TypeIdentifier sequence

Returns

SampleIdentity

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.

Parameters

in – TypeIdentifier sequence

Returns

SampleIdentity

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 type lookup service and registers the resulting dynamic type. The registration may be perform asynchronously, case in which the user will be notified through the given callback, which receives the type_name as unique argument.

Parameters
  • type_information

  • type_name

  • callback

Returns

RETCODE_OK If the given type_information is enough to build the type without using the typelookup service (callback will not be called).

Returns

RETCODE_OK if the given type is already available (callback will not be called).

Returns

RETCODE_NO_DATA if type is not available yet (the callback will be called if negotiation is success, and ignored in other case).

Returns

RETCODE_NOT_ENABLED if the DomainParticipant is not enabled.

Returns

RETCODE_PRECONDITION_NOT_MET if the DomainParticipant type lookup service is disabled.

ReturnCode_t register_content_filter_factory(const char *filter_class_name, IContentFilterFactory *const filter_factory)

Register a custom content filter factory, which can be used to create a ContentFilteredTopic.

DDS specifies a SQL-like content filter to be used by content filtered topics. If this filter does not meet your filtering requirements, you can register a custom filter factory.

To use a custom filter, a factory for it must be registered in the following places:

  • In any application that uses the custom filter factory to create a ContentFilteredTopic and the corresponding DataReader.

  • In each application that writes the data to the applications mentioned above.

For example, suppose Application A on the subscription side creates a Topic named X and a ContentFilteredTopic named filteredX (and a corresponding DataReader), using a previously registered content filter factory, myFilterFactory. With only that, you will have filtering at the subscription side. If you also want to perform filtering in any application that publishes Topic X, then you also need to register the same definition of the ContentFilterFactory myFilterFactory in that application.

Each filter_class_name can only be used to register a content filter factory once per DomainParticipant.

Parameters
  • filter_class_name – Name of the filter class. Cannot be nullptr, must not exceed 255 characters, and must be unique within this DomainParticipant.

  • filter_factory – Factory of content filters to be registered. Cannot be nullptr.

Returns

RETCODE_BAD_PARAMETER if any parameter is nullptr, or the filter_class_name exceeds 255 characters.

Returns

RETCODE_PRECONDITION_NOT_MET if the filter_class_name has been already registered.

Returns

RETCODE_PRECONDITION_NOT_MET if filter_class_name is FASTDDS_SQLFILTER_NAME.

Returns

RETCODE_OK if the filter is correctly registered.

IContentFilterFactory *lookup_content_filter_factory(const char *filter_class_name)

Lookup a custom content filter factory previously registered with register_content_filter_factory.

Parameters

filter_class_name – Name of the filter class. Cannot be nullptr.

Returns

nullptr if the given filter_class_name has not been previously registered on this DomainParticipant. Otherwise, the content filter factory previously registered with the given filter_class_name.

ReturnCode_t unregister_content_filter_factory(const char *filter_class_name)

Unregister a custom content filter factory previously registered with register_content_filter_factory.

A filter_class_name can be unregistered only if it has been previously registered to the DomainParticipant with register_content_filter_factory.

The unregistration of filter is not allowed if there are any existing ContentFilteredTopic objects that are using the filter.

If there is any existing discovered DataReader with the same filter_class_name, filtering on the writer side will be stopped, but this operation will not fail.

Parameters

filter_class_name – Name of the filter class. Cannot be nullptr.

Returns

RETCODE_BAD_PARAMETER if the filter_class_name is nullptr.

Returns

RERCODE_PRECONDITION_NOT_MET if the filter_class_name has not been previously registered.

Returns

RERCODE_PRECONDITION_NOT_MET if there is any ContentFilteredTopic referencing the filter.

Returns

RETCODE_OK if the filter is correctly unregistered.

bool has_active_entities()

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

Returns

true if any, false otherwise.