Skip to content

Commit

Permalink
Keep reference to DomainParticipantFactory (#770)
Browse files Browse the repository at this point in the history
* Keep reference to factory in `CustomParticipantInfo`.

* Change other references to `DomainParticipantFactory::get_instance()`.

Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany authored Oct 14, 2024
1 parent 5cb7665 commit 9d2150f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
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();

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

0 comments on commit 9d2150f

Please sign in to comment.