Skip to content

Commit 0e6e96b

Browse files
Documentation for should_endpoints_match callback (#1238)
* Add documentation for custom endpoint matching logic Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> * Apply review Co-authored-by: Miguel Company <miguelcompany@eprosima.com> Signed-off-by: Emilio Cuesta Fernandez <emiliocuesta@eprosima.com> --------- Signed-off-by: Emilio Cuesta <emiliocuesta@eprosima.com> Signed-off-by: Emilio Cuesta Fernandez <emiliocuesta@eprosima.com> Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
1 parent cda8f42 commit 0e6e96b

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

code/DDSCodeTester.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@ class CustomDomainParticipantListener : public DomainParticipantListener
289289
}
290290
}
291291

292+
bool should_endpoints_match(
293+
const DomainParticipant* participant,
294+
const eprosima::fastdds::rtps::SubscriptionBuiltinTopicData& reader_info,
295+
const eprosima::fastdds::dds::PublicationBuiltinTopicData& writer_info) override
296+
{
297+
static_cast<void>(participant);
298+
// For example, only allow matching between endpoints belonging to different participants.
299+
// This prevents intra-participant communication while still allowing
300+
// cross-participant communication for endpoints that pass standard QoS checks.
301+
return reader_info.participant_guid.guidPrefix != writer_info.participant_guid.guidPrefix;
302+
}
303+
292304
};
293305
//!--
294306

docs/03-exports/aliases-api.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
.. |DomainParticipantListener::on_data_reader_discovery-api| replace:: :cpp:func:`on_data_reader_discovery()<eprosima::fastdds::dds::DomainParticipantListener::on_data_reader_discovery>`
206206
.. |DomainParticipantListener::on_data_writer_discovery-api| replace:: :cpp:func:`on_data_writer_discovery()<eprosima::fastdds::dds::DomainParticipantListener::on_data_writer_discovery>`
207207
.. |DomainParticipantListener::onParticipantAuthentication-api| replace:: :cpp:func:`onParticipantAuthentication()<eprosima::fastdds::dds::DomainParticipantListener::onParticipantAuthentication>`
208+
.. |DomainParticipantListener::should_endpoints_match-api| replace:: :cpp:func:`should_endpoints_match()<eprosima::fastdds::dds::DomainParticipantListener::should_endpoints_match>`
208209

209210
.. |DomainParticipantQos-api| replace:: :cpp:class:`DomainParticipantQos<eprosima::fastdds::dds::DomainParticipantQos>`
210211
.. |DomainParticipantQos::allocation-api| replace:: :cpp:func:`allocation()<eprosima::fastdds::dds::DomainParticipantQos::allocation>`

docs/fastdds/dds_layer/domain/domainParticipantListener/domainParticipantListener.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ Additionally, DomainParticipantListener adds the following non-standard callback
4848
* |DomainParticipantListener::onParticipantAuthentication-api|: Informs about the result of the authentication process
4949
of a remote DomainParticipant (either on failure or success).
5050

51+
* |DomainParticipantListener::should_endpoints_match-api|: Called after standard QoS matching rules have been
52+
evaluated for a pair of endpoints (a :ref:`dds_layer_subscriber_dataReader` and a
53+
:ref:`dds_layer_publisher_dataWriter` on the same topic with compatible QoS).
54+
It allows the application to apply custom matching logic as an additional filter on top of the standard rules.
55+
The callback receives the |DomainParticipant-api| calling the listener, a
56+
``SubscriptionBuiltinTopicData`` with the reader information, and a ``PublicationBuiltinTopicData`` with the
57+
writer information.
58+
Returning ``true`` allows the match to proceed; returning ``false`` prevents it.
59+
The default implementation always returns ``true``.
60+
5161
.. important::
5262

5363
For more information about callbacks and its hierarchy, please refer to

0 commit comments

Comments
 (0)