Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep reference to DomainParticipantFactory #770

Merged
merged 2 commits into from
Oct 14, 2024
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 @@ -24,6 +24,7 @@
#include <vector>

#include "fastdds/dds/domain/DomainParticipant.hpp"
#include "fastdds/dds/domain/DomainParticipantFactory.hpp"
#include "fastdds/dds/domain/DomainParticipantListener.hpp"
#include "fastdds/dds/publisher/Publisher.hpp"
#include "fastdds/dds/subscriber/Subscriber.hpp"
Expand Down Expand Up @@ -91,6 +92,9 @@ typedef struct UseCountTopic

typedef struct CustomParticipantInfo
{
std::shared_ptr<eprosima::fastdds::dds::DomainParticipantFactory> factory_ =
eprosima::fastdds::dds::DomainParticipantFactory::get_shared_instance();

fujitatomoya marked this conversation as resolved.
Show resolved Hide resolved
eprosima::fastdds::dds::DomainParticipant * participant_{nullptr};
ParticipantListener * listener_{nullptr};

Expand Down
14 changes: 6 additions & 8 deletions rmw_fastrtps_shared_cpp/src/participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ __create_participant(
[participant_info]() {
if (nullptr != participant_info->participant_) {
participant_info->participant_->delete_publisher(participant_info->publisher_);
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(
participant_info->participant_);
participant_info->factory_->delete_participant(participant_info->participant_);
}
delete participant_info->listener_;
delete participant_info;
Expand All @@ -99,7 +98,7 @@ __create_participant(
eprosima::fastdds::dds::StatusMask participant_mask = eprosima::fastdds::dds::StatusMask::none();

participant_info->participant_ =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(
participant_info->factory_->create_participant(
static_cast<uint32_t>(domain_id), domainParticipantQos,
participant_info->listener_, participant_mask);

Expand Down Expand Up @@ -159,9 +158,9 @@ rmw_fastrtps_shared_cpp::create_participant(
}

// Load default XML profile.
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->load_profiles();
eprosima::fastdds::dds::DomainParticipantQos domainParticipantQos =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->get_default_participant_qos();
auto factory = eprosima::fastdds::dds::DomainParticipantFactory::get_shared_instance();
factory->load_profiles();
auto domainParticipantQos = factory->get_default_participant_qos();

// Configure discovery
switch (discovery_options->automatic_discovery_range) {
Expand Down Expand Up @@ -432,8 +431,7 @@ rmw_fastrtps_shared_cpp::destroy_participant(CustomParticipantInfo * participant
}

// Delete Domain Participant
ret =
eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(
ret = participant_info->factory_->delete_participant(
participant_info->participant_);

if (ReturnCode_t::RETCODE_OK != ret) {
Expand Down