From 205685ca660856d82a3ec0cacfb0bedf169d21b2 Mon Sep 17 00:00:00 2001 From: juanlofer-eprosima <88179026+juanlofer-eprosima@users.noreply.github.com> Date: Thu, 19 Dec 2024 12:56:29 +0100 Subject: [PATCH] Ignore ignored participants and endpoints (#113) * Ignore ignored participants and endpoints Signed-off-by: Juan Lopez Fernandez * Piggyback: remove redundant method Signed-off-by: Juan Lopez Fernandez --------- Signed-off-by: Juan Lopez Fernandez --- .../participant/SpyDdsParticipant.hpp | 3 --- .../src/cpp/participant/SpyDdsParticipant.cpp | 26 +++++-------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp index 6effe30b..06ffc5ed 100644 --- a/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp +++ b/fastddsspy_participants/include/fastddsspy_participants/participant/SpyDdsParticipant.hpp @@ -83,9 +83,6 @@ class SpyDdsParticipant : public ddspipe::participants::DynTypesParticipant void internal_notify_endpoint_discovered_( const EndpointInfo& endpoint_discovered); - bool come_from_this_participant_( - const ddspipe::core::types::Guid& guid) const noexcept; - //! Participants Internal Reader std::shared_ptr participants_reader_; diff --git a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp index bc9f77f6..0ad1abbc 100644 --- a/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp +++ b/fastddsspy_participants/src/cpp/participant/SpyDdsParticipant.cpp @@ -61,7 +61,7 @@ void SpyDdsParticipant::on_participant_discovery( bool& should_be_ignored) { // If comes from this participant is not interesting - if (come_from_this_participant_(info.guid)) + if (ddspipe::participants::detail::come_from_same_participant_(info.guid, rtps_participant_->getGuid())) { return; } @@ -85,15 +85,14 @@ void SpyDdsParticipant::on_reader_discovery( bool& should_be_ignored) { // If comes from this participant is not interesting - if (come_from_this_participant_(info.guid)) + if (ddspipe::participants::detail::come_from_same_participant_(info.guid, rtps_participant_->getGuid())) { return; } EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); - - // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(reason == fastdds::rtps::ReaderDiscoveryStatus::REMOVED_READER); + endpoint_info.active = (reason == fastdds::rtps::ReaderDiscoveryStatus::DISCOVERED_READER + || reason == fastdds::rtps::ReaderDiscoveryStatus::CHANGED_QOS_READER); ddspipe::participants::DynTypesParticipant::on_reader_discovery(participant, reason, info, should_be_ignored); @@ -107,15 +106,14 @@ void SpyDdsParticipant::on_writer_discovery( bool& should_be_ignored) { // If comes from this participant is not interesting - if (come_from_this_participant_(info.guid)) + if (ddspipe::participants::detail::come_from_same_participant_(info.guid, rtps_participant_->getGuid())) { return; } EndpointInfo endpoint_info = ddspipe::participants::detail::create_endpoint_from_info_(info, id()); - - // If participant left or dropped, this notification arrives as well - endpoint_info.active = !(reason == fastdds::rtps::WriterDiscoveryStatus::REMOVED_WRITER); + endpoint_info.active = (reason == fastdds::rtps::WriterDiscoveryStatus::DISCOVERED_WRITER + || reason == fastdds::rtps::WriterDiscoveryStatus::CHANGED_QOS_WRITER); ddspipe::participants::DynTypesParticipant::on_writer_discovery(participant, reason, info, should_be_ignored); @@ -144,16 +142,6 @@ void SpyDdsParticipant::internal_notify_endpoint_discovered_( endpoints_reader_->simulate_data_reception(std::move(data)); } -/* - * NOTE: this function is required apart from come_from_same_participant_ - * because this participant has 2 guids, the rtps and the dds participant ones - */ -bool SpyDdsParticipant::come_from_this_participant_( - const ddspipe::core::types::Guid& guid) const noexcept -{ - return (guid.guid_prefix() == rtps_participant_->getGuid().guidPrefix); -} - } /* namespace participants */ } /* namespace spy */ } /* namespace eprosima */