Skip to content

Commit

Permalink
Group set_qos_from_attributes free functions into a separate file (#2914
Browse files Browse the repository at this point in the history
)

* Refs #15417: New QosConverters.hpp and .cpp in src/cpp/fastdds/utils folder.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs 15417: set_qos_from_attributes imported from PublisherImpl.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs 15417: set_qos_from_attributes commented in PublisherImpl, and #included. src/cpp/CMakeLists.txt modified to compile new source.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Some CMakeLists.txt from test/ modified to compile new source.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Commented function erased, and not-used using and #include erased.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes imported from DomainParticipantFactory.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes function in DomainParticipantFactory  erased, and not-used #include erased..

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes and set_attributes_from_qos imported from DomainParticipantImpl.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes and set_attributes_from_qos functions in DomainParticipantImpl erased.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes imported from SubscriberImpl.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: set_qos_from_attributes function in SubscriberImpl erased.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Moved the new functions of QosConverters to namespace ::utils::

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Calling set_qos_from_attributes and set_attributes_from_qos pointing to ::utils:: namespace.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Documentation of the free functions.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Year change.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Move description to header file.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Blanc lines and guard condition.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Blanc lines and reference to each specific QoS and Attributes used on each method.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: #includes.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: using std::string.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: uncrustify.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: #includes order.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Doxygen comments.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Doxygen comments.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

* Refs #15417: Got your blank line.

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>

Signed-off-by: Mikel Rico <mikelrico@eprosima.com>
  • Loading branch information
MRicoIE2CS authored Sep 2, 2022
1 parent 682b289 commit 7ccc7a7
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 228 deletions.
1 change: 1 addition & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(${PROJECT_NAME}_source_files
fastdds/core/policy/QosPolicyUtils.cpp
fastdds/publisher/qos/WriterQos.cpp
fastdds/subscriber/qos/ReaderQos.cpp
fastdds/utils/QosConverters.cpp
rtps/builtin/BuiltinProtocols.cpp
rtps/builtin/discovery/participant/DirectMessageSender.cpp
rtps/builtin/discovery/participant/PDP.cpp
Expand Down
60 changes: 5 additions & 55 deletions src/cpp/fastdds/domain/DomainParticipantFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <fastrtps/xmlparser/XMLEndpointParser.h>

#include <fastdds/domain/DomainParticipantImpl.hpp>
#include <fastdds/utils/QosConverters.hpp>
#include <rtps/history/TopicPayloadPoolRegistry.hpp>
#include <statistics/fastdds/domain/DomainParticipantImpl.hpp>
#include <utils/SystemInfo.hpp>
Expand All @@ -49,57 +50,6 @@ namespace eprosima {
namespace fastdds {
namespace dds {

/**
* @brief Fill DomainParticipantQos from a given attributes RTPSParticipantAttributes object
*
* For the case of the non-binary properties, instead of the RTPSParticipantAttributes overriding the
* property list in the DomainParticipantQos, a merge is performed in the following manner:
*
* - If any property from the RTPSParticipantAttributes is not in the DomainParticipantQos, then it is appended
* to the DomainParticipantQos.
* - If any property from the RTPSParticipantAttributes property is also in the DomainParticipantQos, then the
* value in the DomainParticipantQos is overridden with that of the RTPSParticipantAttributes.
*
* @param[in, out] qos The DomainParticipantQos to set
* @param[in] attr The RTPSParticipantAttributes from which the @c qos is set.
*/
static void set_qos_from_attributes(
DomainParticipantQos& qos,
const eprosima::fastrtps::rtps::RTPSParticipantAttributes& attr)
{
qos.user_data().setValue(attr.userData);
qos.allocation() = attr.allocation;
qos.wire_protocol().prefix = attr.prefix;
qos.wire_protocol().participant_id = attr.participantID;
qos.wire_protocol().builtin = attr.builtin;
qos.wire_protocol().port = attr.port;
qos.wire_protocol().throughput_controller = attr.throughputController;
qos.wire_protocol().default_unicast_locator_list = attr.defaultUnicastLocatorList;
qos.wire_protocol().default_multicast_locator_list = attr.defaultMulticastLocatorList;
qos.transport().user_transports = attr.userTransports;
qos.transport().use_builtin_transports = attr.useBuiltinTransports;
qos.transport().send_socket_buffer_size = attr.sendSocketBufferSize;
qos.transport().listen_socket_buffer_size = attr.listenSocketBufferSize;
qos.name() = attr.getName();
qos.flow_controllers() = attr.flow_controllers;

// Merge attributes and qos properties
for (auto property : attr.properties.properties())
{
std::string* property_value = fastrtps::rtps::PropertyPolicyHelper::find_property(
qos.properties(), property.name());
if (nullptr == property_value)
{
qos.properties().properties().emplace_back(property);
}
else
{
*property_value = property.value();
}
}
qos.properties().binary_properties() = attr.properties.binary_properties();
}

DomainParticipantFactory::DomainParticipantFactory()
: default_xml_profiles_loaded(false)
, default_participant_qos_(PARTICIPANT_QOS_DEFAULT)
Expand Down Expand Up @@ -270,7 +220,7 @@ DomainParticipant* DomainParticipantFactory::create_participant_with_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr))
{
DomainParticipantQos qos = default_participant_qos_;
set_qos_from_attributes(qos, attr.rtps);
utils::set_qos_from_attributes(qos, attr.rtps);
return create_participant(did, qos, listen, mask);
}

Expand All @@ -289,7 +239,7 @@ DomainParticipant* DomainParticipantFactory::create_participant_with_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr))
{
DomainParticipantQos qos = default_participant_qos_;
set_qos_from_attributes(qos, attr.rtps);
utils::set_qos_from_attributes(qos, attr.rtps);
return create_participant(attr.domainId, qos, listen, mask);
}

