Skip to content

Commit

Permalink
Refs #20160: Removed overloaded discovery methods.
Browse files Browse the repository at this point in the history
Signed-off-by: adriancampo <adriancampo@eprosima.com>
  • Loading branch information
adriancampo committed Mar 6, 2024
1 parent 21f9203 commit e03974e
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 126 deletions.
34 changes: 0 additions & 34 deletions include/fastdds/dds/domain/DomainParticipantListener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,6 @@ class DomainParticipantListener :
*
* @param[out] participant Pointer to the Participant which discovered the remote DataReader.
* @param[out] info Remote DataReader information. User can take ownership of the object.
*/
virtual void on_data_reader_discovery(
DomainParticipant* participant,
fastrtps::rtps::ReaderDiscoveryInfo&& info)
{
static_cast<void>(participant);
static_cast<void>(info);
}

/*!
* This method is called when a new DataReader is discovered, or a previously discovered DataReader changes
* its QOS or is removed.
*
* @warning Not Supported. This callback will never be called in the current version.
*
* @param[out] participant Pointer to the Participant which discovered the remote DataReader.
* @param[out] info Remote DataReader information. User can take ownership of the object.
* @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataReader.
*/
virtual void on_data_reader_discovery(
Expand All @@ -135,23 +118,6 @@ class DomainParticipantListener :
*
* @param[out] participant Pointer to the Participant which discovered the remote DataWriter.
* @param[out] info Remote DataWriter information. User can take ownership of the object.
*/
virtual void on_data_writer_discovery(
DomainParticipant* participant,
fastrtps::rtps::WriterDiscoveryInfo&& info)
{
static_cast<void>(participant);
static_cast<void>(info);
}

/*!
* This method is called when a new DataWriter is discovered, or a previously discovered DataWriter changes
* its QOS or is removed.
*
* @warning Not Supported. This callback will never be called in the current version.
*
* @param[out] participant Pointer to the Participant which discovered the remote DataWriter.
* @param[out] info Remote DataWriter information. User can take ownership of the object.
* @param[out] should_be_ignored Flag to indicate the library to automatically ignore the discovered DataWriter.
*/
virtual void on_data_writer_discovery(
Expand Down
79 changes: 3 additions & 76 deletions src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,6 @@ bool TypeLookupManager::remove_async_get_type_request(

bool TypeLookupManager::create_endpoints()
{
bool ret = true;

const RTPSParticipantAttributes& pattr = participant_->getRTPSParticipantAttributes();

// Built-in history attributes.
Expand Down Expand Up @@ -519,10 +517,7 @@ bool TypeLookupManager::create_endpoints()
request_listener_ = new TypeLookupRequestListener(this);

// Built-in request writer
request_listener_ = new TypeLookupRequestListener(this);
builtin_request_writer_history_ = new WriterHistory(hatt);
request_wlistener_ = new TypeLookupRequestWListener(this);

RTPSWriter* req_writer;
if (participant_->createWriter(
&req_writer,
Expand All @@ -540,41 +535,13 @@ bool TypeLookupManager::create_endpoints()
EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup request writer creation failed.");
delete builtin_request_writer_history_;
builtin_request_writer_history_ = nullptr;
delete request_wlistener_;
request_wlistener_ = nullptr;
return false;
}

// Built-in reply writer
reply_listener_ = new TypeLookupReplyListener(this);
builtin_reply_writer_history_ = new WriterHistory(hatt);
reply_wlistener_ = new TypeLookupReplyWListener(this);

RTPSWriter* rep_writer;
if (participant_->createWriter(
&rep_writer,
watt,
builtin_reply_writer_history_,
reply_listener_,
fastrtps::rtps::c_EntityId_TypeLookup_reply_writer,
true))
{
builtin_reply_writer_ = dynamic_cast<StatefulWriter*>(rep_writer);
EPROSIMA_LOG_INFO(TYPELOOKUP_SERVICE, "Builtin Typelookup reply writer created.");
}
else
{
EPROSIMA_LOG_ERROR(TYPELOOKUP_SERVICE, "Typelookup reply writer creation failed.");
delete builtin_reply_writer_history_;
builtin_reply_writer_history_ = nullptr;
delete reply_wlistener_;
reply_wlistener_ = nullptr;
delete request_listener_;
request_listener_ = nullptr;
return false;
}

// Built-in request reader
builtin_request_reader_history_ = new ReaderHistory(hatt);

RTPSReader* req_reader;
if (participant_->createReader(
&req_reader,
Expand All @@ -597,7 +564,6 @@ bool TypeLookupManager::create_endpoints()
return false;
}

// Built-in reply reader
reply_listener_ = new TypeLookupReplyListener(this);

// Built-in reply writer
Expand Down Expand Up @@ -648,46 +614,7 @@ bool TypeLookupManager::create_endpoints()
return false;
}

// Clean up if something failed.
if (!ret)
{
if (nullptr != builtin_request_writer_history_)
{
delete builtin_request_writer_history_;
builtin_request_writer_history_ = nullptr;
}

if (nullptr != builtin_reply_writer_history_)
{
delete builtin_reply_writer_history_;
builtin_reply_writer_history_ = nullptr;
}

if (nullptr != builtin_request_reader_history_)
{
delete builtin_request_reader_history_;
builtin_request_reader_history_ = nullptr;
}

if (nullptr != builtin_reply_reader_history_)
{
delete builtin_reply_reader_history_;
builtin_reply_reader_history_ = nullptr;
}

if (nullptr != request_listener_)
{
delete request_listener_;
request_listener_ = nullptr;
}
if (nullptr != reply_listener_)
{
delete reply_listener_;
reply_listener_ = nullptr;
}
}

return ret;
return true;
}

TypeLookup_Request* TypeLookupManager::create_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,6 @@ class TypeLookupManager

//! Collection of all SampleIdentity and the TypeIdentfierWithSize it originated from, hashed by its SampleIdentity.
std::unordered_map<SampleIdentity, xtypes::TypeIdentfierWithSize> async_get_type_requests_;

void request_cache_change_acked(
fastrtps::rtps::CacheChange_t* change);

void reply_cache_change_acked(
fastrtps::rtps::CacheChange_t* change);
};

} /* namespace builtin */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

#include <fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <fastdds/dds/log/Log.hpp>

#include <fastdds/builtin/type_lookup_service/TypeLookupManager.hpp>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/RTPSDomainImpl.hpp>

Expand Down
8 changes: 6 additions & 2 deletions src/cpp/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,9 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onReaderDiscovery(
Sentry sentinel(this);
if (sentinel)
{
participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info));
bool should_be_ignored = false;
participant_->listener_->on_data_reader_discovery(participant_->participant_, std::move(info),
should_be_ignored);
}
}

