Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,19 @@ class DynTypesParticipant : public rtps::SimpleParticipant
std::shared_ptr<core::IReader> create_reader(
const core::ITopic& topic) override;

class DynTypesRtpsListener : public rtps::CommonParticipant::RtpsListener,
public eprosima::fastdds::dds::DomainParticipantListener
/**
* @brief This class is the DDS Listener for DynTypesParticipant. It inherits directly from
* \c fastdds::dds::DomainParticipantListener and implements the methods needed to process type objects and
* type lookup services.
*/
class DynTypesDdsListener : public eprosima::fastdds::dds::DomainParticipantListener
{
public:

DDSPIPE_PARTICIPANTS_DllAPI
explicit DynTypesRtpsListener(
std::shared_ptr<ParticipantConfiguration> conf,
std::shared_ptr<core::DiscoveryDatabase> ddb,
std::shared_ptr<InternalReader> internal_reader);
explicit DynTypesDdsListener(
std::shared_ptr<InternalReader> type_object_reader,
core::types::ParticipantId participant_id);

DDSPIPE_PARTICIPANTS_DllAPI
void on_type_discovery(
Expand All @@ -106,6 +109,9 @@ class DynTypesParticipant : public rtps::SimpleParticipant
//! Copy of Type Object Internal Reader
std::shared_ptr<InternalReader> type_object_reader_;

//! Participant ID for informative purposes. It is stored in the CommonParticipant (RTPS)
core::types::ParticipantId participant_id_;

};

protected:
Expand All @@ -114,12 +120,14 @@ class DynTypesParticipant : public rtps::SimpleParticipant

eprosima::fastdds::dds::DomainParticipant* dds_participant_;

std::unique_ptr<eprosima::fastdds::dds::DomainParticipantListener> dds_participant_listener_;

//! Type Object Internal Reader
std::shared_ptr<InternalReader> type_object_reader_;

//! Override method from \c CommonParticipant to create the internal RTPS participant listener
//! Method to create the internal DDS participant listener
DDSPIPE_PARTICIPANTS_DllAPI
std::unique_ptr<fastrtps::rtps::RTPSParticipantListener> create_listener_() override;
virtual std::unique_ptr<fastdds::dds::DomainParticipantListener> create_dds_listener_();

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,15 @@ std::shared_ptr<IReader> DynTypesParticipant::create_reader(
return rtps::SimpleParticipant::create_reader(topic);
}

DynTypesParticipant::DynTypesRtpsListener::DynTypesRtpsListener(
std::shared_ptr<ParticipantConfiguration> conf,
std::shared_ptr<core::DiscoveryDatabase> ddb,
std::shared_ptr<InternalReader> internal_reader)
: rtps::CommonParticipant::RtpsListener(
conf,
ddb)
, type_object_reader_(internal_reader)
DynTypesParticipant::DynTypesDdsListener::DynTypesDdsListener(
std::shared_ptr<InternalReader> type_object_reader,
core::types::ParticipantId participant_id)
: type_object_reader_(type_object_reader)
, participant_id_(participant_id)
{
}

void DynTypesParticipant::DynTypesRtpsListener::on_type_discovery(
void DynTypesParticipant::DynTypesDdsListener::on_type_discovery(
eprosima::fastdds::dds::DomainParticipant* /* participant */,
const fastrtps::rtps::SampleIdentity& /* request_sample_id */,
const fastrtps::string_255& /* topic */,
Expand All @@ -122,7 +119,7 @@ void DynTypesParticipant::DynTypesRtpsListener::on_type_discovery(
}
}

void DynTypesParticipant::DynTypesRtpsListener::on_type_information_received(
void DynTypesParticipant::DynTypesDdsListener::on_type_information_received(
eprosima::fastdds::dds::DomainParticipant* participant,
const fastrtps::string_255 /* topic_name */,
const fastrtps::string_255 type_name,
Expand Down Expand Up @@ -177,11 +174,11 @@ void DynTypesParticipant::DynTypesRtpsListener::on_type_information_received(
}
}

void DynTypesParticipant::DynTypesRtpsListener::internal_notify_type_object_(
void DynTypesParticipant::DynTypesDdsListener::internal_notify_type_object_(
DynamicType_ptr dynamic_type)
{
logInfo(DDSPIPE_DYNTYPES_PARTICIPANT,
"Participant " << configuration_->id << " discovered type object " << dynamic_type->get_name());
"Participant " << participant_id_ << " discovered type object " << dynamic_type->get_name());

monitor_type_discovered(dynamic_type->get_name());

Expand Down Expand Up @@ -295,9 +292,9 @@ void DynTypesParticipant::initialize_internal_dds_participant_()
configuration->domain,
pqos);

// Note that this listeners also inherits from DomainParticipantListener
dds_participant_->set_listener(
dynamic_cast<fastdds::dds::DomainParticipantListener*>(rtps_participant_listener_.get()));
// Create the DDS listener and set it in the participant
dds_participant_listener_ = create_dds_listener_();
dds_participant_->set_listener(dds_participant_listener_.get());

dds_participant_->enable();

Expand All @@ -313,9 +310,11 @@ void DynTypesParticipant::initialize_internal_dds_participant_()
}
}

std::unique_ptr<fastrtps::rtps::RTPSParticipantListener> DynTypesParticipant::create_listener_()
std::unique_ptr<fastdds::dds::DomainParticipantListener> DynTypesParticipant::create_dds_listener_()
{
return std::make_unique<DynTypesRtpsListener>(configuration_, discovery_database_, type_object_reader_);
// Note that when the DDS listener is created, the RTPS participant is already created and enabled.
// Therefore, we can access to the RTPS participant GUID prefix safely.
return std::make_unique<DynTypesDdsListener>(type_object_reader_, configuration_->id);
}

} /* namespace participants */
Expand Down
Loading