5#ifndef CARLA_ROS2_MIDDLEWARE_TESTING
11#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
12#include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
13#include <fastdds/rtps/attributes/BuiltinTransports.hpp>
20namespace efd = eprosima::fastdds::dds;
29 std::lock_guard<std::mutex> lock(
_mutex);
37 auto* factory = efd::DomainParticipantFactory::get_instance();
38 factory->load_profiles();
39 efd::DomainParticipantQos pqos = factory->get_default_participant_qos();
56 const bool xml_configured_transports =
57 !pqos.transport().user_transports.empty() ||
58 !pqos.transport().use_builtin_transports;
59 if (std::getenv(
"FASTDDS_BUILTIN_TRANSPORTS") ==
nullptr &&
60 !xml_configured_transports) {
61 pqos.setup_transports(eprosima::fastdds::rtps::BuiltinTransports::UDPv4);
65 const uint32_t domain_id =
68 efd::DomainParticipantFactory::get_instance()->create_participant(domain_id, pqos);
70 log_error(
"FastDDSSharedParticipant: Failed to create DomainParticipant");
79 std::lock_guard<std::mutex> lock(
_mutex);
81 log_error(
"FastDDSSharedParticipant::release() called with refcount already 0");
91 efd::DomainParticipantFactory::get_instance()->delete_participant(
_participant);
98 std::lock_guard<std::mutex> lock(
_mutex);
103 std::lock_guard<std::mutex> lock(
_mutex);
109 if (it->second == 0u) {
static void release_type(const std::string &type_name)
Release one use of type_name.
static uint32_t _refcount
static eprosima::fastdds::dds::DomainParticipant * _participant
static eprosima::fastdds::dds::DomainParticipant * acquire()
Increment the refcount and return the shared DomainParticipant.
static void retain_type(const std::string &type_name)
Notify the singleton that one more endpoint is using type_name so that unregister_type() is deferred ...
static std::unordered_map< std::string, uint32_t > _type_refcounts
static void release()
Decrement the refcount.
static int GetEffectiveDomainId()
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)