Skip to content

Commit 6d773c9

Browse files
committed
Refs #21670: Apply Review
Signed-off-by: cferreiragonz <carlosferreira@eprosima.com>
1 parent d2459fc commit 6d773c9

6 files changed

Lines changed: 85 additions & 60 deletions

File tree

ddspipe_participants/include/ddspipe_participants/participant/dds/CommonParticipant.hpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ class CommonParticipant : public core::IParticipant
118118

119119
explicit DDSListener(
120120
std::shared_ptr<SimpleParticipantConfiguration> conf,
121-
std::shared_ptr<core::DiscoveryDatabase> ddb)
122-
: configuration_(conf)
123-
, discovery_database_(ddb)
124-
{
125-
}
121+
std::shared_ptr<core::DiscoveryDatabase> ddb);
126122

127123
/**
128124
* @brief Override method from \c DomainParticipantListener
@@ -164,7 +160,7 @@ class CommonParticipant : public core::IParticipant
164160
void guid(
165161
const fastdds::rtps::GUID_t& guid);
166162

167-
private:
163+
protected:
168164

169165
//! GUID of the participant
170166
fastdds::rtps::GUID_t guid_;
@@ -190,6 +186,17 @@ class CommonParticipant : public core::IParticipant
190186
const std::shared_ptr<core::PayloadPool>& payload_pool,
191187
const std::shared_ptr<core::DiscoveryDatabase>& discovery_database);
192188

189+
/////////////////////////
190+
// VIRTUAL METHODS
191+
/////////////////////////
192+
193+
/**
194+
* @brief Virtual method that creates a listener for the internal DDS Participant.
195+
* It should be overridden if a different listener is needed.
196+
*/
197+
DDSPIPE_PARTICIPANTS_DllAPI
198+
virtual std::unique_ptr<fastdds::dds::DomainParticipantListener> create_listener_();
199+
193200
/////////////////////////
194201
// INTERNAL VIRTUAL METHODS
195202
/////////////////////////
@@ -207,15 +214,6 @@ class CommonParticipant : public core::IParticipant
207214
fastdds::dds::DomainParticipant*
208215
create_dds_participant_();
209216

210-
/**
211-
* @brief Virtual method that creates a listener for the internal DDS Participant.
212-
* It should be overridden if a different listener is needed.
213-
*/
214-
virtual std::unique_ptr<fastdds::dds::DomainParticipantListener> create_listener()
215-
{
216-
return std::make_unique<DDSListener>(configuration_, discovery_database_);
217-
}
218-
219217
/////////////////////////
220218
// INTERNAL METHODS
221219
/////////////////////////

ddspipe_participants/include/ddspipe_participants/participant/dynamic_types/DynTypesParticipant.hpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,15 @@ class DynTypesParticipant : public rtps::SimpleParticipant
7474
std::shared_ptr<core::IReader> create_reader(
7575
const core::ITopic& topic) override;
7676

77-
class DynRTPSListener : public rtps::CommonParticipant::RTPSListener
77+
class DynTypesRtpsListener : public rtps::CommonParticipant::RtpsListener
7878
{
7979
public:
8080

81-
explicit DynRTPSListener(
81+
DDSPIPE_PARTICIPANTS_DllAPI
82+
explicit DynTypesRtpsListener(
8283
std::shared_ptr<ParticipantConfiguration> conf,
8384
std::shared_ptr<core::DiscoveryDatabase> ddb,
84-
std::shared_ptr<InternalReader> type_object_reader_,
85-
std::set<std::string> received_types_)
86-
: rtps::CommonParticipant::RTPSListener(conf, ddb)
87-
, type_object_reader_(type_object_reader_)
88-
, received_types_(received_types_)
89-
{
90-
}
85+
core::types::ParticipantId id);
9186

9287
DDSPIPE_PARTICIPANTS_DllAPI
9388
void on_reader_discovery(
@@ -103,7 +98,13 @@ class DynTypesParticipant : public rtps::SimpleParticipant
10398
const fastdds::rtps::PublicationBuiltinTopicData& info,
10499
bool& should_be_ignored) override;
105100

106-
private:
101+
//! Type Object Reader getter
102+
inline std::shared_ptr<InternalReader> type_object_reader() const
103+
{
104+
return type_object_reader_;
105+
}
106+
107+
protected:
107108

108109
//! Type Object Internal Reader
109110
std::shared_ptr<InternalReader> type_object_reader_;
@@ -119,17 +120,7 @@ class DynTypesParticipant : public rtps::SimpleParticipant
119120
protected:
120121

121122
//! Override method from \c CommonParticipant to create the internal RTPS participant listener
122-
std::unique_ptr<fastdds::rtps::RTPSParticipantListener> create_listener() override
123-
{
124-
return std::make_unique<DynRTPSListener>(configuration_, discovery_database_, type_object_reader_,
125-
received_types_);
126-
}
127-
128-
//! Type Object Internal Reader
129-
std::shared_ptr<InternalReader> type_object_reader_;
130-
131-
//! Received types set
132-
std::set<std::string> received_types_;
123+
std::unique_ptr<fastdds::rtps::RTPSParticipantListener> create_listener_() override;
133124
};
134125

