Skip to content

Commit

Permalink
Remove RTPSParticipant listener overloaded callbaks (#4872)
Browse files Browse the repository at this point in the history
* Refs #21097. Remove `onParticipantDiscovery` overload.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21097. Remove `onReaderDiscovery` and `onWriterDiscovery` overloads.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
MiguelCompany authored Jun 3, 2024
1 parent 15ffc4b commit 9902979
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 79 deletions.
53 changes: 5 additions & 48 deletions include/fastdds/rtps/participant/RTPSParticipantListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ class FASTDDS_EXPORTED_API RTPSParticipantListener
{
}

/*!
* This method is called when a new Participant is discovered, or a previously discovered participant changes
* its QOS or is removed.
*
* @param[out] participant Pointer to the Participant which discovered the remote participant.
* @param[out] info Remote participant information. User can take ownership of the object.
*/
virtual void onParticipantDiscovery(
RTPSParticipant* participant,
ParticipantDiscoveryInfo&& info)
{
static_cast<void>(participant);
static_cast<void>(info);
}

/*!
* This method is called when a new Participant is discovered, or a previously discovered participant changes
* its QOS or is removed.
Expand All @@ -74,7 +59,9 @@ class FASTDDS_EXPORTED_API RTPSParticipantListener
ParticipantDiscoveryInfo&& info,
bool& should_be_ignored)
{
onParticipantDiscovery(participant, std::move(info));
static_cast<void>(participant);
static_cast<void>(info);

should_be_ignored = false;
}

Expand All @@ -89,21 +76,6 @@ class FASTDDS_EXPORTED_API RTPSParticipantListener

#endif // if HAVE_SECURITY

/*!
* This method is called when a new Reader is discovered, or a previously discovered reader changes
* its QOS or is removed.
*
* @param[out] participant Pointer to the Participant which discovered the remote reader.
* @param[out] info Remote reader information. User can take ownership of the object.
*/
virtual void onReaderDiscovery(
RTPSParticipant* participant,
ReaderDiscoveryInfo&& info)
{
static_cast<void>(participant);
static_cast<void>(info);
}

/*!
* This method is called when a new Reader is discovered, or a previously discovered reader changes
* its QOS or is removed.
Expand All @@ -119,22 +91,7 @@ class FASTDDS_EXPORTED_API RTPSParticipantListener
{
static_cast<void>(participant);
static_cast<void>(info);
static_cast<void>(should_be_ignored);
}

/*!
* This method is called when a new Writer is discovered, or a previously discovered writer changes
* its QOS or is removed.
*
* @param[out] participant Pointer to the Participant which discovered the remote writer.
* @param[out] info Remote writer information. User can take ownership of the object.
*/
virtual void onWriterDiscovery(
RTPSParticipant* participant,
WriterDiscoveryInfo&& info)
{
static_cast<void>(participant);
static_cast<void>(info);
should_be_ignored = false;
}

/*!
Expand All @@ -152,7 +109,7 @@ class FASTDDS_EXPORTED_API RTPSParticipantListener
{
static_cast<void>(participant);
static_cast<void>(info);
static_cast<void>(should_be_ignored);
should_be_ignored = false;
}

};
Expand Down
26 changes: 18 additions & 8 deletions src/cpp/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,27 +1558,37 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onParticipantAuthenticati

void DomainParticipantImpl::MyRTPSParticipantListener::onReaderDiscovery(
RTPSParticipant*,
ReaderDiscoveryInfo&& info)
ReaderDiscoveryInfo&& info,
bool& should_be_ignored)
{
should_be_ignored = false;

Sentry sentinel(this);
if (sentinel)
{
bool should_be_ignored = false;
participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info),
should_be_ignored);
DomainParticipantListener* listener = participant_->listener_;
if (nullptr != listener)
{
listener->on_data_reader_discovery(participant_->participant_, std::move(info), should_be_ignored);
}
}
}

void DomainParticipantImpl::MyRTPSParticipantListener::onWriterDiscovery(
RTPSParticipant*,
WriterDiscoveryInfo&& info)
WriterDiscoveryInfo&& info,
bool& should_be_ignored)
{
should_be_ignored = false;

Sentry sentinel(this);
if (sentinel)
{
bool should_be_ignored = false;
participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info),
should_be_ignored);
DomainParticipantListener* listener = participant_->listener_;
if (nullptr != listener)
{
listener->on_data_writer_discovery(participant_->participant_, std::move(info), should_be_ignored);
}
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/cpp/fastdds/domain/DomainParticipantImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,6 @@ class DomainParticipantImpl
bool on_guard_;
};

using fastrtps::rtps::RTPSParticipantListener::onParticipantDiscovery;
using fastrtps::rtps::RTPSParticipantListener::onReaderDiscovery;
using fastrtps::rtps::RTPSParticipantListener::onWriterDiscovery;

public:

MyRTPSParticipantListener(
Expand All @@ -654,11 +650,13 @@ class DomainParticipantImpl

void onReaderDiscovery(
fastrtps::rtps::RTPSParticipant* participant,
fastrtps::rtps::ReaderDiscoveryInfo&& info) override;
fastrtps::rtps::ReaderDiscoveryInfo&& info,
bool& should_be_ignored) override;

void onWriterDiscovery(
fastrtps::rtps::RTPSParticipant* participant,
fastrtps::rtps::WriterDiscoveryInfo&& info) override;
fastrtps::rtps::WriterDiscoveryInfo&& info,
bool& should_be_ignored) override;

DomainParticipantImpl* participant_;
int callback_counter_ = 0;
Expand Down
32 changes: 24 additions & 8 deletions src/cpp/rtps/builtin/discovery/participant/PDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,11 @@ bool PDP::removeReaderProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
ReaderDiscoveryInfo info(std::move(*pR));
bool should_be_ignored = false;
info.status = ReaderDiscoveryInfo::REMOVED_READER;
listener->onReaderDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onReaderDiscovery(participant, std::move(info), should_be_ignored);
}

// Clear reader proxy data and move to pool in order to allow reuse
Expand Down Expand Up @@ -749,9 +751,11 @@ bool PDP::removeWriterProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
WriterDiscoveryInfo info(std::move(*pW));
bool should_be_ignored = false;
info.status = WriterDiscoveryInfo::REMOVED_WRITER;
listener->onWriterDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onWriterDiscovery(participant, std::move(info), should_be_ignored);
}

// Clear writer proxy data and move to pool in order to allow reuse
Expand Down Expand Up @@ -841,9 +845,11 @@ ReaderProxyData* PDP::addReaderProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
ReaderDiscoveryInfo info(*ret_val);
bool should_be_ignored = false;
info.status = ReaderDiscoveryInfo::CHANGED_QOS_READER;
listener->onReaderDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onReaderDiscovery(participant, std::move(info), should_be_ignored);
}

return ret_val;
Expand Down Expand Up @@ -891,9 +897,11 @@ ReaderProxyData* PDP::addReaderProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
ReaderDiscoveryInfo info(*ret_val);
bool should_be_ignored = false;
info.status = ReaderDiscoveryInfo::DISCOVERED_READER;
listener->onReaderDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onReaderDiscovery(participant, std::move(info), should_be_ignored);
}

return ret_val;
Expand Down Expand Up @@ -938,9 +946,11 @@ WriterProxyData* PDP::addWriterProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
WriterDiscoveryInfo info(*ret_val);
bool should_be_ignored = false;
info.status = WriterDiscoveryInfo::CHANGED_QOS_WRITER;
listener->onWriterDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onWriterDiscovery(participant, std::move(info), should_be_ignored);
}

return ret_val;
Expand Down Expand Up @@ -987,9 +997,11 @@ WriterProxyData* PDP::addWriterProxyData(
RTPSParticipantListener* listener = mp_RTPSParticipant->getListener();
if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
WriterDiscoveryInfo info(*ret_val);
bool should_be_ignored = false;
info.status = WriterDiscoveryInfo::DISCOVERED_WRITER;
listener->onWriterDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onWriterDiscovery(participant, std::move(info), should_be_ignored);
}

return ret_val;
Expand Down Expand Up @@ -1198,9 +1210,11 @@ void PDP::actions_on_remote_participant_removed(

if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
ReaderDiscoveryInfo info(std::move(*rit));
bool should_be_ignored = false;
info.status = ReaderDiscoveryInfo::REMOVED_READER;
listener->onReaderDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onReaderDiscovery(participant, std::move(info), should_be_ignored);
}
}
}
Expand All @@ -1215,9 +1229,11 @@ void PDP::actions_on_remote_participant_removed(

if (listener)
{
RTPSParticipant* participant = mp_RTPSParticipant->getUserRTPSParticipant();
WriterDiscoveryInfo info(std::move(*wit));
bool should_be_ignored = false;
info.status = WriterDiscoveryInfo::REMOVED_WRITER;
listener->onWriterDiscovery(mp_RTPSParticipant->getUserRTPSParticipant(), std::move(info));
listener->onWriterDiscovery(participant, std::move(info), should_be_ignored);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ class MockParticipantListener : public RTPSParticipantListener
{
public:

void onParticipantDiscovery(
RTPSParticipant* participant,
ParticipantDiscoveryInfo&& info) override
{
onParticipantDiscovery_mock(participant, info);
}

MOCK_METHOD2(onParticipantDiscovery_mock, void (RTPSParticipant*, const ParticipantDiscoveryInfo&));

void onParticipantDiscovery(
RTPSParticipant* participant,
ParticipantDiscoveryInfo&& info,
Expand Down

0 comments on commit 9902979

Please sign in to comment.