Skip to content

Commit 5a88189

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

6 files changed

Lines changed: 86 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: 23 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,26 @@ 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())->
71+
type_object_reader();
7372
}
7473

7574
// If not type object, use the parent method
7675
return rtps::SimpleParticipant::create_reader(topic);
7776
}
7877

79-
void DynTypesParticipant::DynRTPSListener::on_reader_discovery(
78+
DynTypesParticipant::DynTypesRtpsListener::DynTypesRtpsListener(
79+
std::shared_ptr<ParticipantConfiguration> conf,
80+
std::shared_ptr<core::DiscoveryDatabase> ddb,
81+
core::types::ParticipantId id)
82+
: rtps::CommonParticipant::RtpsListener(
83+
conf,
84+
ddb)
85+
, type_object_reader_(std::make_shared<InternalReader>(id))
86+
{
87+
}
88+
89+
void DynTypesParticipant::DynTypesRtpsListener::on_reader_discovery(
8090
fastdds::rtps::RTPSParticipant* participant,
8191
fastdds::rtps::ReaderDiscoveryStatus reason,
8292
const fastdds::rtps::SubscriptionBuiltinTopicData& info,
@@ -88,13 +98,13 @@ void DynTypesParticipant::DynRTPSListener::on_reader_discovery(
8898
const auto type_info = info.type_information.type_information;
8999
const auto type_name = info.type_name.to_string();
90100

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

93103
notify_type_discovered_(type_info, type_name);
94104
}
95105
}
96106

97-
void DynTypesParticipant::DynRTPSListener::on_writer_discovery(
107+
void DynTypesParticipant::DynTypesRtpsListener::on_writer_discovery(
98108
fastdds::rtps::RTPSParticipant* participant,
99109
fastdds::rtps::WriterDiscoveryStatus reason,
100110
const fastdds::rtps::PublicationBuiltinTopicData& info,
@@ -106,13 +116,13 @@ void DynTypesParticipant::DynRTPSListener::on_writer_discovery(
106116
const auto type_info = info.type_information.type_information;
107117
const auto type_name = info.type_name.to_string();
108118

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

111121
notify_type_discovered_(type_info, type_name);
112122
}
113123
}
114124

115-
void DynTypesParticipant::DynRTPSListener::notify_type_discovered_(
125+
void DynTypesParticipant::DynTypesRtpsListener::notify_type_discovered_(
116126
const fastdds::dds::xtypes::TypeInformation& type_info,
117127
const std::string& type_name)
118128
{
@@ -166,6 +176,11 @@ void DynTypesParticipant::DynRTPSListener::notify_type_discovered_(
166176
type_object_reader_->simulate_data_reception(std::move(data));
167177
}
168178

179+
std::unique_ptr<fastdds::rtps::RTPSParticipantListener> DynTypesParticipant::create_listener_()
180+
{
181+
return std::make_unique<DynTypesRtpsListener>(configuration_, discovery_database_, id());
182+
}
183+
169184
} /* namespace participants */
170185
} /* namespace ddspipe */
171186
} /* 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)