135126
} /* namespace participants */

ddspipe_participants/include/ddspipe_participants/participant/rtps/CommonParticipant.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,14 @@ class CommonParticipant
122122
// RTPS LISTENER METHODS
123123
/////////////////////////
124124

125-
class RTPSListener : public fastdds::rtps::RTPSParticipantListener
125+
class RtpsListener : public fastdds::rtps::RTPSParticipantListener
126126
{
127127
public:
128128

129-
explicit RTPSListener(
129+
DDSPIPE_PARTICIPANTS_DllAPI
130+
explicit RtpsListener(
130131
std::shared_ptr<ParticipantConfiguration> conf,
131-
std::shared_ptr<core::DiscoveryDatabase> ddb)
132-
: configuration_(conf)
133-
, discovery_database_(ddb)
134-
{
135-
}
132+
std::shared_ptr<core::DiscoveryDatabase> ddb);
136133

137134
/**
138135
* @brief Override method from \c RTPSParticipantListener .
@@ -250,10 +247,8 @@ class CommonParticipant
250247
* This method must be called after the RTPS Participant is created, otherwise no listener will be set.
251248
* @return A unique pointer to an RTPS Participant Listener.
252249
*/
253-
virtual std::unique_ptr<fastdds::rtps::RTPSParticipantListener> create_listener()
254-
{
255-
return std::make_unique<RTPSListener>(configuration_, discovery_database_);
256-
}
250+
DDSPIPE_PARTICIPANTS_DllAPI
251+
virtual std::unique_ptr<fastdds::rtps::RTPSParticipantListener> create_listener_();
257252

258253
/////
259254
// VARIABLES

ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ CommonParticipant::~CommonParticipant()
5454
}
5555
}
5656

57+
std::unique_ptr<fastdds::dds::DomainParticipantListener> CommonParticipant::create_listener_()
58+
{
59+
return std::make_unique<DDSListener>(configuration_, discovery_database_);
60+
}
61+
5762
void CommonParticipant::init()
5863
{
5964
EPROSIMA_LOG_INFO(DDSPIPE_DDS_PARTICIPANT, "Initializing DDS Participant " << id() << ".");
@@ -214,6 +219,14 @@ std::shared_ptr<core::IReader> CommonParticipant::create_reader(
214219
}
215220
}
216221