Expand All @@ -1543,7 +1545,9 @@ void DomainParticipantImpl::MyRTPSParticipantListener::onWriterDiscovery(
Sentry sentinel(this);
if (sentinel)
{
participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info));
bool should_be_ignored = false;
participant_->listener_->on_data_writer_discovery(participant_->participant_, std::move(info),
should_be_ignored);
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/blackbox/api/dds-pim/PubSubReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class PubSubReader

void on_data_writer_discovery(
eprosima::fastdds::dds::DomainParticipant*,
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
if (reader_.onEndpointDiscovery_ != nullptr)
{
Expand Down
6 changes: 4 additions & 2 deletions test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class PubSubWriter

void on_data_reader_discovery(
eprosima::fastdds::dds::DomainParticipant*,
eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override
eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
if (info.status == eprosima::fastrtps::rtps::ReaderDiscoveryInfo::DISCOVERED_READER)
{
Expand All @@ -141,7 +142,8 @@ class PubSubWriter

void on_data_writer_discovery(
eprosima::fastdds::dds::DomainParticipant*,
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
if (info.status == eprosima::fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER)
{
Expand Down
6 changes: 4 additions & 2 deletions test/blackbox/api/dds-pim/PubSubWriterReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class PubSubWriterReader

void on_data_reader_discovery(
eprosima::fastdds::dds::DomainParticipant* participant,
eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info) override
eprosima::fastrtps::rtps::ReaderDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
(void)participant;

Expand All @@ -131,7 +132,8 @@ class PubSubWriterReader

void on_data_writer_discovery(
eprosima::fastdds::dds::DomainParticipant* participant,
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info) override
eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
(void)participant;

Expand Down
3 changes: 2 additions & 1 deletion test/unittest/dds/publisher/DataWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ TEST(DataWriterTests, get_guid)

void on_data_writer_discovery(
DomainParticipant*,
fastrtps::rtps::WriterDiscoveryInfo&& info) override
fastrtps::rtps::WriterDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
std::unique_lock<std::mutex> lock(mutex);
if (fastrtps::rtps::WriterDiscoveryInfo::DISCOVERED_WRITER == info.status)
Expand Down
3 changes: 2 additions & 1 deletion test/unittest/dds/subscriber/DataReaderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ TEST_F(DataReaderTests, get_guid)

void on_data_reader_discovery(
DomainParticipant*,
ReaderDiscoveryInfo&& info) override
ReaderDiscoveryInfo&& info,
bool& /*should_be_ignored*/) override
{
std::unique_lock<std::mutex> lock(mutex);
if (ReaderDiscoveryInfo::DISCOVERED_READER == info.status)
Expand Down

0 comments on commit e03974e

Please sign in to comment.