Expand Down Expand Up @@ -367,7 +317,7 @@ ReturnCode_t DomainParticipantFactory::get_participant_qos_from_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillParticipantAttributes(profile_name, attr))
{
qos = default_participant_qos_;
set_qos_from_attributes(qos, attr.rtps);
utils::set_qos_from_attributes(qos, attr.rtps);
return ReturnCode_t::RETCODE_OK;
}

Expand Down Expand Up @@ -459,7 +409,7 @@ void DomainParticipantFactory::reset_default_participant_qos()
{
eprosima::fastrtps::ParticipantAttributes attr;
XMLProfileManager::getDefaultParticipantAttributes(attr);
set_qos_from_attributes(default_participant_qos_, attr.rtps);
utils::set_qos_from_attributes(default_participant_qos_, attr.rtps);
}
}

Expand Down
77 changes: 15 additions & 62 deletions src/cpp/fastdds/domain/DomainParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <fastdds/topic/TopicImpl.hpp>
#include <fastdds/topic/TopicProxy.hpp>
#include <fastdds/topic/TopicProxyFactory.hpp>
#include <fastdds/utils/QosConverters.hpp>
#include <rtps/RTPSDomainImpl.hpp>
#include <utils/SystemInfo.hpp>

Expand Down Expand Up @@ -88,54 +89,6 @@ using fastrtps::rtps::EndpointKind_t;
using fastrtps::rtps::ResourceEvent;
using eprosima::fastdds::dds::Log;

static void set_attributes_from_qos(
fastrtps::rtps::RTPSParticipantAttributes& attr,
const DomainParticipantQos& qos)
{
attr.allocation = qos.allocation();
attr.properties = qos.properties();
attr.setName(qos.name());
attr.prefix = qos.wire_protocol().prefix;
attr.participantID = qos.wire_protocol().participant_id;
attr.builtin = qos.wire_protocol().builtin;
attr.port = qos.wire_protocol().port;
attr.throughputController = qos.wire_protocol().throughput_controller;
attr.defaultUnicastLocatorList = qos.wire_protocol().default_unicast_locator_list;
attr.defaultMulticastLocatorList = qos.wire_protocol().default_multicast_locator_list;
attr.userTransports = qos.transport().user_transports;
attr.useBuiltinTransports = qos.transport().use_builtin_transports;
attr.sendSocketBufferSize = qos.transport().send_socket_buffer_size;
attr.listenSocketBufferSize = qos.transport().listen_socket_buffer_size;
attr.userData = qos.user_data().data_vec();
attr.flow_controllers = qos.flow_controllers();
}

static void set_qos_from_attributes(
TopicQos& qos,
const TopicAttributes& attr)
{
qos.history() = attr.historyQos;
qos.resource_limits() = attr.resourceLimitsQos;
}

static void set_qos_from_attributes(
SubscriberQos& qos,
const SubscriberAttributes& attr)
{
qos.group_data().setValue(attr.qos.m_groupData);
qos.partition() = attr.qos.m_partition;
qos.presentation() = attr.qos.m_presentation;
}

static void set_qos_from_attributes(
PublisherQos& qos,
const PublisherAttributes& attr)
{
qos.group_data().setValue(attr.qos.m_groupData);
qos.partition() = attr.qos.m_partition;
qos.presentation() = attr.qos.m_presentation;
}