222+
CommonParticipant::DDSListener::DDSListener(
223+
std::shared_ptr<SimpleParticipantConfiguration> conf,
224+
std::shared_ptr<core::DiscoveryDatabase> ddb)
225+
: configuration_(conf)
226+
, discovery_database_(ddb)
227+
{
228+
}
229+
217230
void CommonParticipant::DDSListener::on_participant_discovery(
218231
fastdds::dds::DomainParticipant* participant,
219232
fastdds::rtps::ParticipantDiscoveryStatus reason,
@@ -414,7 +427,7 @@ fastdds::dds::DomainParticipant* CommonParticipant::create_dds_participant_()
414427
mask << fastdds::dds::StatusMask::subscription_matched();
415428

416429
// Create the participant listener
417-
dds_participant_listener_ = create_listener();
430+
dds_participant_listener_ = create_listener_();
418431

419432
return eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(
420433
configuration_->domain,

ddspipe_participants/src/cpp/participant/dynamic_types/DynTypesParticipant.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ DynTypesParticipant::DynTypesParticipant(
5050
participant_configuration,
5151
payload_pool,
5252
discovery_database)
53-
, type_object_reader_(std::make_shared<InternalReader>(
54-
this->id()))
5553
{
5654
// Do nothing
5755
}
@@ -69,14 +67,25 @@ std::shared_ptr<IReader> DynTypesParticipant::create_reader(
6967
// If type object topic, return the internal reader for type objects
7068
if (core::types::is_type_object_topic(topic))
7169
{
72-
return this->type_object_reader_;
70+
return static_cast<DynTypesParticipant::DynTypesRtpsListener*>(rtps_participant_listener_.get())->type_object_reader();
7371
}
7472

7573
// If not type object, use the parent method
7674
return rtps::SimpleParticipant::create_reader(topic);
7775
}
7876

79-
void DynTypesParticipant::DynRTPSListener::on_reader_discovery(
77+
DynTypesParticipant::DynTypesRtpsListener::DynTypesRtpsListener(
78+
std::shared_ptr<ParticipantConfiguration> conf,
79+
std::shared_ptr<core::DiscoveryDatabase> ddb,
80+
core::types::ParticipantId id)
81+
: rtps::CommonParticipant::RtpsListener(
82+
conf,
83+
ddb)
84+
, type_object_reader_(std::make_shared<InternalReader>(id))
85+
{
86+
}
87+
88+
void DynTypesParticipant::DynTypesRtpsListener::on_reader_discovery(
8089
fastdds::rtps::RTPSParticipant* participant,
8190
fastdds::rtps::ReaderDiscoveryStatus reason,
8291
const fastdds::rtps::SubscriptionBuiltinTopicData& info,
@@ -88,13 +97,13 @@ void DynTypesParticipant::DynRTPSListener::on_reader_discovery(
8897
const auto type_info = info.type_information.type_information;
8998
const auto type_name = info.type_name.to_string();
9099

91-
rtps::CommonParticipant::RTPSListener::on_reader_discovery(participant, reason, info, should_be_ignored);
100+
rtps::CommonParticipant::RtpsListener::on_reader_discovery(participant, reason, info, should_be_ignored);
92101

93102
notify_type_discovered_(type_info, type_name);
94103
}
95104
}
96105

97-
void DynTypesParticipant::DynRTPSListener::on_writer_discovery(
106+
void DynTypesParticipant::DynTypesRtpsListener::on_writer_discovery(
98107
fastdds::rtps::RTPSParticipant* participant,
99108
fastdds::rtps::WriterDiscoveryStatus reason,
100109
const fastdds::rtps::PublicationBuiltinTopicData& info,
@@ -106,13 +115,13 @@ void DynTypesParticipant::DynRTPSListener::on_writer_discovery(
106115
const auto type_info = info.type_information.type_information;
107116
const auto type_name = info.type_name.to_string();
108117

109-
rtps::CommonParticipant::RTPSListener::on_writer_discovery(participant, reason, info, should_be_ignored);
118+
rtps::CommonParticipant::RtpsListener::on_writer_discovery(participant, reason, info, should_be_ignored);
110119

111120
notify_type_discovered_(type_info, type_name);
112121
}
113122
}
114123

115-
void DynTypesParticipant::DynRTPSListener::notify_type_discovered_(
124+
void DynTypesParticipant::DynTypesRtpsListener::notify_type_discovered_(
116125
const fastdds::dds::xtypes::TypeInformation& type_info,
117126
const std::string& type_name)
118127
{
@@ -166,6 +175,11 @@ void DynTypesParticipant::DynRTPSListener::notify_type_discovered_(
166175
type_object_reader_->simulate_data_reception(std::move(data));
167176
}
168177

178+
std::unique_ptr<fastdds::rtps::RTPSParticipantListener> DynTypesParticipant::create_listener_()
179+
{
180+
return std::make_unique<DynTypesRtpsListener>(configuration_, discovery_database_, id());
181+
}
182+
169183
} /* namespace participants */
170184
} /* namespace ddspipe */
171185
} /* namespace eprosima */

ddspipe_participants/src/cpp/participant/rtps/CommonParticipant.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ void CommonParticipant::init()
7979
participant_attributes_);
8080
}
8181

82-
void CommonParticipant::RTPSListener::on_participant_discovery(
82+
CommonParticipant::RtpsListener::RtpsListener(
83+
std::shared_ptr<ParticipantConfiguration> conf,
84+
std::shared_ptr<core::DiscoveryDatabase> ddb)
85+
: configuration_(conf)
86+
, discovery_database_(ddb)
87+
{
88+
}
89+
90+
void CommonParticipant::RtpsListener::on_participant_discovery(
8391
fastdds::rtps::RTPSParticipant* participant,
8492
fastdds::rtps::ParticipantDiscoveryStatus reason,
8593
const fastdds::rtps::ParticipantBuiltinTopicData& info,
@@ -116,7 +124,7 @@ void CommonParticipant::RTPSListener::on_participant_discovery(
116124
}
117125
}
118126

119-
void CommonParticipant::RTPSListener::on_reader_discovery(
127+
void CommonParticipant::RtpsListener::on_reader_discovery(
120128
fastdds::rtps::RTPSParticipant* participant,
121129
fastdds::rtps::ReaderDiscoveryStatus reason,
122130
const fastdds::rtps::SubscriptionBuiltinTopicData& info,
@@ -161,7 +169,7 @@ void CommonParticipant::RTPSListener::on_reader_discovery(
161169
}
162170
}
163171

164-
void CommonParticipant::RTPSListener::on_writer_discovery(
172+
void CommonParticipant::RtpsListener::on_writer_discovery(
165173
fastdds::rtps::RTPSParticipant* participant,
166174
fastdds::rtps::WriterDiscoveryStatus reason,
167175
const fastdds::rtps::PublicationBuiltinTopicData& info,
@@ -327,7 +335,7 @@ void CommonParticipant::create_participant_(
327335
"Creating Participant in domain " << domain);
328336

329337
// Create the RTPS Participant Listener
330-
rtps_participant_listener_ = create_listener();
338+
rtps_participant_listener_ = create_listener_();
331339

332340
// Listener must be set in creation as no callbacks should be missed
333341
// It is safe to do so here as object is already created and callbacks do not require anything set in this method
@@ -503,6 +511,12 @@ CommonParticipant::reckon_participant_attributes_() const
503511
return params;
504512
}
505513

514+
std::unique_ptr<fastdds::rtps::RTPSParticipantListener>
515+
CommonParticipant::create_listener_()
516+
{
517+
return std::make_unique<RtpsListener>(configuration_, discovery_database_);
518+
}
519+
506520
} /* namespace rtps */
507521
} /* namespace participants */
508522
} /* namespace ddspipe */

0 commit comments

Comments
 (0)