@@ -94,18 +94,15 @@ std::shared_ptr<IReader> DynTypesParticipant::create_reader(
9494 return rtps::SimpleParticipant::create_reader (topic);
9595}
9696
97- DynTypesParticipant::DynTypesRtpsListener::DynTypesRtpsListener (
98- std::shared_ptr<ParticipantConfiguration> conf,
99- std::shared_ptr<core::DiscoveryDatabase> ddb,
100- std::shared_ptr<InternalReader> internal_reader)
101- : rtps::CommonParticipant::RtpsListener(
102- conf,
103- ddb)
104- , type_object_reader_(internal_reader)
97+ DynTypesParticipant::DynTypesDdsListener::DynTypesDdsListener (
98+ std::shared_ptr<InternalReader> type_object_reader,
99+ core::types::ParticipantId participant_id)
100+ : type_object_reader_(type_object_reader)
101+ , participant_id_(participant_id)
105102{
106103}
107104
108- void DynTypesParticipant::DynTypesRtpsListener ::on_type_discovery (
105+ void DynTypesParticipant::DynTypesDdsListener ::on_type_discovery (
109106 eprosima::fastdds::dds::DomainParticipant* /* participant */ ,
110107 const fastrtps::rtps::SampleIdentity& /* request_sample_id */ ,
111108 const fastrtps::string_255& /* topic */ ,
@@ -122,7 +119,7 @@ void DynTypesParticipant::DynTypesRtpsListener::on_type_discovery(
122119 }
123120}
124121
125- void DynTypesParticipant::DynTypesRtpsListener ::on_type_information_received (
122+ void DynTypesParticipant::DynTypesDdsListener ::on_type_information_received (
126123 eprosima::fastdds::dds::DomainParticipant* participant,
127124 const fastrtps::string_255 /* topic_name */ ,
128125 const fastrtps::string_255 type_name,
@@ -177,11 +174,11 @@ void DynTypesParticipant::DynTypesRtpsListener::on_type_information_received(
177174 }
178175}
179176
180- void DynTypesParticipant::DynTypesRtpsListener ::internal_notify_type_object_ (
177+ void DynTypesParticipant::DynTypesDdsListener ::internal_notify_type_object_ (
181178 DynamicType_ptr dynamic_type)
182179{
183180 logInfo (DDSPIPE_DYNTYPES_PARTICIPANT ,
184- " Participant " << configuration_-> id << " discovered type object " << dynamic_type->get_name ());
181+ " Participant " << participant_id_ << " discovered type object " << dynamic_type->get_name ());
185182
186183 monitor_type_discovered (dynamic_type->get_name ());
187184
@@ -295,9 +292,9 @@ void DynTypesParticipant::initialize_internal_dds_participant_()
295292 configuration->domain ,
296293 pqos);
297294
298- // Note that this listeners also inherits from DomainParticipantListener
299- dds_participant_-> set_listener (
300- dynamic_cast <fastdds::dds::DomainParticipantListener*>(rtps_participant_listener_ .get () ));
295+ // Create the DDS listener and set it in the participant
296+ dds_participant_listener_ = create_dds_listener_ ();
297+ dds_participant_-> set_listener (dds_participant_listener_ .get ());
301298
302299 dds_participant_->enable ();
303300
@@ -313,9 +310,11 @@ void DynTypesParticipant::initialize_internal_dds_participant_()
313310 }
314311}
315312
316- std::unique_ptr<fastrtps::rtps::RTPSParticipantListener > DynTypesParticipant::create_listener_ ()
313+ std::unique_ptr<fastdds::dds::DomainParticipantListener > DynTypesParticipant::create_dds_listener_ ()
317314{
318- return std::make_unique<DynTypesRtpsListener>(configuration_, discovery_database_, type_object_reader_);
315+ // Note that when the DDS listener is created, the RTPS participant is already created and enabled.
316+ // Therefore, we can access to the RTPS participant GUID prefix safely.
317+ return std::make_unique<DynTypesDdsListener>(type_object_reader_, configuration_->id );
319318}
320319
321320} /* namespace participants */
0 commit comments