DomainParticipantImpl::DomainParticipantImpl(
DomainParticipant* dp,
DomainId_t did,
Expand All @@ -157,15 +110,15 @@ DomainParticipantImpl::DomainParticipantImpl(

PublisherAttributes pub_attr;
XMLProfileManager::getDefaultPublisherAttributes(pub_attr);
set_qos_from_attributes(default_pub_qos_, pub_attr);
utils::set_qos_from_attributes(default_pub_qos_, pub_attr);

SubscriberAttributes sub_attr;
XMLProfileManager::getDefaultSubscriberAttributes(sub_attr);
set_qos_from_attributes(default_sub_qos_, sub_attr);
utils::set_qos_from_attributes(default_sub_qos_, sub_attr);

TopicAttributes top_attr;
XMLProfileManager::getDefaultTopicAttributes(top_attr);
set_qos_from_attributes(default_topic_qos_, top_attr);
utils::set_qos_from_attributes(default_topic_qos_, top_attr);

// Pre calculate participant id and generated guid
participant_id_ = qos_.wire_protocol().participant_id;
Expand Down Expand Up @@ -295,7 +248,7 @@ ReturnCode_t DomainParticipantImpl::enable()
assert(get_rtps_participant() == nullptr);

fastrtps::rtps::RTPSParticipantAttributes rtps_attr;
set_attributes_from_qos(rtps_attr, qos_);
utils::set_attributes_from_qos(rtps_attr, qos_);
rtps_attr.participantID = participant_id_;

// If DEFAULT_ROS2_MASTER_URI is specified then try to create default client if
Expand Down Expand Up @@ -406,7 +359,7 @@ ReturnCode_t DomainParticipantImpl::set_qos(
if (qos_should_be_updated)
{
// Notify the participant that there is a QoS update
set_attributes_from_qos(patt, qos_);
utils::set_attributes_from_qos(patt, qos_);
}
else
{
Expand Down Expand Up @@ -847,7 +800,7 @@ Publisher* DomainParticipantImpl::create_publisher_with_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillPublisherAttributes(profile_name, attr))
{
PublisherQos qos = default_pub_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return create_publisher(qos, listener, mask);
}

Expand Down Expand Up @@ -1043,7 +996,7 @@ void DomainParticipantImpl::reset_default_publisher_qos()
PublisherImpl::set_qos(default_pub_qos_, PUBLISHER_QOS_DEFAULT, true);
PublisherAttributes attr;
XMLProfileManager::getDefaultPublisherAttributes(attr);
set_qos_from_attributes(default_pub_qos_, attr);
utils::set_qos_from_attributes(default_pub_qos_, attr);
}

const PublisherQos& DomainParticipantImpl::get_default_publisher_qos() const
Expand All @@ -1059,7 +1012,7 @@ const ReturnCode_t DomainParticipantImpl::get_publisher_qos_from_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillPublisherAttributes(profile_name, attr))
{
qos = default_pub_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return ReturnCode_t::RETCODE_OK;
}

Expand Down Expand Up @@ -1091,7 +1044,7 @@ void DomainParticipantImpl::reset_default_subscriber_qos()
SubscriberImpl::set_qos(default_sub_qos_, SUBSCRIBER_QOS_DEFAULT, true);
SubscriberAttributes attr;
XMLProfileManager::getDefaultSubscriberAttributes(attr);
set_qos_from_attributes(default_sub_qos_, attr);
utils::set_qos_from_attributes(default_sub_qos_, attr);
}

const SubscriberQos& DomainParticipantImpl::get_default_subscriber_qos() const
Expand All @@ -1107,7 +1060,7 @@ const ReturnCode_t DomainParticipantImpl::get_subscriber_qos_from_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillSubscriberAttributes(profile_name, attr))
{
qos = default_sub_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return ReturnCode_t::RETCODE_OK;
}

Expand Down Expand Up @@ -1139,7 +1092,7 @@ void DomainParticipantImpl::reset_default_topic_qos()
TopicImpl::set_qos(default_topic_qos_, TOPIC_QOS_DEFAULT, true);
TopicAttributes attr;
XMLProfileManager::getDefaultTopicAttributes(attr);
set_qos_from_attributes(default_topic_qos_, attr);
utils::set_qos_from_attributes(default_topic_qos_, attr);
}

const TopicQos& DomainParticipantImpl::get_default_topic_qos() const
Expand All @@ -1155,7 +1108,7 @@ const ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr))
{
qos = default_topic_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return ReturnCode_t::RETCODE_OK;
}

Expand Down Expand Up @@ -1320,7 +1273,7 @@ Subscriber* DomainParticipantImpl::create_subscriber_with_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillSubscriberAttributes(profile_name, attr))
{
SubscriberQos qos = default_sub_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return create_subscriber(qos, listener, mask);
}

Expand Down Expand Up @@ -1404,7 +1357,7 @@ Topic* DomainParticipantImpl::create_topic_with_profile(
if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr))
{
TopicQos qos = default_topic_qos_;
set_qos_from_attributes(qos, attr);
utils::set_qos_from_attributes(qos, attr);
return create_topic(topic_name, type_name, qos, listener, mask);
}

Expand Down
Loading

0 comments on commit 7ccc7a7

Please sign in to comment.