From fd98df9af1af98e8f2c7cd7a0571301ed474b04a Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 14:18:37 +0200 Subject: [PATCH 01/37] Refs #21357: Make TopicAttributes private and move to namespace Signed-off-by: Mario Dominguez --- src/cpp/CMakeLists.txt | 2 +- .../attributes/TopicAttributes.cpp | 5 ++++- .../cpp/xmlparser}/attributes/TopicAttributes.hpp | 14 ++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) rename src/cpp/{rtps => xmlparser}/attributes/TopicAttributes.cpp (96%) rename {include/fastdds/rtps => src/cpp/xmlparser}/attributes/TopicAttributes.hpp (90%) diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 394b67cbd34..e0be0a759a3 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -116,7 +116,6 @@ set(${PROJECT_NAME}_source_files rtps/attributes/RTPSParticipantAttributes.cpp rtps/attributes/ServerAttributes.cpp rtps/attributes/ThreadSettings.cpp - rtps/attributes/TopicAttributes.cpp rtps/builtin/BuiltinProtocols.cpp rtps/builtin/data/ParticipantProxyData.cpp rtps/builtin/data/ProxyDataConverters.cpp @@ -237,6 +236,7 @@ set(${PROJECT_NAME}_source_files utils/SystemInfo.cpp utils/TimedConditionVariable.cpp utils/UnitsParser.cpp + xmlparser/attributes/TopicAttributes.cpp xmlparser/XMLDynamicParser.cpp xmlparser/XMLElementParser.cpp xmlparser/XMLEndpointParser.cpp diff --git a/src/cpp/rtps/attributes/TopicAttributes.cpp b/src/cpp/xmlparser/attributes/TopicAttributes.cpp similarity index 96% rename from src/cpp/rtps/attributes/TopicAttributes.cpp rename to src/cpp/xmlparser/attributes/TopicAttributes.cpp index 8652e5e6c2c..deb1886134d 100644 --- a/src/cpp/rtps/attributes/TopicAttributes.cpp +++ b/src/cpp/xmlparser/attributes/TopicAttributes.cpp @@ -16,11 +16,13 @@ * @file TopicAttributes.cpp */ -#include #include +#include + namespace eprosima { namespace fastdds { +namespace xmlparser { bool TopicAttributes::checkQos() const { @@ -72,5 +74,6 @@ bool TopicAttributes::checkQos() const return true; } +} // namespave xmlparser } // namespace fastdds } // namespace eprosima diff --git a/include/fastdds/rtps/attributes/TopicAttributes.hpp b/src/cpp/xmlparser/attributes/TopicAttributes.hpp similarity index 90% rename from include/fastdds/rtps/attributes/TopicAttributes.hpp rename to src/cpp/xmlparser/attributes/TopicAttributes.hpp index 53d2c66522d..cf9052b8827 100644 --- a/include/fastdds/rtps/attributes/TopicAttributes.hpp +++ b/src/cpp/xmlparser/attributes/TopicAttributes.hpp @@ -16,8 +16,8 @@ * @file TopicAttributes.hpp */ -#ifndef FASTDDS_RTPS_ATTRIBUTES__TOPICATTRIBUTES_HPP -#define FASTDDS_RTPS_ATTRIBUTES__TOPICATTRIBUTES_HPP +#ifndef FASTDDS_XMLPARSER_ATTRIBUTES__TOPICATTRIBUTES_HPP +#define FASTDDS_XMLPARSER_ATTRIBUTES__TOPICATTRIBUTES_HPP #include @@ -26,9 +26,10 @@ namespace eprosima { namespace fastdds { +namespace xmlparser { /** - * Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publisher or Subscriber. + * Class TopicAttributes, used to define the attributes of the topic associated with a Publisher or Subscriber. * @ingroup FASTDDS_ATTRIBUTES_MODULE */ class TopicAttributes @@ -120,8 +121,6 @@ class TopicAttributes bool checkQos() const; }; -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - /** * Check if two topic attributes are not equal * @param t1 First instance of TopicAttributes to compare @@ -143,9 +142,8 @@ bool inline operator !=( return false; } -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - +} // namespace xmlparser } // namespace fastdds } // namespace eprosima -#endif // FASTDDS_RTPS_ATTRIBUTES__TOPICATTRIBUTES_HPP +#endif // FASTDDS_XMLPARSER_ATTRIBUTES__TOPICATTRIBUTES_HPP From 15bc0b817f7f110624f65f0b409958b6a8d73ef7 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 14:23:27 +0200 Subject: [PATCH 02/37] Refs #21357: Relay TopicAttributes references to xmlparser namespace Signed-off-by: Mario Dominguez --- src/cpp/fastdds/domain/DomainParticipantImpl.cpp | 9 +++++---- src/cpp/fastdds/utils/QosConverters.cpp | 2 +- src/cpp/fastdds/utils/QosConverters.hpp | 4 ++-- src/cpp/xmlparser/XMLProfileManager.h | 1 + .../xmlparser/attributes/PublisherAttributes.hpp | 5 +++-- .../attributes/SubscriberAttributes.hpp | 5 +++-- .../unittest/xmlparser/XMLElementParserTests.cpp | 2 +- .../unittest/xmlparser/XMLProfileParserTests.cpp | 16 ++++++++-------- .../unittest/xmlparser/wrapper/XMLParserTest.hpp | 4 ++-- 9 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 6449cef4677..c9b7d19ceb2 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include namespace eprosima { @@ -116,7 +117,7 @@ DomainParticipantImpl::DomainParticipantImpl( XMLProfileManager::getDefaultSubscriberAttributes(sub_attr); utils::set_qos_from_attributes(default_sub_qos_, sub_attr); - TopicAttributes top_attr; + xmlparser::TopicAttributes top_attr; XMLProfileManager::getDefaultTopicAttributes(top_attr); utils::set_qos_from_attributes(default_topic_qos_, top_attr); @@ -1114,7 +1115,7 @@ void DomainParticipantImpl::reset_default_topic_qos() { // TODO (ILG): Change when we have full XML support for DDS QoS profiles TopicImpl::set_qos(default_topic_qos_, TOPIC_QOS_DEFAULT, true); - TopicAttributes attr; + xmlparser::TopicAttributes attr; XMLProfileManager::getDefaultTopicAttributes(attr); utils::set_qos_from_attributes(default_topic_qos_, attr); } @@ -1128,7 +1129,7 @@ ReturnCode_t DomainParticipantImpl::get_topic_qos_from_profile( const std::string& profile_name, TopicQos& qos) const { - TopicAttributes attr; + xmlparser::TopicAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr)) { qos = default_topic_qos_; @@ -1405,7 +1406,7 @@ Topic* DomainParticipantImpl::create_topic_with_profile( const StatusMask& mask) { // TODO (ILG): Change when we have full XML support for DDS QoS profiles - TopicAttributes attr; + xmlparser::TopicAttributes attr; if (XMLP_ret::XML_OK == XMLProfileManager::fillTopicAttributes(profile_name, attr)) { TopicQos qos = default_topic_qos_; diff --git a/src/cpp/fastdds/utils/QosConverters.cpp b/src/cpp/fastdds/utils/QosConverters.cpp index 9b0afb104ae..3ec726ab75e 100644 --- a/src/cpp/fastdds/utils/QosConverters.cpp +++ b/src/cpp/fastdds/utils/QosConverters.cpp @@ -231,7 +231,7 @@ void set_attributes_from_extended_qos( void set_qos_from_attributes( TopicQos& qos, - const TopicAttributes& attr) + const xmlparser::TopicAttributes& attr) { qos.history() = attr.historyQos; qos.resource_limits() = attr.resourceLimitsQos; diff --git a/src/cpp/fastdds/utils/QosConverters.hpp b/src/cpp/fastdds/utils/QosConverters.hpp index ef728a53cc5..69a4df86cc7 100644 --- a/src/cpp/fastdds/utils/QosConverters.hpp +++ b/src/cpp/fastdds/utils/QosConverters.hpp @@ -28,13 +28,13 @@ #include #include #include -#include #include #include #include #include #include +#include namespace eprosima { namespace fastdds { @@ -125,7 +125,7 @@ void set_attributes_from_extended_qos( */ void set_qos_from_attributes( TopicQos& qos, - const TopicAttributes& attr); + const xmlparser::TopicAttributes& attr); /** * Obtains the SubscriberQos from the SubscriberAttributes provided. diff --git a/src/cpp/xmlparser/XMLProfileManager.h b/src/cpp/xmlparser/XMLProfileManager.h index d2c45462fda..7534690994d 100644 --- a/src/cpp/xmlparser/XMLProfileManager.h +++ b/src/cpp/xmlparser/XMLProfileManager.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/src/cpp/xmlparser/attributes/PublisherAttributes.hpp b/src/cpp/xmlparser/attributes/PublisherAttributes.hpp index a4d68d5917b..b8b3c42124d 100644 --- a/src/cpp/xmlparser/attributes/PublisherAttributes.hpp +++ b/src/cpp/xmlparser/attributes/PublisherAttributes.hpp @@ -24,11 +24,12 @@ #include #include #include -#include #include #include #include +#include + namespace eprosima { namespace fastdds { namespace xmlparser { @@ -61,7 +62,7 @@ class PublisherAttributes } //! Topic Attributes for the Publisher - fastdds::TopicAttributes topic; + fastdds::xmlparser::TopicAttributes topic; //! QOS for the Publisher dds::WriterQos qos; diff --git a/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp b/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp index 51466642040..b9adb04cfb6 100644 --- a/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp +++ b/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp @@ -24,10 +24,11 @@ #include #include #include -#include #include #include +#include + namespace eprosima { namespace fastdds { namespace xmlparser { @@ -41,7 +42,7 @@ class SubscriberAttributes public: //! Topic Attributes - fastdds::TopicAttributes topic; + fastdds::xmlparser::TopicAttributes topic; //! Reader QOs. dds::ReaderQos qos; diff --git a/test/unittest/xmlparser/XMLElementParserTests.cpp b/test/unittest/xmlparser/XMLElementParserTests.cpp index 16f54d6c19c..445ca94562a 100644 --- a/test/unittest/xmlparser/XMLElementParserTests.cpp +++ b/test/unittest/xmlparser/XMLElementParserTests.cpp @@ -2089,7 +2089,7 @@ TEST_F(XMLParserTests, getXMLFlowControllerDescriptorList_NegativeClauses) TEST_F(XMLParserTests, getXMLTopicAttributes_NegativeClauses) { uint8_t ident = 1; - TopicAttributes topic; + xmlparser::TopicAttributes topic; tinyxml2::XMLDocument xml_doc; tinyxml2::XMLElement* titleElement; diff --git a/test/unittest/xmlparser/XMLProfileParserTests.cpp b/test/unittest/xmlparser/XMLProfileParserTests.cpp index 226755d897b..65e21bbe769 100644 --- a/test/unittest/xmlparser/XMLProfileParserTests.cpp +++ b/test/unittest/xmlparser/XMLProfileParserTests.cpp @@ -851,7 +851,7 @@ TEST_P(XMLProfileParserTests, XMLParserPublisher) EXPECT_EQ( xmlparser::XMLP_ret::XML_OK, xmlparser::XMLProfileManager::fillPublisherAttributes(publisher_profile, publisher_atts)); - TopicAttributes& pub_topic = publisher_atts.topic; + xmlparser::TopicAttributes& pub_topic = publisher_atts.topic; dds::WriterQos& pub_qos = publisher_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -925,7 +925,7 @@ TEST_F(XMLProfileParserBasicTests, XMLParserPublisherDeprecated) EXPECT_EQ( xmlparser::XMLP_ret::XML_OK, xmlparser::XMLProfileManager::fillPublisherAttributes(publisher_profile, publisher_atts)); - TopicAttributes& pub_topic = publisher_atts.topic; + xmlparser::TopicAttributes& pub_topic = publisher_atts.topic; dds::WriterQos& pub_qos = publisher_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -997,7 +997,7 @@ TEST_P(XMLProfileParserTests, XMLParserDefaultPublisherProfile) xmlparser::XMLProfileManager::loadXMLFile(xml_filename_)); xmlparser::XMLProfileManager::getDefaultPublisherAttributes(publisher_atts); - TopicAttributes& pub_topic = publisher_atts.topic; + xmlparser::TopicAttributes& pub_topic = publisher_atts.topic; dds::WriterQos& pub_qos = publisher_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -1069,7 +1069,7 @@ TEST_F(XMLProfileParserBasicTests, XMLParserDefaultPublisherProfileDeprecated) xmlparser::XMLProfileManager::loadXMLFile("test_xml_deprecated.xml")); xmlparser::XMLProfileManager::getDefaultPublisherAttributes(publisher_atts); - TopicAttributes& pub_topic = publisher_atts.topic; + xmlparser::TopicAttributes& pub_topic = publisher_atts.topic; dds::WriterQos& pub_qos = publisher_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -1143,7 +1143,7 @@ TEST_P(XMLProfileParserTests, XMLParserSubscriber) EXPECT_EQ( xmlparser::XMLP_ret::XML_OK, xmlparser::XMLProfileManager::fillSubscriberAttributes(subscriber_profile, subscriber_atts)); - TopicAttributes& sub_topic = subscriber_atts.topic; + xmlparser::TopicAttributes& sub_topic = subscriber_atts.topic; dds::ReaderQos& sub_qos = subscriber_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -1215,7 +1215,7 @@ TEST_F(XMLProfileParserBasicTests, XMLParserSubscriberDeprecated) EXPECT_EQ( xmlparser::XMLP_ret::XML_OK, xmlparser::XMLProfileManager::fillSubscriberAttributes(subscriber_profile, subscriber_atts)); - TopicAttributes& sub_topic = subscriber_atts.topic; + xmlparser::TopicAttributes& sub_topic = subscriber_atts.topic; dds::ReaderQos& sub_qos = subscriber_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -1285,7 +1285,7 @@ TEST_P(XMLProfileParserTests, XMLParserDefaultSubscriberProfile) xmlparser::XMLProfileManager::loadXMLFile(xml_filename_)); xmlparser::XMLProfileManager::getDefaultSubscriberAttributes(subscriber_atts); - TopicAttributes& sub_topic = subscriber_atts.topic; + xmlparser::TopicAttributes& sub_topic = subscriber_atts.topic; dds::ReaderQos& sub_qos = subscriber_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; @@ -1355,7 +1355,7 @@ TEST_F(XMLProfileParserBasicTests, XMLParserDefaultSubscriberProfileDeprecated) xmlparser::XMLProfileManager::loadXMLFile("test_xml_deprecated.xml")); xmlparser::XMLProfileManager::getDefaultSubscriberAttributes(subscriber_atts); - TopicAttributes& sub_topic = subscriber_atts.topic; + xmlparser::TopicAttributes& sub_topic = subscriber_atts.topic; dds::ReaderQos& sub_qos = subscriber_atts.qos; Locator_t locator; LocatorListIterator loc_list_it; diff --git a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp index 4c4e8a5e9a3..55ddbb11880 100644 --- a/test/unittest/xmlparser/wrapper/XMLParserTest.hpp +++ b/test/unittest/xmlparser/wrapper/XMLParserTest.hpp @@ -239,7 +239,7 @@ class XMLParserTest : public XMLParser static XMLP_ret getXMLTopicAttributes_wrapper( tinyxml2::XMLElement* elem, - TopicAttributes& topic, + xmlparser::TopicAttributes& topic, uint8_t ident) { return getXMLTopicAttributes(elem, topic, ident); @@ -522,7 +522,7 @@ class XMLParserTest : public XMLParser static XMLP_ret fillDataNode_wrapper( tinyxml2::XMLElement* p_profile, - DataNode& topic_node) + DataNode& topic_node) { return fillDataNode(p_profile, topic_node); } From 7a9479eb4c86850b0893c025e164160694348e69 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 14:30:14 +0200 Subject: [PATCH 03/37] Refs #21357: Remove TopicAttributes references in DDS layer headers Signed-off-by: Mario Dominguez --- include/fastdds/dds/publisher/Publisher.hpp | 3 --- include/fastdds/dds/subscriber/Subscriber.hpp | 3 --- include/fastdds/dds/subscriber/qos/DataReaderQos.hpp | 3 --- include/fastdds/dds/topic/qos/TopicQos.hpp | 1 - src/cpp/fastdds/publisher/DataWriterImpl.hpp | 5 ----- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 2 -- .../fastdds/domain/DomainParticipantImpl.hpp | 3 +-- 7 files changed, 1 insertion(+), 19 deletions(-) diff --git a/include/fastdds/dds/publisher/Publisher.hpp b/include/fastdds/dds/publisher/Publisher.hpp index d5812b129d5..a29deab4541 100644 --- a/include/fastdds/dds/publisher/Publisher.hpp +++ b/include/fastdds/dds/publisher/Publisher.hpp @@ -37,9 +37,6 @@ class Publisher; namespace eprosima { namespace fastdds { - -class TopicAttributes; - namespace rtps { class IPayloadPool; diff --git a/include/fastdds/dds/subscriber/Subscriber.hpp b/include/fastdds/dds/subscriber/Subscriber.hpp index 738c9207eab..eba91b2c44d 100644 --- a/include/fastdds/dds/subscriber/Subscriber.hpp +++ b/include/fastdds/dds/subscriber/Subscriber.hpp @@ -40,9 +40,6 @@ class Subscriber; namespace eprosima { namespace fastdds { - -class TopicAttributes; - namespace rtps { class IPayloadPool; diff --git a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp index 60c75f41862..4f51984c208 100644 --- a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp +++ b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp @@ -25,15 +25,12 @@ #include #include #include -#include #include namespace eprosima { namespace fastdds { namespace dds { -using TopicAttributesQos = fastdds::TopicAttributes; - //! Qos Policy to configure the DisablePositiveACKsQos and the reader attributes class RTPSReliableReaderQos { diff --git a/include/fastdds/dds/topic/qos/TopicQos.hpp b/include/fastdds/dds/topic/qos/TopicQos.hpp index f469d28897c..78898e1c332 100644 --- a/include/fastdds/dds/topic/qos/TopicQos.hpp +++ b/include/fastdds/dds/topic/qos/TopicQos.hpp @@ -21,7 +21,6 @@ #define FASTDDS_DDS_TOPIC_QOS__TOPICQOS_HPP #include -#include #include diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.hpp b/src/cpp/fastdds/publisher/DataWriterImpl.hpp index d735c737a3b..2b8f13fdce4 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.hpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.hpp @@ -585,11 +585,6 @@ class DataWriterImpl : protected rtps::IReaderDataFilter fastdds::rtps::WriteParams& wparams, const InstanceHandle_t& handle); - fastdds::TopicAttributes get_topic_attributes( - const DataWriterQos& qos, - const Topic& topic, - const TypeSupport& type); - static void set_qos( DataWriterQos& to, const DataWriterQos& from, diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index 66503d09cbf..41194cd2c20 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -600,8 +600,6 @@ class DataReaderImpl */ bool lifespan_expired(); - fastdds::TopicAttributes topic_attributes() const; - void subscriber_qos_updated(); RequestedIncompatibleQosStatus& update_requested_incompatible_qos( diff --git a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp index 3bd9c44d0d6..6a7d45538b7 100644 --- a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp +++ b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -87,7 +86,7 @@ class DomainParticipantImpl participant_->impl_ = this; guid_.guidPrefix.value[11] = 1; - eprosima::fastdds::TopicAttributes top_attr; + eprosima::fastdds::xmlparser::TopicAttributes top_attr; eprosima::fastdds::xmlparser::XMLProfileManager::getDefaultTopicAttributes(top_attr); default_topic_qos_.history() = top_attr.historyQos; default_topic_qos_.resource_limits() = top_attr.resourceLimitsQos; From 33f2d5c3fbdc91992f15a99e6c34b6a93136f8af Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 14:42:10 +0200 Subject: [PATCH 04/37] Refs #21357: Remove TopicAttributes from RTPSDomain and weak forward declarations from RTPS headers Signed-off-by: Mario Dominguez --- include/fastdds/rtps/RTPSDomain.hpp | 13 ------ src/cpp/rtps/RTPSDomain.cpp | 19 --------- src/cpp/rtps/RTPSDomainImpl.hpp | 12 ------ src/cpp/rtps/builtin/data/ReaderProxyData.hpp | 1 - src/cpp/rtps/builtin/data/WriterProxyData.hpp | 1 - src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 1 - .../rtps/participant/RTPSParticipantImpl.h | 41 ++++++++----------- .../rtps/participant/RTPSParticipant.hpp | 2 - 8 files changed, 18 insertions(+), 72 deletions(-) diff --git a/include/fastdds/rtps/RTPSDomain.hpp b/include/fastdds/rtps/RTPSDomain.hpp index 55eb3766361..6f2935dd25e 100644 --- a/include/fastdds/rtps/RTPSDomain.hpp +++ b/include/fastdds/rtps/RTPSDomain.hpp @@ -29,7 +29,6 @@ #include #include #include -#include namespace eprosima { namespace fastdds { @@ -251,18 +250,6 @@ class RTPSDomain FASTDDS_EXPORTED_API static bool set_library_settings( const fastdds::LibrarySettings& library_settings); - /** - * @brief Get the TopicAttributes from XML profile. - * - * @param profile_name Topic profile name. - * @param topic_att TopicAttributes object where the attributes are returned. - * @return bool true if the profile exists. - * false otherwise. - */ - FASTDDS_EXPORTED_API static bool get_topic_attributes_from_profile( - const std::string& profile_name, - TopicAttributes& topic_att); - private: RTPSDomain() = delete; diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 1be97cf6697..e9a789df432 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -820,25 +820,6 @@ bool RTPSDomainImpl::set_library_settings( return true; } -bool RTPSDomain::get_topic_attributes_from_profile( - const std::string& profile_name, - TopicAttributes& topic_attributes) -{ - return RTPSDomainImpl::get_topic_attributes_from_profile(profile_name, topic_attributes); -} - -bool RTPSDomainImpl::get_topic_attributes_from_profile( - const std::string& profile_name, - TopicAttributes& topic_attributes) -{ - if (xmlparser::XMLP_ret::XML_OK == - xmlparser::XMLProfileManager::fillTopicAttributes(profile_name, topic_attributes)) - { - return true; - } - return false; -} - fastdds::dds::xtypes::ITypeObjectRegistry& RTPSDomainImpl::type_object_registry() { return get_instance()->type_object_registry_; diff --git a/src/cpp/rtps/RTPSDomainImpl.hpp b/src/cpp/rtps/RTPSDomainImpl.hpp index 35e2d398d10..605d2ed1461 100644 --- a/src/cpp/rtps/RTPSDomainImpl.hpp +++ b/src/cpp/rtps/RTPSDomainImpl.hpp @@ -236,18 +236,6 @@ class RTPSDomainImpl static bool set_library_settings( const fastdds::LibrarySettings& library_settings); - /** - * @brief Get the TopicAttributes from XML profile. - * - * @param profile_name Topic profile name. - * @param topic_att TopicAttributes object where the attributes are returned. - * @return bool true if the profile exists. - * false otherwise. - */ - static bool get_topic_attributes_from_profile( - const std::string& profile_name, - TopicAttributes& topic_attributes); - /** * @brief Return the ITypeObjectRegistry member to access the interface for the public API. * diff --git a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp index 73d60d93d75..7712ef2ea61 100644 --- a/src/cpp/rtps/builtin/data/ReaderProxyData.hpp +++ b/src/cpp/rtps/builtin/data/ReaderProxyData.hpp @@ -28,7 +28,6 @@ #include #include #include -#include namespace eprosima { namespace fastdds { diff --git a/src/cpp/rtps/builtin/data/WriterProxyData.hpp b/src/cpp/rtps/builtin/data/WriterProxyData.hpp index e64273bf7ea..7eb674628a3 100644 --- a/src/cpp/rtps/builtin/data/WriterProxyData.hpp +++ b/src/cpp/rtps/builtin/data/WriterProxyData.hpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index 10bd9435f3f..2cc906821fc 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -44,7 +44,6 @@ class TypeIdentifier; } // namespace xtypes } // namespace dds -class TopicAttributes; namespace rtps { diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 8d8760ead76..58b07431a9b 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -108,7 +108,6 @@ class TypeLookupManager; namespace fastdds { -class TopicAttributes; class MessageReceiver; namespace rtps { @@ -897,59 +896,55 @@ class RTPSParticipantImpl /** * Register a Writer in the BuiltinProtocols. * @param Writer Pointer to the RTPSWriter. - * @param topicAtt TopicAttributes of the Writer. + * @param pub_builtin_data Contains the discovery information of the writer. * @param wqos WriterQos. * @return True if correctly registered. */ - bool registerWriter( + bool register_writer( RTPSWriter* Writer, - const TopicAttributes& topicAtt, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos); /** * Register a Reader in the BuiltinProtocols. - * @param Reader Pointer to the RTPSReader. - * @param topicAtt TopicAttributes of the Reader. - * @param rqos ReaderQos. - * @param content_filter Optional content filtering information. + * @param Reader Pointer to the RTPSReader. + * @param sub_builtin_data Contains the discovery information of the reader. + * @param rqos ReaderQos. + * @param content_filter Optional content filtering information. * @return True if correctly registered. */ - bool registerReader( + bool register_reader( RTPSReader* Reader, - const TopicAttributes& topicAtt, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); /** * Update participant attributes. * @param patt New participant attributes. - * @return True on success, false otherwise. */ void update_attributes( const RTPSParticipantAttributes& patt); /** * Update local writer QoS - * @param Writer Writer to update - * @param wqos New QoS for the writer + * @param rtps_writer Writer to update. + * @param wqos New QoS for the writer. * @return True on success */ - bool updateLocalWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, + bool update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos); /** * Update local reader QoS - * @param Reader Reader to update - * @param topicAtt TopicAttributes of the Reader. - * @param rqos New QoS for the reader - * @param content_filter Optional content filtering information. + * @param rtps_reader Reader to update. + * @param rqos New QoS for the reader. + * @param content_filter Optional content filtering information. * @return True on success */ - bool updateLocalReader( - RTPSReader* Reader, - const TopicAttributes& topicAtt, + bool update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index 50f1695c64e..ea6fcd9e396 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -58,8 +58,6 @@ class TypeLookupManager; } // namespace builtin } // namespace dds -class TopicAttributes; - namespace rtps { struct PublicationBuiltinTopicData; From c69b36e18d4af2ee04eafd9f88309d632ba23237 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:02:27 +0200 Subject: [PATCH 05/37] Refs #21357: Include PublicationBuiltinTopicData in RTPS and refactor some APIS to snake case Signed-off-by: Mario Dominguez --- .../rtps/participant/RTPSParticipant.hpp | 26 +++++------ src/cpp/rtps/builtin/BuiltinProtocols.cpp | 29 ++++++------ src/cpp/rtps/builtin/BuiltinProtocols.h | 34 +++++++------- .../rtps/builtin/discovery/endpoint/EDP.cpp | 45 +++++++++---------- .../builtin/discovery/endpoint/EDPClient.cpp | 20 ++++----- .../builtin/discovery/endpoint/EDPClient.h | 12 ++--- .../builtin/discovery/endpoint/EDPServer.cpp | 10 ++--- .../builtin/discovery/endpoint/EDPServer.hpp | 4 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 22 ++++----- .../builtin/discovery/endpoint/EDPSimple.h | 22 +++++---- .../builtin/discovery/endpoint/EDPStatic.cpp | 10 ++--- .../builtin/discovery/endpoint/EDPStatic.h | 22 +++++---- .../rtps/builtin/discovery/participant/PDP.h | 2 +- .../participant/timedevent/DSClientEvent.cpp | 2 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 15 +++---- .../rtps/participant/RTPSParticipantImpl.cpp | 23 +++++----- src/cpp/rtps/security/SecurityManager.cpp | 4 +- .../rtps/monitor-service/MonitorService.cpp | 27 +++++------ .../rtps/monitor-service/MonitorService.hpp | 3 +- .../common/RTPSBlackboxTestsBasic.cpp | 6 ++- .../common/RTPSWithRegistrationWriter.hpp | 15 ++++--- .../EDP/rtps/builtin/discovery/endpoint/EDP.h | 4 +- .../rtps/builtin/discovery/participant/PDP.h | 2 +- .../builtin/discovery/participant/PDPSimple.h | 2 +- .../rtps/participant/RTPSParticipant.hpp | 7 ++- test/unittest/dds/topic/TopicTests.cpp | 1 - test/unittest/rtps/discovery/EdpTests.cpp | 4 +- .../rtps/reader/StatefulReaderTests.cpp | 10 ++--- .../statistics/rtps/MonitorServiceTests.cpp | 2 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 11 +++-- .../rtps/monitor-service/MonitorService.hpp | 10 ++++- 31 files changed, 201 insertions(+), 205 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 46c618c954e..0098a53d1ac 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -139,15 +139,15 @@ class FASTDDS_EXPORTED_API RTPSParticipant uint32_t getRTPSParticipantID() const; /** - * Register a RTPSWriter in the builtin Protocols. - * @param Writer Pointer to the RTPSWriter. - * @param topicAtt Topic Attributes where you want to register it. + * Register a Writer in the BuiltinProtocols. + * @param rtps_writer Pointer to the RTPSWriter. + * @param pub_builtin_data Contains the discovery information of the writer. * @param wqos WriterQos. * @return True if correctly registered. */ - bool registerWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, + bool register_writer( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos); /** @@ -172,15 +172,13 @@ class FASTDDS_EXPORTED_API RTPSParticipant const RTPSParticipantAttributes& patt); /** - * Update writer QOS - * @param Writer to update - * @param topicAtt Topic Attributes where you want to register it. - * @param wqos New writer QoS - * @return true on success + * Update local writer QoS + * @param rtps_writer Writer to update. + * @param wqos New QoS for the writer. + * @return True on success */ - bool updateWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, + bool update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos); /** diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 9e36ab50266..0d2a45f6f02 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -195,16 +195,16 @@ void BuiltinProtocols::filter_server_remote_locators( m_DiscoveryServers.swap(allowed_locators); } -bool BuiltinProtocols::addLocalWriter( - RTPSWriter* w, - const fastdds::TopicAttributes& topicAtt, +bool BuiltinProtocols::add_writer( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) { bool ok = true; if (nullptr != mp_PDP) { - ok = mp_PDP->getEDP()->newLocalWriterProxyData(w, topicAtt, wqos); + ok = mp_PDP->get_edp()->new_writer_proxy_data(rtps_writer, pub_builtin_data, wqos); if (!ok) { @@ -219,7 +219,7 @@ bool BuiltinProtocols::addLocalWriter( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_writer(w, wqos); + ok &= mp_WLP->add_local_writer(rtps_writer, wqos); } else { @@ -260,15 +260,14 @@ bool BuiltinProtocols::addLocalReader( return ok; } -bool BuiltinProtocols::updateLocalWriter( - RTPSWriter* W, - const TopicAttributes& topicAtt, +bool BuiltinProtocols::update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos) { bool ok = false; - if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP())) + if ((nullptr != mp_PDP) && (nullptr != mp_PDP->get_edp())) { - ok = mp_PDP->getEDP()->updatedLocalWriter(W, topicAtt, wqos); + ok = mp_PDP->get_edp()->update_writer(rtps_writer, wqos); } return ok; } @@ -287,17 +286,17 @@ bool BuiltinProtocols::updateLocalReader( return ok; } -bool BuiltinProtocols::removeLocalWriter( - RTPSWriter* W) +bool BuiltinProtocols::remove_writer( + RTPSWriter* rtps_writer) { bool ok = false; if (nullptr != mp_WLP) { - ok |= mp_WLP->remove_local_writer(W); + ok |= mp_WLP->remove_local_writer(rtps_writer); } - if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP())) + if ((nullptr != mp_PDP) && (nullptr != mp_PDP->get_edp())) { - ok |= mp_PDP->getEDP()->removeLocalWriter(W); + ok |= mp_PDP->get_edp()->remove_writer(rtps_writer); } return ok; } diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index 07b79135977..b3d732e8e48 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -53,6 +53,7 @@ class RTPSParticipantImpl; class RTPSWriter; class RTPSReader; class NetworkFactory; +struct PublicationBuiltinTopicData; /** * Class BuiltinProtocols that contains builtin endpoints implementing the discovery and liveliness protocols. @@ -126,15 +127,15 @@ class BuiltinProtocols LocatorList_t m_DiscoveryServers; /** - * Add a local Writer to the BuiltinProtocols. - * @param w Pointer to the RTPSWriter + * Add a local writer to the BuiltinProtocols. + * @param writer Pointer to the RTPSWriter * @param topicAtt Attributes of the associated topic - * @param wqos QoS policies dictated by the publisher + * @param wqos QoS policies dictated by the publisher * @return True if correct. */ - bool addLocalWriter( - RTPSWriter* w, - const TopicAttributes& topicAtt, + bool add_writer( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos); /** * Add a local Reader to the BuiltinProtocols. @@ -152,21 +153,18 @@ class BuiltinProtocols /** * Update a local Writer QOS - * @param W Writer to update - * @param topicAtt Attributes of the associated topic - * @param wqos New Writer QoS + * @param rtps_writer Writer to update + * @param wqos New Writer QoS * @return */ - bool updateLocalWriter( - RTPSWriter* W, - const TopicAttributes& topicAtt, + bool update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos); /** * Update a local Reader QOS - * @param R Reader to update - * @param topicAtt Attributes of the associated topic - * @param qos New Reader QoS - * @param content_filter Optional content filtering information. + * @param rtps_reader Reader to update + * @param rqos New Reader QoS + * @param content_filter Optional content filtering information. * @return */ bool updateLocalReader( @@ -179,8 +177,8 @@ class BuiltinProtocols * @param W Pointer to the writer. * @return True if correctly removed. */ - bool removeLocalWriter( - RTPSWriter* W); + bool remove_writer( + RTPSWriter* rtps_writer); /** * Remove a local Reader from the builtinProtocols. * @param R Pointer to the reader. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 53e1da5ab9c..b2b59790dda 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -234,14 +233,14 @@ bool EDP::newLocalReaderProxyData( return true; } -bool EDP::newLocalWriterProxyData( - RTPSWriter* writer, - const TopicAttributes& att, +bool EDP::new_writer_proxy_data( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << writer->getGuid().entityId << " in topic " << att.topicName); + EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_writer->getGuid().entityId << " in topic " << pub_builtin_data.topic_name.to_string()); - auto init_fun = [this, writer, &att, &wqos]( + auto init_fun = [this, rtps_writer, &pub_builtin_data, &wqos]( WriterProxyData* wpd, bool updating, const ParticipantProxyData& participant_data) @@ -249,15 +248,15 @@ bool EDP::newLocalWriterProxyData( if (updating) { EPROSIMA_LOG_ERROR(RTPS_EDP, - "Adding already existent writer " << writer->getGuid().entityId << " in topic " - << att.topicName); + "Adding already existent writer " << rtps_writer->getGuid().entityId << " in topic " + << pub_builtin_data.topic_name.to_string()); return false; } const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - const auto& watt = writer->getAttributes(); + const auto& watt = rtps_writer->getAttributes(); - wpd->guid(writer->getGuid()); + wpd->guid(rtps_writer->getGuid()); wpd->key() = wpd->guid(); if (watt.multicastLocatorList.empty() && watt.unicastLocatorList.empty()) { @@ -271,9 +270,9 @@ bool EDP::newLocalWriterProxyData( watt.external_unicast_locators); } wpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); - wpd->topicName(att.getTopicName()); - wpd->typeName(att.getTopicDataType()); - wpd->topicKind(att.getTopicKind()); + wpd->topicName(pub_builtin_data.topic_name); + wpd->typeName(pub_builtin_data.type_name); + wpd->topicKind((wpd->guid().entityId.value[3] & 0x0F) == 0x02 ? WITH_KEY : NO_KEY); using dds::utils::TypePropagation; using dds::xtypes::TypeInformationParameter; @@ -281,19 +280,20 @@ bool EDP::newLocalWriterProxyData( auto type_propagation = mp_RTPSParticipant->type_propagation(); assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation); - if (att.type_information.assigned()) + const auto& type_info = pub_builtin_data.type_information; + if (type_info.assigned()) { switch (type_propagation) { case TypePropagation::TYPEPROPAGATION_ENABLED: { - wpd->type_information(att.type_information); + wpd->type_information(type_info); break; } case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: { TypeInformationParameter minimal; - minimal.type_information.minimal(att.type_information.type_information.minimal()); + minimal.type_information.minimal(type_info.type_information.minimal()); minimal.assigned(true); wpd->type_information(minimal); break; @@ -310,7 +310,7 @@ bool EDP::newLocalWriterProxyData( } } - BaseWriter* base_writer = BaseWriter::downcast(writer); + BaseWriter* base_writer = BaseWriter::downcast(rtps_writer); assert(base_writer->get_history() != nullptr); wpd->typeMaxSerialized(base_writer->get_history()->getTypeMaxSerialized()); wpd->m_qos.setQos(wqos, true); @@ -334,7 +334,7 @@ bool EDP::newLocalWriterProxyData( //ADD IT TO THE LIST OF READERPROXYDATA GUID_t participant_guid; - WriterProxyData* writer_data = this->mp_PDP->addWriterProxyData(writer->getGuid(), participant_guid, init_fun); + WriterProxyData* writer_data = this->mp_PDP->addWriterProxyData(rtps_writer->getGuid(), participant_guid, init_fun); if (writer_data == nullptr) { return false; @@ -353,9 +353,9 @@ bool EDP::newLocalWriterProxyData( { pairing_writer_proxy_with_any_local_reader(participant_guid, writer_data); } - pairingWriter(writer, participant_guid, *writer_data); + pairingWriter(rtps_writer, participant_guid, *writer_data); //DO SOME PROCESSING DEPENDING ON THE IMPLEMENTATION (SIMPLE OR STATIC) - processLocalWriterProxyData(writer, writer_data); + process_writer_proxy_data(rtps_writer, writer_data); return true; } @@ -433,9 +433,8 @@ bool EDP::updatedLocalReader( return false; } -bool EDP::updatedLocalWriter( +bool EDP::update_writer( RTPSWriter* writer, - const TopicAttributes&, const fastdds::dds::WriterQos& wqos) { auto init_fun = [this, writer, &wqos]( @@ -467,7 +466,7 @@ bool EDP::updatedLocalWriter( WriterProxyData* writer_data = this->mp_PDP->addWriterProxyData(writer->getGuid(), participant_guid, init_fun); if (writer_data != nullptr) { - processLocalWriterProxyData(writer, writer_data); + process_writer_proxy_data(writer, writer_data); #ifdef FASTDDS_STATISTICS // notify monitor service about the new local entity proxy update diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp index 7a8e39ba2eb..ebba04cc1ac 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp @@ -71,17 +71,17 @@ bool EDPClient::processLocalReaderProxyData( return ret_val; } -bool EDPClient::processLocalWriterProxyData( - RTPSWriter* local_writer, +bool EDPClient::process_writer_proxy_data( + RTPSWriter* rtps_writer, WriterProxyData* wdata) { EPROSIMA_LOG_INFO(RTPS_EDP, wdata->guid().entityId); - (void)local_writer; + (void)rtps_writer; auto* writer = &publications_writer_; #if HAVE_SECURITY - if (local_writer->getAttributes().security_attributes().is_discovery_protected) + if (rtps_writer->getAttributes().security_attributes().is_discovery_protected) { writer = &publications_secure_writer_; } @@ -104,15 +104,15 @@ bool EDPClient::processLocalWriterProxyData( return ret_val; } -bool EDPClient::removeLocalWriter( - RTPSWriter* W) +bool EDPClient::remove_writer( + RTPSWriter* rtps_writer) { - EPROSIMA_LOG_INFO(RTPS_EDP, W->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, rtps_writer->getGuid().entityId); auto* writer = &publications_writer_; #if HAVE_SECURITY - if (W->getAttributes().security_attributes().is_discovery_protected) + if (rtps_writer->getAttributes().security_attributes().is_discovery_protected) { writer = &publications_secure_writer_; } @@ -121,7 +121,7 @@ bool EDPClient::removeLocalWriter( if (writer->first != nullptr) { InstanceHandle_t iH; - iH = W->getGuid(); + iH = rtps_writer->getGuid(); CacheChange_t* change = EDPUtils::create_change(*writer, NOT_ALIVE_DISPOSED_UNREGISTERED, iH, mp_PDP->builtin_attributes().writerPayloadSize); if (change != nullptr) @@ -150,7 +150,7 @@ bool EDPClient::removeLocalWriter( writer->second->add_change(change, wp); } } - return mp_PDP->removeWriterProxyData(W->getGuid()); + return mp_PDP->removeWriterProxyData(rtps_writer->getGuid()); } bool EDPClient::removeLocalReader( diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h index e0c92ea8cf1..a241f3a2c00 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h @@ -58,12 +58,12 @@ class EDPClient : public EDPSimple ReaderProxyData* rdata) override; /** * This method generates the corresponding change in the publciations writer and send it to all known remote endpoints. - * @param writer Pointer to the Writer object. + * @param rtps_writer Pointer to the Writer object. * @param wdata Pointer to the WriterProxyData object. * @return true if correct. */ - bool processLocalWriterProxyData( - RTPSWriter* writer, + bool process_writer_proxy_data( + RTPSWriter* rtps_writer, WriterProxyData* wdata) override; /** * This methods generates the change disposing of the local Reader and calls the unpairing and removal methods of the base class. @@ -74,11 +74,11 @@ class EDPClient : public EDPSimple RTPSReader* R) override; /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. - * @param W Pointer to the RTPSWriter object. + * @param rtps_writer Pointer to the RTPSWriter object. * @return True if correct. */ - bool removeLocalWriter( - RTPSWriter* W) override; + bool remove_writer( + RTPSWriter* rtps_writer) override; }; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp index a347b7e857a..5587d47a116 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp @@ -269,14 +269,14 @@ bool EDPServer::removeLocalReader( return false; } -bool EDPServer::removeLocalWriter( - RTPSWriter* W) +bool EDPServer::remove_writer( + RTPSWriter* rtps_writer) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Removing local writer: " << W->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, "Removing local writer: " << rtps_writer->getGuid().entityId); // Get publications writer and writer guid auto* writer = &publications_writer_; - GUID_t guid = W->getGuid(); + GUID_t guid = rtps_writer->getGuid(); // Recover writer information std::string topic_name; @@ -325,7 +325,7 @@ bool EDPServer::removeLocalWriter( return false; } -bool EDPServer::processLocalWriterProxyData( +bool EDPServer::process_writer_proxy_data( RTPSWriter* local_writer, WriterProxyData* wdata) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp index a06e6c1497d..38a1b1ea377 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp @@ -87,7 +87,7 @@ class EDPServer : public EDPSimple * @param wdata Pointer to the WriterProxyData object. * @return true if correct. */ - bool processLocalWriterProxyData( + bool process_writer_proxy_data( RTPSWriter* writer, WriterProxyData* wdata) override; /** @@ -102,7 +102,7 @@ class EDPServer : public EDPSimple * @param W Pointer to the RTPSWriter object. * @return True if correct. */ - bool removeLocalWriter( + bool remove_writer( RTPSWriter* W) override; /** diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index bc2a8e6e581..908e9b9ba98 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -545,17 +545,17 @@ bool EDPSimple::processLocalReaderProxyData( return ret_val; } -bool EDPSimple::processLocalWriterProxyData( - RTPSWriter* local_writer, +bool EDPSimple::process_writer_proxy_data( + RTPSWriter* rtps_writer, WriterProxyData* wdata) { EPROSIMA_LOG_INFO(RTPS_EDP, wdata->guid().entityId); - (void)local_writer; + (void)rtps_writer; auto* writer = &publications_writer_; #if HAVE_SECURITY - if (local_writer->getAttributes().security_attributes().is_discovery_protected) + if (rtps_writer->getAttributes().security_attributes().is_discovery_protected) { writer = &publications_secure_writer_; } @@ -637,15 +637,15 @@ bool EDPSimple::serialize_proxy_data( return true; } -bool EDPSimple::removeLocalWriter( - RTPSWriter* W) +bool EDPSimple::remove_writer( + RTPSWriter* rtps_writer) { - EPROSIMA_LOG_INFO(RTPS_EDP, W->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, rtps_writer->getGuid().entityId); auto* writer = &publications_writer_; #if HAVE_SECURITY - if (W->getAttributes().security_attributes().is_discovery_protected) + if (rtps_writer->getAttributes().security_attributes().is_discovery_protected) { writer = &publications_secure_writer_; } @@ -654,7 +654,7 @@ bool EDPSimple::removeLocalWriter( if (writer->first != nullptr) { InstanceHandle_t iH; - iH = W->getGuid(); + iH = rtps_writer->getGuid(); CacheChange_t* change = EDPUtils::create_change(*writer, NOT_ALIVE_DISPOSED_UNREGISTERED, iH, mp_PDP->builtin_attributes().writerPayloadSize); if (change != nullptr) @@ -680,11 +680,11 @@ bool EDPSimple::removeLocalWriter( // notify monitor service about the new local entity proxy update if (nullptr != this->mp_PDP->get_proxy_observer()) { - this->mp_PDP->get_proxy_observer()->on_local_entity_change(W->getGuid(), false); + this->mp_PDP->get_proxy_observer()->on_local_entity_change(rtps_writer->getGuid(), false); } #endif //FASTDDS_STATISTICS - return mp_PDP->removeWriterProxyData(W->getGuid()); + return mp_PDP->removeWriterProxyData(rtps_writer->getGuid()); } bool EDPSimple::removeLocalReader( diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h index 480259bbc86..fe21a0911f1 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h @@ -17,9 +17,8 @@ * */ -#ifndef _FASTDDS_RTPS_EDPSIMPLE_H_ -#define _FASTDDS_RTPS_EDPSIMPLE_H_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSIMPLE_H +#define FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSIMPLE_H #include #include @@ -132,12 +131,12 @@ class EDPSimple : public EDP ReaderProxyData* rdata) override; /** * This method generates the corresponding change in the publciations writer and send it to all known remote endpoints. - * @param writer Pointer to the Writer object. - * @param wdata Pointer to the WriterProxyData object. + * @param rtps_writer Pointer to the Writer object. + * @param wdata Pointer to the WriterProxyData object. * @return true if correct. */ - bool processLocalWriterProxyData( - RTPSWriter* writer, + bool process_writer_proxy_data( + RTPSWriter* rtps_writer, WriterProxyData* wdata) override; /** * This methods generates the change disposing of the local Reader and calls the unpairing and removal methods of the base class. @@ -148,11 +147,11 @@ class EDPSimple : public EDP RTPSReader* R) override; /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. - * @param W Pointer to the RTPSWriter object. + * @param rtps_writer Pointer to the RTPSWriter object. * @return True if correct. */ - bool removeLocalWriter( - RTPSWriter* W) override; + bool remove_writer( + RTPSWriter* rtps_writer) override; protected: @@ -287,5 +286,4 @@ class EDPSimple : public EDP } /* namespace fastdds */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* _FASTDDS_RTPS_EDPSIMPLE_H_ */ +#endif /* FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSIMPLE_H */ diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index c54219c60b7..864b661f5dc 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -337,7 +337,7 @@ bool EDPStatic::processLocalReaderProxyData( return true; } -bool EDPStatic::processLocalWriterProxyData( +bool EDPStatic::process_writer_proxy_data( RTPSWriter*, WriterProxyData* wdata) { @@ -379,8 +379,8 @@ bool EDPStatic::removeLocalReader( return false; } -bool EDPStatic::removeLocalWriter( - RTPSWriter* W) +bool EDPStatic::remove_writer( + RTPSWriter* rtps_writer) { std::lock_guard guard(*mp_PDP->getMutex()); ParticipantProxyData* localpdata = this->mp_PDP->getLocalParticipantProxyData(); @@ -390,10 +390,10 @@ bool EDPStatic::removeLocalWriter( EDPStaticProperty staticproperty; if (staticproperty.fromProperty((*pit).pair())) { - if (staticproperty.m_entityId == W->getGuid().entityId) + if (staticproperty.m_entityId == rtps_writer->getGuid().entityId) { auto new_property = EDPStaticProperty::toProperty(exchange_format_, "Writer", "ENDED", - W->getAttributes().getUserDefinedID(), W->getGuid().entityId); + rtps_writer->getAttributes().getUserDefinedID(), rtps_writer->getGuid().entityId); if (!pit->modify(new_property)) { EPROSIMA_LOG_ERROR(RTPS_EDP, "Failed to change property <" diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h index 164bf241bf1..4a7a9c56d82 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h @@ -17,9 +17,8 @@ * */ -#ifndef _FASTDDS_RTPS_EDPSTATIC_H_ -#define _FASTDDS_RTPS_EDPSTATIC_H_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSTATIC_H +#define FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSTATIC_H #include @@ -80,11 +79,11 @@ class EDPStatic : public EDP RTPSReader* R) override; /** * Abstract method that removes a local Writer from the discovery method - * @param W Pointer to the Writer to remove. + * @param rtps_writer Pointer to the writer to remove. * @return True if correctly removed. */ - bool removeLocalWriter( - RTPSWriter* W) override; + bool remove_writer( + RTPSWriter* rtps_writer) override; /** * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation). @@ -97,12 +96,12 @@ class EDPStatic : public EDP ReaderProxyData* rdata) override; /** * After a new local WriterProxyData has been created some processing is needed (depends on the implementation). - * @param writer Pointer to the RTPSWriter object. - * @param wdata Pointer to the Writer ProxyData object. + * @param rtps_writer Pointer to the RTPSWriter object. + * @param wdata Pointer to the Writer ProxyData object. * @return True if correct. */ - bool processLocalWriterProxyData( - RTPSWriter* writer, + bool process_writer_proxy_data( + RTPSWriter* rtps_writer, WriterProxyData* wdata) override; /** @@ -162,5 +161,4 @@ class EDPStatic : public EDP } /* namespace rtps */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* _FASTDDS_RTPS_EDPSTATIC_H_ */ +#endif /* FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDPSTATIC_H */ diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.h b/src/cpp/rtps/builtin/discovery/participant/PDP.h index a74d5bb45de..884da0daef9 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.h @@ -342,7 +342,7 @@ class PDP : public fastdds::statistics::rtps::IProxyQueryable * Get a pointer to the EDP object. * @return pointer to the EDP object. */ - inline EDP* getEDP() + inline EDP* get_edp() { return mp_EDP; } diff --git a/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp b/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp index 58104b39b01..1c32d2b7402 100644 --- a/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp @@ -43,7 +43,7 @@ DSClientEvent::DSClientEvent( return event(); }, interval) , mp_PDP(p_PDP) - , mp_EDP(static_cast(mp_PDP->getEDP())) + , mp_EDP(static_cast(mp_PDP->get_edp())) { } diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 6dbed268b2f..2d75115609f 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -75,12 +75,12 @@ uint32_t RTPSParticipant::getRTPSParticipantID() const return mp_impl->getRTPSParticipantID(); } -bool RTPSParticipant::registerWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, +bool RTPSParticipant::register_writer( + RTPSWriter* writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) { - return mp_impl->registerWriter(Writer, topicAtt, wqos); + return mp_impl->register_writer(writer, pub_builtin_data, wqos); } bool RTPSParticipant::registerReader( @@ -98,12 +98,11 @@ void RTPSParticipant::update_attributes( mp_impl->update_attributes(patt); } -bool RTPSParticipant::updateWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, +bool RTPSParticipant::update_writer( + RTPSWriter* writer, const fastdds::dds::WriterQos& wqos) { - return mp_impl->updateLocalWriter(Writer, topicAtt, wqos); + return mp_impl->update_writer(writer, wqos); } bool RTPSParticipant::updateReader( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 829f6108cfd..6cab26acbde 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1404,12 +1404,12 @@ void RTPSParticipantImpl::disableReader( m_receiverResourcelistMutex.unlock(); } -bool RTPSParticipantImpl::registerWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, +bool RTPSParticipantImpl::register_writer( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) { - return this->mp_builtinProtocols->addLocalWriter(Writer, topicAtt, wqos); + return this->mp_builtinProtocols->add_writer(rtps_writer, pub_builtin_data, wqos); } bool RTPSParticipantImpl::registerReader( @@ -1606,12 +1606,11 @@ void RTPSParticipantImpl::update_attributes( } } -bool RTPSParticipantImpl::updateLocalWriter( - RTPSWriter* Writer, - const TopicAttributes& topicAtt, +bool RTPSParticipantImpl::update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& wqos) { - return this->mp_builtinProtocols->updateLocalWriter(Writer, topicAtt, wqos); + return this->mp_builtinProtocols->update_writer(rtps_writer, wqos); } bool RTPSParticipantImpl::updateLocalReader( @@ -2000,7 +1999,7 @@ bool RTPSParticipantImpl::deleteUserEndpoint( { if (found_in_users) { - mp_builtinProtocols->removeLocalWriter(static_cast(p_endpoint)); + mp_builtinProtocols->remove_writer(static_cast(p_endpoint)); } #if HAVE_SECURITY @@ -2090,7 +2089,7 @@ void RTPSParticipantImpl::deleteAllUserEndpoints() auto removeEndpoint = [this](EndpointKind_t kind, Endpoint* p) { return kind == WRITER - ? mp_builtinProtocols->removeLocalWriter((RTPSWriter*)p) + ? mp_builtinProtocols->remove_writer((RTPSWriter*)p) : mp_builtinProtocols->removeLocalReader((RTPSReader*)p); }; @@ -2880,10 +2879,10 @@ const fastdds::statistics::rtps::IStatusObserver* RTPSParticipantImpl::create_mo return this->createWriter(WriterOut, param, hist, listen, entityId, isBuiltin); }, [&](RTPSWriter* w, - const fastdds::TopicAttributes& topicAtt, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) -> bool { - return this->registerWriter(w, topicAtt, wqos); + return this->register_writer(w, pub_builtin_data, wqos); }, getEventResource() )); diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 2474799cdf9..ca68fce8bfc 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -4069,13 +4069,13 @@ bool SecurityManager::participant_authorized( for (auto& remote_reader : temp_readers) { - participant_->pdp()->getEDP()->pairing_reader_proxy_with_local_writer(remote_reader.second, + participant_->pdp()->get_edp()->pairing_reader_proxy_with_local_writer(remote_reader.second, participant_data.m_guid, remote_reader.first); } for (auto& remote_writer : temp_writers) { - participant_->pdp()->getEDP()->pairing_writer_proxy_with_local_reader(remote_writer.second, + participant_->pdp()->get_edp()->pairing_writer_proxy_with_local_reader(remote_writer.second, participant_data.m_guid, remote_writer.first); } diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 8412a6f74da..17299ff7114 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -445,13 +445,15 @@ bool MonitorService::create_endpoint() hatt.initialReservedCaches = 25; hatt.maximumReservedCaches = 0; - TopicAttributes tatt; - tatt.historyQos.kind = dds::KEEP_LAST_HISTORY_QOS; - tatt.historyQos.depth = 1; - tatt.topicKind = WITH_KEY; - tatt.topicName = MONITOR_SERVICE_TOPIC; - tatt.resourceLimitsQos.max_instances = 0; - tatt.resourceLimitsQos.max_samples_per_instance = 1; + dds::HistoryQosPolicy hqos; + hqos.kind = dds::KEEP_LAST_HISTORY_QOS; + hqos.depth = 1; + + TopicKind_t topic_kind = WITH_KEY; + + dds::ResourceLimitsQosPolicy rl_qos; + rl_qos.max_instances = 0; + rl_qos.max_samples_per_instance = 1; PoolConfig writer_pool_cfg = PoolConfig::from_history_attributes(hatt); status_writer_payload_pool_ = TopicPayloadPoolRegistry::get(MONITOR_SERVICE_TOPIC, writer_pool_cfg); @@ -460,7 +462,7 @@ bool MonitorService::create_endpoint() status_writer_history_.reset(new eprosima::fastdds::dds::DataWriterHistory( status_writer_payload_pool_, std::make_shared(writer_pool_cfg), - tatt, type_.max_serialized_type_size, + hqos, rl_qos, topic_kind, type_.max_serialized_type_size, MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE, []( const InstanceHandle_t& ) -> void @@ -486,12 +488,11 @@ bool MonitorService::create_endpoint() wqos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; wqos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; - TopicAttributes tatts; - tatts.topicName = MONITOR_SERVICE_TOPIC; - tatts.topicDataType = type_.get_name(); - tatts.topicKind = WITH_KEY; + PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.topic_name = MONITOR_SERVICE_TOPIC; + pub_builtin_data.type_name = type_.get_name(); - endpoint_registrator_(status_writer_, tatts, wqos); + endpoint_registrator_(status_writer_, pub_builtin_data, wqos); } else { diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp index 88546865d96..02e19feb004 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -81,7 +82,7 @@ class MonitorService using endpoint_registrator_t = std::function; MonitorService( diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index 8d82942c0c7..c1c7e58f0e1 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -807,7 +807,6 @@ TEST(RTPS, MultithreadedWriterCreation) /* Create writer history */ eprosima::fastdds::rtps::HistoryAttributes hattr; eprosima::fastdds::rtps::WriterHistory* history = new eprosima::fastdds::rtps::WriterHistory(hattr); - eprosima::fastdds::TopicAttributes topic_attr; /* Create writer with a flow controller */ eprosima::fastdds::rtps::WriterAttributes writer_attr; @@ -816,9 +815,12 @@ TEST(RTPS, MultithreadedWriterCreation) eprosima::fastdds::rtps::RTPSWriter* writer = eprosima::fastdds::rtps::RTPSDomain::createRTPSWriter( rtps_participant, writer_attr, history, nullptr); + PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.type_name = "string"; + pub_builtin_data.topic_name = "test_topic"; /* Register writer in participant */ eprosima::fastdds::dds::WriterQos writer_qos; - ASSERT_EQ(rtps_participant->registerWriter(writer, topic_attr, writer_qos), true); + ASSERT_EQ(rtps_participant->register_writer(writer, pub_builtin_data, writer_qos), true); { /* Wait for test completion request */ diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index 116b51d481b..f2c74236430 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -124,11 +124,11 @@ class RTPSWithRegistrationWriter , initialized_(false) , matched_(0) { - topic_attr_.topicDataType = type_.get_name(); + pub_builtin_data_.type_name = type_.get_name(); // Generate topic name std::ostringstream t; t << topic_name << "_" << asio::ip::host_name() << "_" << GET_PID(); - topic_attr_.topicName = t.str(); + pub_builtin_data_.topic_name = t.str(); // By default, heartbeat period and nack response delay are 100 milliseconds. writer_attr_.times.heartbeat_period.seconds = 0; @@ -178,7 +178,7 @@ class RTPSWithRegistrationWriter return; } - ASSERT_EQ(participant_->registerWriter(writer_, topic_attr_, writer_qos_), true); + ASSERT_EQ(participant_->register_writer(writer_, pub_builtin_data_, writer_qos_), true); initialized_ = true; } @@ -190,7 +190,7 @@ class RTPSWithRegistrationWriter return; } - ASSERT_TRUE(participant_->updateWriter(writer_, topic_attr_, writer_qos_)); + ASSERT_TRUE(participant_->update_writer(writer_, writer_qos_)); } void destroy() @@ -466,7 +466,8 @@ class RTPSWithRegistrationWriter RTPSWithRegistrationWriter& history_depth( const int32_t depth) { - topic_attr_.historyQos.depth = depth; + hattr_.maximumReservedCaches = depth; + hattr_.initialReservedCaches = std::min(hattr_.initialReservedCaches, depth); return *this; } @@ -586,7 +587,7 @@ class RTPSWithRegistrationWriter eprosima::fastdds::rtps::RTPSWriter* writer_; eprosima::fastdds::rtps::WriterAttributes writer_attr_; eprosima::fastdds::dds::WriterQos writer_qos_; - eprosima::fastdds::TopicAttributes topic_attr_; + eprosima::fastdds::rtps::PublicationBuiltinTopicData pub_builtin_data_; eprosima::fastdds::rtps::WriterHistory* history_; eprosima::fastdds::rtps::HistoryAttributes hattr_; bool initialized_; diff --git a/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h b/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h index 54bce71540b..d959f143b94 100644 --- a/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h +++ b/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h @@ -63,7 +63,7 @@ class EDP return true; } - virtual bool removeLocalWriter( + virtual bool remove_writer( eprosima::fastdds::rtps::RTPSWriter*) { return true; @@ -83,7 +83,7 @@ class EDP return true; } - virtual bool processLocalWriterProxyData( + virtual bool process_writer_proxy_data( eprosima::fastdds::rtps::RTPSWriter*, eprosima::fastdds::rtps::WriterProxyData*) { diff --git a/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h b/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h index 2c0ac9f2575..242e938ac05 100644 --- a/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h +++ b/test/mock/rtps/PDP/rtps/builtin/discovery/participant/PDP.h @@ -60,7 +60,7 @@ class PDP MOCK_METHOD0(createPDPEndpoints, bool()); - MOCK_METHOD0(getEDP, EDP*()); + MOCK_METHOD0(get_edp, EDP*()); #ifdef FASTDDS_STATISTICS MOCK_METHOD0(get_proxy_observer, const fastdds::statistics::rtps::IProxyObserver*()); diff --git a/test/mock/rtps/PDPSimple/rtps/builtin/discovery/participant/PDPSimple.h b/test/mock/rtps/PDPSimple/rtps/builtin/discovery/participant/PDPSimple.h index ecdfff04ee2..ad534e4351b 100644 --- a/test/mock/rtps/PDPSimple/rtps/builtin/discovery/participant/PDPSimple.h +++ b/test/mock/rtps/PDPSimple/rtps/builtin/discovery/participant/PDPSimple.h @@ -38,7 +38,7 @@ class PDPSimple MOCK_METHOD1(get_participant_proxy_data_serialized, CDRMessage_t(Endianness_t)); - EDP* getEDP() + EDP* get_edp() { return &edp_; } diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index ea6fcd9e396..f5ff38c5619 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -185,14 +185,13 @@ class FASTDDS_EXPORTED_API RTPSParticipant MOCK_CONST_METHOD0(typelookup_manager, fastdds::dds::builtin::TypeLookupManager* ()); - MOCK_METHOD3(registerWriter, bool( + MOCK_METHOD3(register_writer, bool( RTPSWriter * Writer, - const TopicAttributes& topicAtt, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos)); - MOCK_METHOD3(updateWriter, bool( + MOCK_METHOD2(update_writer, bool( RTPSWriter * Writer, - const TopicAttributes& topicAtt, const fastdds::dds::WriterQos& wqos)); MOCK_METHOD3(registerReader, bool( diff --git a/test/unittest/dds/topic/TopicTests.cpp b/test/unittest/dds/topic/TopicTests.cpp index 670d248495a..13ea0195d76 100644 --- a/test/unittest/dds/topic/TopicTests.cpp +++ b/test/unittest/dds/topic/TopicTests.cpp @@ -22,7 +22,6 @@ #include #include #include -#include namespace eprosima { namespace fastdds { diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index ba238dc50a6..86a2442a5ef 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -66,7 +66,7 @@ class EDPMock : public EDP return true; } - bool removeLocalWriter( + bool remove_writer( RTPSWriter* /*W*/) override { return true; @@ -79,7 +79,7 @@ class EDPMock : public EDP return true; } - bool processLocalWriterProxyData( + bool process_writer_proxy_data( RTPSWriter* /*writer*/, WriterProxyData* /*wdata*/) override { diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index f3828aace75..74b5892f730 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -90,12 +90,10 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) ASSERT_NE(writer, nullptr); // Register both endpoints - TopicAttributes topic_att; - topic_att.topicKind = NO_KEY; - topic_att.topicDataType = "string"; - topic_att.topicName = "topic"; - part->registerReader(reader, topic_att, {}); - part->registerWriter(writer, topic_att, {}); + PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.type_name = "string"; + pub_builtin_data.topic_name = "topic"; + part->register_writer(writer, pub_builtin_data, {}); // After registration, the writer should be matched auto writer_guid = writer->getGuid(); diff --git a/test/unittest/statistics/rtps/MonitorServiceTests.cpp b/test/unittest/statistics/rtps/MonitorServiceTests.cpp index 9d2b408fea2..b6ac7b8c386 100644 --- a/test/unittest/statistics/rtps/MonitorServiceTests.cpp +++ b/test/unittest/statistics/rtps/MonitorServiceTests.cpp @@ -78,7 +78,7 @@ class MonitorServiceTests : public ::testing::Test }, [&]( fastdds::rtps::RTPSWriter*, - const fastdds::TopicAttributes&, + const ::eprosima::fastdds::rtps::PublicationBuiltinTopicData&, const fastdds::dds::WriterQos&)->bool { return true; diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 77737f0a58b..4755f712dbd 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -352,17 +352,16 @@ class RTPSStatisticsTestsImpl } void match_endpoints( - bool key, + bool /* key */, fastcdr::string_255 data_type, fastcdr::string_255 topic_name) { using namespace fastdds; using namespace fastdds::rtps; - TopicAttributes Tatt; - Tatt.topicKind = key ? TopicKind_t::WITH_KEY : TopicKind_t::NO_KEY; - Tatt.topicDataType = data_type; - Tatt.topicName = topic_name; + PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.type_name = data_type; + pub_builtin_data.topic_name = topic_name; dds::WriterQos Wqos; auto& watt = writer_->getAttributes(); @@ -378,7 +377,7 @@ class RTPSStatisticsTestsImpl RELIABLE == ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - participant_->registerWriter(writer_, Tatt, Wqos); + participant_->register_writer(writer_, pub_builtin_data, Wqos); participant_->registerReader(reader_, Tatt, Rqos); } diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index 10d47e833c6..28e5d6e64cc 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -41,6 +42,13 @@ namespace eprosima { namespace fastdds { + +namespace rtps { + +struct PublicationBuiltinTopicData; + +} // namespace rtps + namespace statistics { namespace rtps { @@ -61,7 +69,7 @@ class MonitorService using endpoint_registrator_t = std::function; MonitorService( From 024fa618a5ddac9de689ab385216f89a3f1dbfe3 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:06:08 +0200 Subject: [PATCH 06/37] Refs #21357: Include SubscriptionBuiltinTopicData in RTPS and refactor some APIS to snake case Signed-off-by: Mario Dominguez --- .../rtps/participant/RTPSParticipant.hpp | 32 ++++---- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 29 ++++---- src/cpp/rtps/builtin/BuiltinProtocols.h | 22 +++--- .../rtps/builtin/discovery/endpoint/EDP.cpp | 62 ++++++++-------- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 74 +++++++++---------- .../builtin/discovery/endpoint/EDPClient.cpp | 14 ++-- .../builtin/discovery/endpoint/EDPClient.h | 12 +-- .../builtin/discovery/endpoint/EDPServer.cpp | 10 +-- .../builtin/discovery/endpoint/EDPServer.hpp | 4 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 22 +++--- .../builtin/discovery/endpoint/EDPSimple.h | 14 ++-- .../builtin/discovery/endpoint/EDPStatic.cpp | 10 +-- .../builtin/discovery/endpoint/EDPStatic.h | 16 ++-- src/cpp/rtps/participant/RTPSParticipant.cpp | 15 ++-- .../rtps/participant/RTPSParticipantImpl.cpp | 19 +++-- .../common/RTPSBlackboxTestsDiscovery.cpp | 12 +-- .../common/RTPSWithRegistrationReader.hpp | 15 ++-- .../EDP/rtps/builtin/discovery/endpoint/EDP.h | 4 +- .../rtps/participant/RTPSParticipant.hpp | 21 ++---- test/unittest/dds/status/ListenerTests.cpp | 2 +- test/unittest/rtps/discovery/EdpTests.cpp | 4 +- .../rtps/reader/StatefulReaderTests.cpp | 4 + .../statistics/rtps/RTPSStatisticsTests.cpp | 7 +- 23 files changed, 206 insertions(+), 218 deletions(-) diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 0098a53d1ac..9ea6d4af3d7 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -151,16 +151,16 @@ class FASTDDS_EXPORTED_API RTPSParticipant const fastdds::dds::WriterQos& wqos); /** - * Register a RTPSReader in the builtin Protocols. - * @param Reader Pointer to the RTPSReader. - * @param topicAtt Topic Attributes where you want to register it. - * @param rqos ReaderQos. - * @param content_filter Optional content filtering information. + * Register a Reader in the BuiltinProtocols. + * @param rtps_reader Pointer to the RTPSReader. + * @param sub_builtin_data Contains the discovery information of the reader. + * @param rqos ReaderQos. + * @param content_filter Optional content filtering information. * @return True if correctly registered. */ - bool registerReader( - RTPSReader* Reader, - const TopicAttributes& topicAtt, + bool register_reader( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); @@ -182,16 +182,14 @@ class FASTDDS_EXPORTED_API RTPSParticipant const fastdds::dds::WriterQos& wqos); /** - * Update reader QOS - * @param Reader Pointer to the RTPSReader to update - * @param topicAtt Topic Attributes where you want to register it. - * @param rqos New reader QoS - * @param content_filter Optional content filtering information. - * @return true on success + * Update local reader QoS + * @param rtps_reader Reader to update. + * @param rqos New QoS for the reader. + * @param content_filter Optional content filtering information. + * @return True on success */ - bool updateReader( - RTPSReader* Reader, - const TopicAttributes& topicAtt, + bool update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 0d2a45f6f02..d4aafc2819c 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -229,9 +229,9 @@ bool BuiltinProtocols::add_writer( return ok; } -bool BuiltinProtocols::addLocalReader( - RTPSReader* R, - const fastdds::TopicAttributes& topicAtt, +bool BuiltinProtocols::add_reader( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { @@ -239,7 +239,7 @@ bool BuiltinProtocols::addLocalReader( if (nullptr != mp_PDP) { - ok = mp_PDP->getEDP()->newLocalReaderProxyData(R, topicAtt, rqos, content_filter); + ok = mp_PDP->get_edp()->new_reader_proxy_data(rtps_reader, sub_builtin_data, rqos, content_filter); if (!ok) { @@ -254,7 +254,7 @@ bool BuiltinProtocols::addLocalReader( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_reader(R, rqos); + ok &= mp_WLP->add_local_reader(rtps_reader, rqos); } return ok; @@ -272,16 +272,15 @@ bool BuiltinProtocols::update_writer( return ok; } -bool BuiltinProtocols::updateLocalReader( - RTPSReader* R, - const TopicAttributes& topicAtt, +bool BuiltinProtocols::update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { bool ok = false; - if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP())) + if ((nullptr != mp_PDP) && (nullptr != mp_PDP->get_edp())) { - ok = mp_PDP->getEDP()->updatedLocalReader(R, topicAtt, rqos, content_filter); + ok = mp_PDP->get_edp()->update_reader(rtps_reader, rqos, content_filter); } return ok; } @@ -301,17 +300,17 @@ bool BuiltinProtocols::remove_writer( return ok; } -bool BuiltinProtocols::removeLocalReader( - RTPSReader* R) +bool BuiltinProtocols::remove_reader( + RTPSReader* rtps_reader) { bool ok = false; if (nullptr != mp_WLP) { - ok |= mp_WLP->remove_local_reader(R); + ok |= mp_WLP->remove_local_reader(rtps_reader); } - if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP())) + if ((nullptr != mp_PDP) && (nullptr != mp_PDP->get_edp())) { - ok |= mp_PDP->getEDP()->removeLocalReader(R); + ok |= mp_PDP->get_edp()->remove_reader(rtps_reader); } return ok; } diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index b3d732e8e48..8b55aae7439 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -54,6 +54,7 @@ class RTPSWriter; class RTPSReader; class NetworkFactory; struct PublicationBuiltinTopicData; +struct SubscriptionBuiltinTopicData; /** * Class BuiltinProtocols that contains builtin endpoints implementing the discovery and liveliness protocols. @@ -138,16 +139,16 @@ class BuiltinProtocols const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos); /** - * Add a local Reader to the BuiltinProtocols. - * @param R Pointer to the RTPSReader. + * Add a local reader to the BuiltinProtocols. + * @param rtps_reader Pointer to the RTPSReader. * @param topicAtt Attributes of the associated topic * @param rqos QoS policies dictated by the subscriber * @param content_filter Optional content filtering information. * @return True if correct. */ - bool addLocalReader( - RTPSReader* R, - const TopicAttributes& topicAtt, + bool add_reader( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); @@ -167,10 +168,9 @@ class BuiltinProtocols * @param content_filter Optional content filtering information. * @return */ - bool updateLocalReader( - RTPSReader* R, - const TopicAttributes& topicAtt, - const fastdds::dds::ReaderQos& qos, + bool update_reader( + RTPSReader* rtps_reader, + const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * Remove a local Writer from the builtinProtocols. @@ -184,8 +184,8 @@ class BuiltinProtocols * @param R Pointer to the reader. * @return True if correctly removed. */ - bool removeLocalReader( - RTPSReader* R); + bool remove_reader( + RTPSReader* rtps_reader); //! Announce RTPSParticipantState (force the sending of a DPD message.) void announceRTPSParticipantState(); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index b2b59790dda..8d5dc43fcc3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -93,15 +93,15 @@ EDP::~EDP() // TODO Auto-generated destructor stub } -bool EDP::newLocalReaderProxyData( - RTPSReader* reader, - const TopicAttributes& att, +bool EDP::new_reader_proxy_data( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << reader->getGuid().entityId << " in topic " << att.topicName); + EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_reader->getGuid().entityId << " in topic " << sub_builtin_data.topic_name.to_string()); - auto init_fun = [this, reader, &att, &rqos, content_filter]( + auto init_fun = [this, rtps_reader, &sub_builtin_data, &rqos, content_filter]( ReaderProxyData* rpd, bool updating, const ParticipantProxyData& participant_data) @@ -109,17 +109,17 @@ bool EDP::newLocalReaderProxyData( if (updating) { EPROSIMA_LOG_ERROR(RTPS_EDP, - "Adding already existent reader " << reader->getGuid().entityId << " in topic " - << att.topicName); + "Adding already existent reader " << rtps_reader->getGuid().entityId << " in topic " + << sub_builtin_data.topic_name.to_string()); return false; } const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - const auto& ratt = reader->getAttributes(); + const auto& ratt = rtps_reader->getAttributes(); rpd->isAlive(true); - rpd->m_expectsInlineQos = reader->expects_inline_qos(); - rpd->guid(reader->getGuid()); + rpd->m_expectsInlineQos = rtps_reader->expects_inline_qos(); + rpd->guid(rtps_reader->getGuid()); rpd->key() = rpd->guid(); if (ratt.multicastLocatorList.empty() && ratt.unicastLocatorList.empty()) { @@ -133,9 +133,9 @@ bool EDP::newLocalReaderProxyData( ratt.external_unicast_locators); } rpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); - rpd->topicName(att.getTopicName()); - rpd->typeName(att.getTopicDataType()); - rpd->topicKind(att.getTopicKind()); + rpd->topicName(sub_builtin_data.topic_name); + rpd->typeName(sub_builtin_data.type_name); + rpd->topicKind((rpd->guid().entityId.value[3] & 0x0F) == 0x07 ? WITH_KEY : NO_KEY); using dds::utils::TypePropagation; using dds::xtypes::TypeInformationParameter; @@ -143,19 +143,20 @@ bool EDP::newLocalReaderProxyData( auto type_propagation = mp_RTPSParticipant->type_propagation(); assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation); - if (att.type_information.assigned()) + const auto& type_info = sub_builtin_data.type_information; + if (type_info.assigned()) { switch (type_propagation) { case TypePropagation::TYPEPROPAGATION_ENABLED: { - rpd->type_information(att.type_information); + rpd->type_information(type_info); break; } case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: { TypeInformationParameter minimal; - minimal.type_information.minimal(att.type_information.type_information.minimal()); + minimal.type_information.minimal(type_info.type_information.minimal()); minimal.assigned(true); rpd->type_information(minimal); break; @@ -208,7 +209,7 @@ bool EDP::newLocalReaderProxyData( //ADD IT TO THE LIST OF READERPROXYDATA GUID_t participant_guid; ReaderProxyData* reader_data = this->mp_PDP->addReaderProxyData( - reader->getGuid(), participant_guid, init_fun); + rtps_reader->getGuid(), participant_guid, init_fun); if (reader_data == nullptr) { return false; @@ -227,9 +228,9 @@ bool EDP::newLocalReaderProxyData( { pairing_reader_proxy_with_any_local_writer(participant_guid, reader_data); } - pairingReader(reader, participant_guid, *reader_data); + pairingReader(rtps_reader, participant_guid, *reader_data); //DO SOME PROCESSING DEPENDING ON THE IMPLEMENTATION (SIMPLE OR STATIC) - processLocalReaderProxyData(reader, reader_data); + process_reader_proxy_data(rtps_reader, reader_data); return true; } @@ -359,13 +360,12 @@ bool EDP::new_writer_proxy_data( return true; } -bool EDP::updatedLocalReader( - RTPSReader* reader, - const TopicAttributes&, +bool EDP::update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { - auto init_fun = [this, reader, &rqos, content_filter]( + auto init_fun = [this, rtps_reader, &rqos, content_filter]( ReaderProxyData* rdata, bool updating, const ParticipantProxyData& participant_data) @@ -375,15 +375,15 @@ bool EDP::updatedLocalReader( assert(updating); const NetworkFactory& network = mp_RTPSParticipant->network_factory(); - if (reader->getAttributes().multicastLocatorList.empty() && - reader->getAttributes().unicastLocatorList.empty()) + if (rtps_reader->getAttributes().multicastLocatorList.empty() && + rtps_reader->getAttributes().unicastLocatorList.empty()) { rdata->set_locators(participant_data.default_locators); } else { - rdata->set_multicast_locators(reader->getAttributes().multicastLocatorList, network); - rdata->set_announced_unicast_locators(reader->getAttributes().unicastLocatorList); + rdata->set_multicast_locators(rtps_reader->getAttributes().multicastLocatorList, network); + rdata->set_announced_unicast_locators(rtps_reader->getAttributes().unicastLocatorList); } rdata->m_qos.setQos(rqos, false); if (nullptr != content_filter) @@ -406,16 +406,16 @@ bool EDP::updatedLocalReader( rdata->content_filter().filter_expression = ""; } rdata->isAlive(true); - rdata->m_expectsInlineQos = reader->expects_inline_qos(); + rdata->m_expectsInlineQos = rtps_reader->expects_inline_qos(); return true; }; GUID_t participant_guid; - ReaderProxyData* reader_data = this->mp_PDP->addReaderProxyData(reader->getGuid(), participant_guid, init_fun); + ReaderProxyData* reader_data = this->mp_PDP->addReaderProxyData(rtps_reader->getGuid(), participant_guid, init_fun); if (reader_data != nullptr) { - processLocalReaderProxyData(reader, reader_data); + process_reader_proxy_data(rtps_reader, reader_data); #ifdef FASTDDS_STATISTICS // notify monitor service about the new local entity proxy update if (nullptr != this->mp_PDP->get_proxy_observer()) @@ -427,7 +427,7 @@ bool EDP::updatedLocalReader( { pairing_reader_proxy_with_any_local_writer(participant_guid, reader_data); } - pairingReader(reader, participant_guid, *reader_data); + pairingReader(rtps_reader, participant_guid, *reader_data); return true; } return false; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index 2cc906821fc..a93cf1cb54c 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -17,9 +17,8 @@ * */ -#ifndef FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT_EDP_H -#define FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT_EDP_H -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDP_H +#define FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDP_H #include #include @@ -53,6 +52,8 @@ class RTPSWriter; class RTPSReader; class WriterProxyData; class RTPSParticipantImpl; +struct PublicationBuiltinTopicData; +struct SubscriptionBuiltinTopicData; /** * Class EDP, base class for Endpoint Discovery Protocols. It contains generic methods used by the two EDP implemented (EDPSimple and EDPStatic), as well as abstract methods @@ -130,18 +131,18 @@ class EDP /** * Abstract method that removes a local Reader from the discovery method - * @param R Pointer to the Reader to remove. + * @param rtps_reader Pointer to the Reader to remove. * @return True if correctly removed. */ - virtual bool removeLocalReader( - RTPSReader* R) = 0; + virtual bool remove_reader( + RTPSReader* rtps_reader) = 0; /** * Abstract method that removes a local Writer from the discovery method - * @param W Pointer to the Writer to remove. + * @param rtps_writer Pointer to the Writer to remove. * @return True if correctly removed. */ - virtual bool removeLocalWriter( - RTPSWriter* W) = 0; + virtual bool remove_writer( + RTPSWriter* rtps_writer) = 0; /** * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation). @@ -149,7 +150,7 @@ class EDP * @param rdata Pointer to the ReaderProxyData object. * @return True if correct. */ - virtual bool processLocalReaderProxyData( + virtual bool process_reader_proxy_data( RTPSReader* reader, ReaderProxyData* rdata) = 0; @@ -159,57 +160,53 @@ class EDP * @param wdata Pointer to the Writer ProxyData object. * @return True if correct. */ - virtual bool processLocalWriterProxyData( + virtual bool process_writer_proxy_data( RTPSWriter* writer, WriterProxyData* wdata) = 0; /** * Create a new ReaderPD for a local Reader. - * @param R Pointer to the RTPSReader. - * @param att Attributes of the associated topic - * @param qos QoS policies dictated by the subscriber - * @param content_filter Optional content filtering information. + * @param rtps_reader Pointer to the RTPSReader. + * @param sub_builtin_data Subscription data for the reader. + * @param qos QoS policies dictated by the subscriber. + * @param content_filter Optional content filtering information. * @return True if correct. */ - bool newLocalReaderProxyData( - RTPSReader* R, - const TopicAttributes& att, + bool new_reader_proxy_data( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * Create a new ReaderPD for a local Writer. - * @param W Pointer to the RTPSWriter. - * @param att Attributes of the associated topic - * @param qos QoS policies dictated by the publisher + * @param rtps_writer Pointer to the RTPSWriter. + * @param pub_builtin_data Publication data for the writer. + * @param qos QoS policies dictated by the publisher. * @return True if correct. */ - bool newLocalWriterProxyData( - RTPSWriter* W, - const TopicAttributes& att, + bool new_writer_proxy_data( + RTPSWriter* rtps_writer, + const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& qos); /** * A previously created Reader has been updated - * @param R Pointer to the reader - * @param att Attributes of the associated topic - * @param qos QoS policies dictated by the subscriber - * @param content_filter Optional content filtering information. + * @param rtps_reader Pointer to the RTPSReader. + * @param qos QoS policies dictated by the subscriber. + * @param content_filter Optional content filtering information. * @return True if correctly updated */ - bool updatedLocalReader( - RTPSReader* R, - const TopicAttributes& att, + bool update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * A previously created Writer has been updated - * @param W Pointer to the Writer - * @param att Attributes of the associated topic - * @param qos QoS policies dictated by the publisher + * @param rtps_writer Pointer to the RTPSWriter. + * @param qos QoS policies dictated by the publisher. * @return True if correctly updated */ - bool updatedLocalWriter( - RTPSWriter* W, - const TopicAttributes& att, + bool update_writer( + RTPSWriter* rtps_writer, const fastdds::dds::WriterQos& qos); /** @@ -391,5 +388,4 @@ class EDP } // namespace fastdds } // namespace eprosima -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT_EDP_H +#endif // FASTDDS_RTPS_BUILTIN_DISCOVERY_ENDPOINT__EDP_H diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp index ebba04cc1ac..097d3fef1d3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp @@ -38,7 +38,7 @@ namespace eprosima { namespace fastdds { namespace rtps { -bool EDPClient::processLocalReaderProxyData( +bool EDPClient::process_reader_proxy_data( RTPSReader* local_reader, ReaderProxyData* rdata) { @@ -153,15 +153,15 @@ bool EDPClient::remove_writer( return mp_PDP->removeWriterProxyData(rtps_writer->getGuid()); } -bool EDPClient::removeLocalReader( - RTPSReader* R) +bool EDPClient::remove_reader( + RTPSReader* rtps_reader) { - EPROSIMA_LOG_INFO(RTPS_EDP, R->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, rtps_reader->getGuid().entityId); auto* writer = &subscriptions_writer_; #if HAVE_SECURITY - if (R->getAttributes().security_attributes().is_discovery_protected) + if (rtps_reader->getAttributes().security_attributes().is_discovery_protected) { writer = &subscriptions_secure_writer_; } @@ -170,7 +170,7 @@ bool EDPClient::removeLocalReader( if (writer->first != nullptr) { InstanceHandle_t iH; - iH = (R->getGuid()); + iH = (rtps_reader->getGuid()); CacheChange_t* change = EDPUtils::create_change(*writer, NOT_ALIVE_DISPOSED_UNREGISTERED, iH, mp_PDP->builtin_attributes().writerPayloadSize); if (change != nullptr) @@ -198,7 +198,7 @@ bool EDPClient::removeLocalReader( writer->second->add_change(change, wp); } } - return mp_PDP->removeReaderProxyData(R->getGuid()); + return mp_PDP->removeReaderProxyData(rtps_reader->getGuid()); } } /* namespace rtps */ diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h index a241f3a2c00..7b37f236f82 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.h @@ -49,12 +49,12 @@ class EDPClient : public EDPSimple /** * This method generates the corresponding change in the subscription writer and send it to all known remote endpoints. - * @param reader Pointer to the Reader object. + * @param rtps_reader Pointer to the Reader object. * @param rdata Pointer to the ReaderProxyData object. * @return true if correct. */ - bool processLocalReaderProxyData( - RTPSReader* reader, + bool process_reader_proxy_data( + RTPSReader* rtps_reader, ReaderProxyData* rdata) override; /** * This method generates the corresponding change in the publciations writer and send it to all known remote endpoints. @@ -67,11 +67,11 @@ class EDPClient : public EDPSimple WriterProxyData* wdata) override; /** * This methods generates the change disposing of the local Reader and calls the unpairing and removal methods of the base class. - * @param R Pointer to the RTPSReader object. + * @param rtps_reader Pointer to the RTPSReader object. * @return True if correct. */ - bool removeLocalReader( - RTPSReader* R) override; + bool remove_reader( + RTPSReader* rtps_reader) override; /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. * @param rtps_writer Pointer to the RTPSWriter object. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp index 5587d47a116..dc423a3bec3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp @@ -214,14 +214,14 @@ bool EDPServer::createSEDPEndpoints() return created; } -bool EDPServer::removeLocalReader( - RTPSReader* R) +bool EDPServer::remove_reader( + RTPSReader* rtps_reader) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Removing local reader: " << R->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, "Removing local reader: " << rtps_reader->getGuid().entityId); // Get subscriptions writer and reader guid auto* writer = &subscriptions_writer_; - GUID_t guid = R->getGuid(); + GUID_t guid = rtps_reader->getGuid(); // Recover reader information std::string topic_name; @@ -375,7 +375,7 @@ bool EDPServer::process_writer_proxy_data( return false; } -bool EDPServer::processLocalReaderProxyData( +bool EDPServer::process_reader_proxy_data( RTPSReader* local_reader, ReaderProxyData* rdata) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp index 38a1b1ea377..a1d36293934 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.hpp @@ -78,7 +78,7 @@ class EDPServer : public EDPSimple * @param rdata Pointer to the ReaderProxyData object. * @return true if correct. */ - bool processLocalReaderProxyData( + bool process_reader_proxy_data( RTPSReader* reader, ReaderProxyData* rdata) override; /** @@ -95,7 +95,7 @@ class EDPServer : public EDPSimple * @param R Pointer to the RTPSReader object. * @return True if correct. */ - bool removeLocalReader( + bool remove_reader( RTPSReader* R) override; /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index 908e9b9ba98..861b47a0d76 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -521,17 +521,17 @@ bool EDPSimple::create_sedp_secure_endpoints() #endif // if HAVE_SECURITY -bool EDPSimple::processLocalReaderProxyData( - RTPSReader* local_reader, +bool EDPSimple::process_reader_proxy_data( + RTPSReader* rtps_reader, ReaderProxyData* rdata) { EPROSIMA_LOG_INFO(RTPS_EDP, rdata->guid().entityId); - (void)local_reader; + (void)rtps_reader; auto* writer = &subscriptions_writer_; #if HAVE_SECURITY - if (local_reader->getAttributes().security_attributes().is_discovery_protected) + if (rtps_reader->getAttributes().security_attributes().is_discovery_protected) { writer = &subscriptions_secure_writer_; } @@ -687,15 +687,15 @@ bool EDPSimple::remove_writer( return mp_PDP->removeWriterProxyData(rtps_writer->getGuid()); } -bool EDPSimple::removeLocalReader( - RTPSReader* R) +bool EDPSimple::remove_reader( + RTPSReader* rtps_reader) { - EPROSIMA_LOG_INFO(RTPS_EDP, R->getGuid().entityId); + EPROSIMA_LOG_INFO(RTPS_EDP, rtps_reader->getGuid().entityId); auto* writer = &subscriptions_writer_; #if HAVE_SECURITY - if (R->getAttributes().security_attributes().is_discovery_protected) + if (rtps_reader->getAttributes().security_attributes().is_discovery_protected) { writer = &subscriptions_secure_writer_; } @@ -704,7 +704,7 @@ bool EDPSimple::removeLocalReader( if (writer->first != nullptr) { InstanceHandle_t iH; - iH = (R->getGuid()); + iH = (rtps_reader->getGuid()); CacheChange_t* change = EDPUtils::create_change(*writer, NOT_ALIVE_DISPOSED_UNREGISTERED, iH, mp_PDP->builtin_attributes().writerPayloadSize); if (change != nullptr) @@ -729,11 +729,11 @@ bool EDPSimple::removeLocalReader( // notify monitor service about the new local entity proxy update if (nullptr != this->mp_PDP->get_proxy_observer()) { - this->mp_PDP->get_proxy_observer()->on_local_entity_change(R->getGuid(), false); + this->mp_PDP->get_proxy_observer()->on_local_entity_change(rtps_reader->getGuid(), false); } #endif //FASTDDS_STATISTICS - return mp_PDP->removeReaderProxyData(R->getGuid()); + return mp_PDP->removeReaderProxyData(rtps_reader->getGuid()); } void EDPSimple::assignRemoteEndpoints( diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h index fe21a0911f1..feff00d9d4f 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.h @@ -122,12 +122,12 @@ class EDPSimple : public EDP /** * This method generates the corresponding change in the subscription writer and send it to all known remote endpoints. - * @param reader Pointer to the Reader object. - * @param rdata Pointer to the ReaderProxyData object. + * @param rtps_reader Pointer to the Reader object. + * @param rdata Pointer to the ReaderProxyData object. * @return true if correct. */ - bool processLocalReaderProxyData( - RTPSReader* reader, + bool process_reader_proxy_data( + RTPSReader* rtps_reader, ReaderProxyData* rdata) override; /** * This method generates the corresponding change in the publciations writer and send it to all known remote endpoints. @@ -140,11 +140,11 @@ class EDPSimple : public EDP WriterProxyData* wdata) override; /** * This methods generates the change disposing of the local Reader and calls the unpairing and removal methods of the base class. - * @param R Pointer to the RTPSReader object. + * @param rtps_reader Pointer to the RTPSReader object. * @return True if correct. */ - bool removeLocalReader( - RTPSReader* R) override; + bool remove_reader( + RTPSReader* rtps_reader) override; /** * This methods generates the change disposing of the local Writer and calls the unpairing and removal methods of the base class. * @param rtps_writer Pointer to the RTPSWriter object. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp index 864b661f5dc..39b23506f6f 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp @@ -322,7 +322,7 @@ bool EDPStaticProperty::fromProperty( return false; } -bool EDPStatic::processLocalReaderProxyData( +bool EDPStatic::process_reader_proxy_data( RTPSReader*, ReaderProxyData* rdata) { @@ -352,8 +352,8 @@ bool EDPStatic::process_writer_proxy_data( return true; } -bool EDPStatic::removeLocalReader( - RTPSReader* R) +bool EDPStatic::remove_reader( + RTPSReader* rtps_reader) { std::lock_guard guard(*mp_PDP->getMutex()); ParticipantProxyData* localpdata = this->mp_PDP->getLocalParticipantProxyData(); @@ -363,10 +363,10 @@ bool EDPStatic::removeLocalReader( EDPStaticProperty staticproperty; if (staticproperty.fromProperty((*pit).pair())) { - if (staticproperty.m_entityId == R->getGuid().entityId) + if (staticproperty.m_entityId == rtps_reader->getGuid().entityId) { auto new_property = EDPStaticProperty::toProperty(exchange_format_, "Reader", "ENDED", - R->getAttributes().getUserDefinedID(), R->getGuid().entityId); + rtps_reader->getAttributes().getUserDefinedID(), rtps_reader->getGuid().entityId); if (!pit->modify(new_property)) { EPROSIMA_LOG_ERROR(RTPS_EDP, "Failed to change property <" diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h index 4a7a9c56d82..72e3e7cff32 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.h @@ -71,12 +71,12 @@ class EDPStatic : public EDP const ParticipantProxyData& pdata, bool assign_secure_endpoints) override; /** - * Abstract method that removes a local Reader from the discovery method - * @param R Pointer to the Reader to remove. + * Abstract method that removes a local reader from the discovery method + * @param rtps_reader Pointer to the Reader to remove. * @return True if correctly removed. */ - bool removeLocalReader( - RTPSReader* R) override; + bool remove_reader( + RTPSReader* rtps_reader) override; /** * Abstract method that removes a local Writer from the discovery method * @param rtps_writer Pointer to the writer to remove. @@ -87,12 +87,12 @@ class EDPStatic : public EDP /** * After a new local ReaderProxyData has been created some processing is needed (depends on the implementation). - * @param reader Pointer to the RTPSReader object. - * @param rdata Pointer to the ReaderProxyData object. + * @param rtps_reader Pointer to the RTPSReader object. + * @param rdata Pointer to the ReaderProxyData object. * @return True if correct. */ - bool processLocalReaderProxyData( - RTPSReader* reader, + bool process_reader_proxy_data( + RTPSReader* rtps_reader, ReaderProxyData* rdata) override; /** * After a new local WriterProxyData has been created some processing is needed (depends on the implementation). diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 2d75115609f..24b08105c75 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -83,13 +83,13 @@ bool RTPSParticipant::register_writer( return mp_impl->register_writer(writer, pub_builtin_data, wqos); } -bool RTPSParticipant::registerReader( - RTPSReader* Reader, - const TopicAttributes& topicAtt, +bool RTPSParticipant::register_reader( + RTPSReader* reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return mp_impl->registerReader(Reader, topicAtt, rqos, content_filter); + return mp_impl->register_reader(reader, sub_builtin_data, rqos, content_filter); } void RTPSParticipant::update_attributes( @@ -105,13 +105,12 @@ bool RTPSParticipant::update_writer( return mp_impl->update_writer(writer, wqos); } -bool RTPSParticipant::updateReader( - RTPSReader* Reader, - const TopicAttributes& topicAtt, +bool RTPSParticipant::update_reader( + RTPSReader* reader, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return mp_impl->updateLocalReader(Reader, topicAtt, rqos, content_filter); + return mp_impl->update_reader(reader, rqos, content_filter); } std::vector RTPSParticipant::getParticipantNames() const diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 6cab26acbde..49b9a4c5469 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1412,13 +1412,13 @@ bool RTPSParticipantImpl::register_writer( return this->mp_builtinProtocols->add_writer(rtps_writer, pub_builtin_data, wqos); } -bool RTPSParticipantImpl::registerReader( - RTPSReader* reader, - const TopicAttributes& topicAtt, +bool RTPSParticipantImpl::register_reader( + RTPSReader* rtps_reader, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return this->mp_builtinProtocols->addLocalReader(reader, topicAtt, rqos, content_filter); + return this->mp_builtinProtocols->add_reader(rtps_reader, sub_builtin_data, rqos, content_filter); } void RTPSParticipantImpl::update_attributes( @@ -1613,13 +1613,12 @@ bool RTPSParticipantImpl::update_writer( return this->mp_builtinProtocols->update_writer(rtps_writer, wqos); } -bool RTPSParticipantImpl::updateLocalReader( - RTPSReader* reader, - const TopicAttributes& topicAtt, +bool RTPSParticipantImpl::update_reader( + RTPSReader* rtps_reader, const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return this->mp_builtinProtocols->updateLocalReader(reader, topicAtt, rqos, content_filter); + return this->mp_builtinProtocols->update_reader(rtps_reader, rqos, content_filter); } /* @@ -2014,7 +2013,7 @@ bool RTPSParticipantImpl::deleteUserEndpoint( { if (found_in_users) { - mp_builtinProtocols->removeLocalReader(static_cast(p_endpoint)); + mp_builtinProtocols->remove_reader(static_cast(p_endpoint)); } #if HAVE_SECURITY @@ -2090,7 +2089,7 @@ void RTPSParticipantImpl::deleteAllUserEndpoints() { return kind == WRITER ? mp_builtinProtocols->remove_writer((RTPSWriter*)p) - : mp_builtinProtocols->removeLocalReader((RTPSReader*)p); + : mp_builtinProtocols->remove_reader((RTPSReader*)p); }; #if HAVE_SECURITY diff --git a/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp b/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp index ce1a78550a7..f9f5d56545b 100644 --- a/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsDiscovery.cpp @@ -433,7 +433,7 @@ TEST_P(RTPSDiscovery, WriterListenerOnReaderDiscoveryIncompatibleQoS) } /*! - * \test RTPS-CFT-RRR-01 Tests a good `ContentFilterProperty` passed to `registerReader()` and `updateReader()` is + * \test RTPS-CFT-RRR-01 Tests a good `ContentFilterProperty` passed to `register_reader()` and `update_reader()` is * propagated successfully through discovery. */ TEST_P(RTPSDiscovery, ContentFilterRegistration) @@ -528,7 +528,7 @@ TEST_P(RTPSDiscovery, ContentFilterRegistration) } /*! - * \test RTPS-CFT-RRR-02 Tests a wrong `ContentFilterProperty` passed to `registerReader()` makes the function fail. + * \test RTPS-CFT-RRR-02 Tests a wrong `ContentFilterProperty` passed to `register_reader()` makes the function fail. */ TEST_P(RTPSDiscovery, ContentFilterWrongRegistration) { @@ -630,7 +630,7 @@ TEST_P(RTPSDiscovery, ContentFilterWrongRegistration) } /*! - * \test RTPS-CFT-RRR-03 Tests a wrong `ContentFilterProperty` passed to `updateReader()` makes the function fail. + * \test RTPS-CFT-RRR-03 Tests a wrong `ContentFilterProperty` passed to `update_reader()` makes the function fail. */ TEST_P(RTPSDiscovery, ContentFilterWrongUpdate) { @@ -747,7 +747,7 @@ TEST_P(RTPSDiscovery, ContentFilterWrongUpdate) } /*! - * \test RTPS-CFT-RRR-04 Tests `registerReader()` and `updateReader()` works successfully when the pointer to + * \test RTPS-CFT-RRR-04 Tests `register_reader()` and `update_reader()` works successfully when the pointer to * `ContentFilterProperty` is `nullptr`. */ TEST_P(RTPSDiscovery, ContentFilterRegistrationWithoutCFP) @@ -830,8 +830,8 @@ TEST_P(RTPSDiscovery, ContentFilterRegistrationWithoutCFP) } /*! - * \test RTPS-CFT-RRR_05 Tests ``updateReader()` works successfully when a `ContentFilterProperty` is added for first - * time, because `registerReader()` passed a `nullptr`. + * \test RTPS-CFT-RRR_05 Tests ``update_reader()` works successfully when a `ContentFilterProperty` is added for first + * time, because `register_reader()` passed a `nullptr`. */ TEST_P(RTPSDiscovery, ContentFilterRegistrationWithoutCFPButUpdate) { diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index 879f4dbda0d..e3702acd245 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -140,11 +140,11 @@ class RTPSWithRegistrationReader , receiving_(false) , matched_(0) { - topic_attr_.topicDataType = type_.get_name(); + sub_builtin_data_.type_name = type_.get_name(); // Generate topic name std::ostringstream t; t << topic_name << "_" << asio::ip::host_name() << "_" << GET_PID(); - topic_attr_.topicName = t.str(); + sub_builtin_data_.topic_name = t.str(); // By default, heartbeat period delay is 100 milliseconds. reader_attr_.times.heartbeat_response_delay.seconds = 0; @@ -193,7 +193,7 @@ class RTPSWithRegistrationReader return; } - initialized_ = participant_->registerReader(reader_, topic_attr_, reader_qos_, content_filter_property_); + initialized_ = participant_->register_reader(reader_, sub_builtin_data_, reader_qos_, content_filter_property_); } void update() @@ -203,7 +203,7 @@ class RTPSWithRegistrationReader return; } - initialized_ = participant_->updateReader(reader_, topic_attr_, reader_qos_, content_filter_property_); + initialized_ = participant_->update_reader(reader_, reader_qos_, content_filter_property_); } bool isInitialized() const @@ -430,7 +430,8 @@ class RTPSWithRegistrationReader RTPSWithRegistrationReader& history_depth( const int32_t depth) { - topic_attr_.historyQos.depth = depth; + hattr_.maximumReservedCaches = depth; + hattr_.initialReservedCaches = std::min(hattr_.initialReservedCaches, depth); return *this; } @@ -627,7 +628,7 @@ class RTPSWithRegistrationReader bool destroy_participant_{false}; eprosima::fastdds::rtps::RTPSReader* reader_; eprosima::fastdds::rtps::ReaderAttributes reader_attr_; - eprosima::fastdds::TopicAttributes topic_attr_; + eprosima::fastdds::rtps::SubscriptionBuiltinTopicData sub_builtin_data_; eprosima::fastdds::dds::ReaderQos reader_qos_; eprosima::fastdds::rtps::ReaderHistory* history_; eprosima::fastdds::rtps::HistoryAttributes hattr_; diff --git a/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h b/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h index d959f143b94..8518507ba18 100644 --- a/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h +++ b/test/mock/rtps/EDP/rtps/builtin/discovery/endpoint/EDP.h @@ -57,7 +57,7 @@ class EDP return true; } - virtual bool removeLocalReader( + virtual bool remove_reader( eprosima::fastdds::rtps::RTPSReader*) { return true; @@ -76,7 +76,7 @@ class EDP } - virtual bool processLocalReaderProxyData( + virtual bool process_reader_proxy_data( eprosima::fastdds::rtps::RTPSReader*, eprosima::fastdds::rtps::ReaderProxyData*) { diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index f5ff38c5619..7406a2e3cf3 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -194,31 +194,20 @@ class FASTDDS_EXPORTED_API RTPSParticipant RTPSWriter * Writer, const fastdds::dds::WriterQos& wqos)); - MOCK_METHOD3(registerReader, bool( + MOCK_METHOD4(register_reader, bool( RTPSReader * Reader, - const TopicAttributes& topicAtt, - const fastdds::dds::ReaderQos& rqos)); - - MOCK_METHOD4(registerReader, bool( - RTPSReader * Reader, - const TopicAttributes& topicAtt, + const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter)); - MOCK_METHOD3(updateReader, bool( + MOCK_METHOD3(update_reader, bool( RTPSReader * Reader, - const TopicAttributes& topicAtt, - const fastdds::dds::ReaderQos& rqos)); + const fastdds::dds::ReaderQos& rqos, + const fastdds::rtps::ContentFilterProperty* content_filter)); MOCK_METHOD1(ignore_participant, bool( const GuidPrefix_t& participant_guid)); - MOCK_METHOD4(updateReader, bool( - RTPSReader * Reader, - const TopicAttributes& topicAtt, - const fastdds::dds::ReaderQos& rqos, - const fastdds::rtps::ContentFilterProperty* content_filter)); - std::vector get_netmask_filter_info() const { return {}; diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index b6e7b55cc63..91fec1db748 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -585,7 +585,7 @@ class UserListeners : public ::testing::Test ASSERT_NE(subscriber_, nullptr); EXPECT_CALL(participant_mock_, - registerReader(&reader_mock_, ::testing::_, ::testing::_, nullptr)).WillRepeatedly( + register_reader(&reader_mock_, ::testing::_, ::testing::_, nullptr)).WillRepeatedly( ::testing::Return(true)); datareader_ = diff --git a/test/unittest/rtps/discovery/EdpTests.cpp b/test/unittest/rtps/discovery/EdpTests.cpp index 86a2442a5ef..b206d62ccf4 100644 --- a/test/unittest/rtps/discovery/EdpTests.cpp +++ b/test/unittest/rtps/discovery/EdpTests.cpp @@ -60,7 +60,7 @@ class EDPMock : public EDP { } - bool removeLocalReader( + bool remove_reader( RTPSReader* /*R*/) override { return true; @@ -72,7 +72,7 @@ class EDPMock : public EDP return true; } - bool processLocalReaderProxyData( + bool process_reader_proxy_data( RTPSReader* /*reader*/, ReaderProxyData* /*rdata*/) override { diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index 74b5892f730..f2ba8694054 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -90,9 +90,13 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) ASSERT_NE(writer, nullptr); // Register both endpoints + SubscriptionBuiltinTopicData sub_builtin_data; + sub_builtin_data.type_name = "string"; + sub_builtin_data.topic_name = "topic"; PublicationBuiltinTopicData pub_builtin_data; pub_builtin_data.type_name = "string"; pub_builtin_data.topic_name = "topic"; + part->register_reader(reader, sub_builtin_data, {}); part->register_writer(writer, pub_builtin_data, {}); // After registration, the writer should be matched diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 4755f712dbd..f5fd0d7120d 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -363,6 +362,10 @@ class RTPSStatisticsTestsImpl pub_builtin_data.type_name = data_type; pub_builtin_data.topic_name = topic_name; + SubscriptionBuiltinTopicData sub_builtin_data; + sub_builtin_data.type_name = data_type; + sub_builtin_data.topic_name = topic_name; + dds::WriterQos Wqos; auto& watt = writer_->getAttributes(); Wqos.m_durability.durabilityKind(watt.durabilityKind); @@ -378,7 +381,7 @@ class RTPSStatisticsTestsImpl ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; participant_->register_writer(writer_, pub_builtin_data, Wqos); - participant_->registerReader(reader_, Tatt, Rqos); + participant_->register_reader(reader_, sub_builtin_data, Rqos); } void destroy_endpoints() From 39b571f80dbd9ec69ad35cf17508979cccef2361 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:09:13 +0200 Subject: [PATCH 07/37] Refs #21357: Move BuiltinTopicKeyValue conversion helpers to utils (make it accesible to DDS later) Signed-off-by: Mario Dominguez --- .../rtps/builtin/data/ProxyDataConverters.cpp | 63 +------------ src/cpp/utils/BuiltinTopicKeyConversions.hpp | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+), 62 deletions(-) create mode 100644 src/cpp/utils/BuiltinTopicKeyConversions.hpp diff --git a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp index d5f2d5dc002..e21c492135b 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp +++ b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp @@ -32,73 +32,12 @@ #include #include #include +#include namespace eprosima { namespace fastdds { namespace rtps { -typedef uint32_t BuiltinTopicKeyValue[3]; - -static void from_proxy_to_builtin( - const EntityId_t& entity_id, - BuiltinTopicKeyValue& builtin_key_value) -{ - builtin_key_value[0] = 0; - builtin_key_value[1] = 0; - builtin_key_value[2] = static_cast(entity_id.value[0]) << 24 - | static_cast(entity_id.value[1]) << 16 - | static_cast(entity_id.value[2]) << 8 - | static_cast(entity_id.value[3]); -} - -static void from_proxy_to_builtin( - const GuidPrefix_t& guid_prefix, - BuiltinTopicKeyValue& dds_key) -{ - dds_key[0] = static_cast(guid_prefix.value[0]) << 24 - | static_cast(guid_prefix.value[1]) << 16 - | static_cast(guid_prefix.value[2]) << 8 - | static_cast(guid_prefix.value[3]); - dds_key[1] = static_cast(guid_prefix.value[4]) << 24 - | static_cast(guid_prefix.value[5]) << 16 - | static_cast(guid_prefix.value[6]) << 8 - | static_cast(guid_prefix.value[7]); - dds_key[2] = static_cast(guid_prefix.value[8]) << 24 - | static_cast(guid_prefix.value[9]) << 16 - | static_cast(guid_prefix.value[10]) << 8 - | static_cast(guid_prefix.value[11]); -} - -static void from_builtin_to_proxy( - const BuiltinTopicKeyValue& dds_key, - EntityId_t& entity_id) -{ - entity_id.value[0] = static_cast((dds_key[2] >> 24) & 0xFF); - entity_id.value[1] = static_cast((dds_key[2] >> 16) & 0xFF); - entity_id.value[2] = static_cast((dds_key[2] >> 8) & 0xFF); - entity_id.value[3] = static_cast(dds_key[2] & 0xFF); -} - -static void from_builtin_to_proxy( - const BuiltinTopicKeyValue& dds_key, - GuidPrefix_t& guid_prefix) -{ - guid_prefix.value[0] = static_cast((dds_key[0] >> 24) & 0xFF); - guid_prefix.value[1] = static_cast((dds_key[0] >> 16) & 0xFF); - guid_prefix.value[2] = static_cast((dds_key[0] >> 8) & 0xFF); - guid_prefix.value[3] = static_cast(dds_key[0] & 0xFF); - - guid_prefix.value[4] = static_cast((dds_key[1] >> 24) & 0xFF); - guid_prefix.value[5] = static_cast((dds_key[1] >> 16) & 0xFF); - guid_prefix.value[6] = static_cast((dds_key[1] >> 8) & 0xFF); - guid_prefix.value[7] = static_cast(dds_key[1] & 0xFF); - - guid_prefix.value[8] = static_cast((dds_key[2] >> 24) & 0xFF); - guid_prefix.value[9] = static_cast((dds_key[2] >> 16) & 0xFF); - guid_prefix.value[10] = static_cast((dds_key[2] >> 8) & 0xFF); - guid_prefix.value[11] = static_cast(dds_key[2] & 0xFF); -} - void from_proxy_to_builtin( const ParticipantProxyData& proxy_data, ParticipantBuiltinTopicData& builtin_data) diff --git a/src/cpp/utils/BuiltinTopicKeyConversions.hpp b/src/cpp/utils/BuiltinTopicKeyConversions.hpp new file mode 100644 index 00000000000..58684949852 --- /dev/null +++ b/src/cpp/utils/BuiltinTopicKeyConversions.hpp @@ -0,0 +1,91 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file BuiltinTopicKeyConversions.hpp + */ + +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +typedef uint32_t BuiltinTopicKeyValue[3]; + +inline void from_proxy_to_builtin( + const EntityId_t& entity_id, + BuiltinTopicKeyValue& builtin_key_value) +{ + builtin_key_value[0] = 0; + builtin_key_value[1] = 0; + builtin_key_value[2] = static_cast(entity_id.value[0]) << 24 + | static_cast(entity_id.value[1]) << 16 + | static_cast(entity_id.value[2]) << 8 + | static_cast(entity_id.value[3]); +} + +inline void from_proxy_to_builtin( + const GuidPrefix_t& guid_prefix, + BuiltinTopicKeyValue& dds_key) +{ + dds_key[0] = static_cast(guid_prefix.value[0]) << 24 + | static_cast(guid_prefix.value[1]) << 16 + | static_cast(guid_prefix.value[2]) << 8 + | static_cast(guid_prefix.value[3]); + dds_key[1] = static_cast(guid_prefix.value[4]) << 24 + | static_cast(guid_prefix.value[5]) << 16 + | static_cast(guid_prefix.value[6]) << 8 + | static_cast(guid_prefix.value[7]); + dds_key[2] = static_cast(guid_prefix.value[8]) << 24 + | static_cast(guid_prefix.value[9]) << 16 + | static_cast(guid_prefix.value[10]) << 8 + | static_cast(guid_prefix.value[11]); +} + +inline void from_builtin_to_proxy( + const BuiltinTopicKeyValue& dds_key, + EntityId_t& entity_id) +{ + entity_id.value[0] = static_cast((dds_key[2] >> 24) & 0xFF); + entity_id.value[1] = static_cast((dds_key[2] >> 16) & 0xFF); + entity_id.value[2] = static_cast((dds_key[2] >> 8) & 0xFF); + entity_id.value[3] = static_cast(dds_key[2] & 0xFF); +} + +inline void from_builtin_to_proxy( + const BuiltinTopicKeyValue& dds_key, + GuidPrefix_t& guid_prefix) +{ + guid_prefix.value[0] = static_cast((dds_key[0] >> 24) & 0xFF); + guid_prefix.value[1] = static_cast((dds_key[0] >> 16) & 0xFF); + guid_prefix.value[2] = static_cast((dds_key[0] >> 8) & 0xFF); + guid_prefix.value[3] = static_cast(dds_key[0] & 0xFF); + + guid_prefix.value[4] = static_cast((dds_key[1] >> 24) & 0xFF); + guid_prefix.value[5] = static_cast((dds_key[1] >> 16) & 0xFF); + guid_prefix.value[6] = static_cast((dds_key[1] >> 8) & 0xFF); + guid_prefix.value[7] = static_cast(dds_key[1] & 0xFF); + + guid_prefix.value[8] = static_cast((dds_key[2] >> 24) & 0xFF); + guid_prefix.value[9] = static_cast((dds_key[2] >> 16) & 0xFF); + guid_prefix.value[10] = static_cast((dds_key[2] >> 8) & 0xFF); + guid_prefix.value[11] = static_cast(dds_key[2] & 0xFF); +} + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima From 3f30adbe766a3da7ae4c71f36c8420e024c42a41 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:10:22 +0200 Subject: [PATCH 08/37] Refs #21357: Add utility method to LocatorList Signed-off-by: Mario Dominguez --- include/fastdds/rtps/common/LocatorList.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/fastdds/rtps/common/LocatorList.hpp b/include/fastdds/rtps/common/LocatorList.hpp index 149eac8e10b..f2a3ad8dfaf 100644 --- a/include/fastdds/rtps/common/LocatorList.hpp +++ b/include/fastdds/rtps/common/LocatorList.hpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -376,6 +377,16 @@ class LocatorList return false; } + // Copy the inner locator list to a ResourceLimitedVector locator list. + FASTDDS_EXPORTED_API void copy_to( + eprosima::fastdds::ResourceLimitedVector& locator_list) const + { + for(auto& locator : m_locators) + { + locator_list.emplace_back(locator); + } + } + private: std::vector m_locators; From 468e988dee2771eb7a6dc8e02090fe0f4f953404 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:15:57 +0200 Subject: [PATCH 09/37] Refs #21357: Remove TopicAttributes from DataWriterHistory Signed-off-by: Mario Dominguez --- .../fastdds/publisher/DataWriterHistory.cpp | 60 ++++++++++--------- .../fastdds/publisher/DataWriterHistory.hpp | 22 +++---- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 9 ++- .../fastdds/publisher/DataWriterHistory.hpp | 48 ++++++++------- .../mock/fastdds/publisher/DataWriterImpl.hpp | 7 ++- .../fastdds/publisher/DataWriterHistory.hpp | 32 +++++----- 6 files changed, 98 insertions(+), 80 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterHistory.cpp b/src/cpp/fastdds/publisher/DataWriterHistory.cpp index 4a5342ca44f..1e55db9f40b 100644 --- a/src/cpp/fastdds/publisher/DataWriterHistory.cpp +++ b/src/cpp/fastdds/publisher/DataWriterHistory.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -35,20 +36,22 @@ namespace dds { using namespace eprosima::fastdds::rtps; HistoryAttributes DataWriterHistory::to_history_attributes( - const TopicAttributes& topic_att, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, uint32_t payloadMaxSize, MemoryManagementPolicy_t mempolicy) { - auto initial_samples = topic_att.resourceLimitsQos.allocated_samples; - auto max_samples = topic_att.resourceLimitsQos.max_samples; - auto extra_samples = topic_att.resourceLimitsQos.extra_samples; + auto initial_samples = resource_limits_qos.allocated_samples; + auto max_samples = resource_limits_qos.max_samples; + auto extra_samples = resource_limits_qos.extra_samples; - if (topic_att.historyQos.kind != KEEP_ALL_HISTORY_QOS) + if (history_qos.kind != KEEP_ALL_HISTORY_QOS) { - max_samples = topic_att.historyQos.depth; - if (topic_att.getTopicKind() != NO_KEY) + max_samples = history_qos.depth; + if (topic_kind != NO_KEY) { - max_samples *= topic_att.resourceLimitsQos.max_instances; + max_samples *= resource_limits_qos.max_instances; } initial_samples = std::min(initial_samples, max_samples); @@ -60,14 +63,16 @@ HistoryAttributes DataWriterHistory::to_history_attributes( DataWriterHistory::DataWriterHistory( const std::shared_ptr& payload_pool, const std::shared_ptr& change_pool, - const TopicAttributes& topic_att, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, uint32_t payloadMaxSize, MemoryManagementPolicy_t mempolicy, std::function unack_sample_remove_functor) - : WriterHistory(to_history_attributes(topic_att, payloadMaxSize, mempolicy), payload_pool, change_pool) - , history_qos_(topic_att.historyQos) - , resource_limited_qos_(topic_att.resourceLimitsQos) - , topic_att_(topic_att) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) + , history_qos_(history_qos) + , resource_limited_qos_(resource_limits_qos) + , topic_kind_(topic_kind) , unacknowledged_sample_removed_functor_(unack_sample_remove_functor) { if (resource_limited_qos_.max_samples <= 0) @@ -92,7 +97,7 @@ DataWriterHistory::~DataWriterHistory() void DataWriterHistory::rebuild_instances() { - if (topic_att_.getTopicKind() == WITH_KEY) + if (topic_kind_ == WITH_KEY) { for (CacheChange_t* change : m_changes) { @@ -114,7 +119,7 @@ bool DataWriterHistory::register_instance( payload = nullptr; /// Preconditions - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { return false; } @@ -148,7 +153,7 @@ bool DataWriterHistory::prepare_change( { bool ret = false; bool is_acked = change_is_acked_or_fully_delivered(m_changes.front()); - InstanceHandle_t instance = topic_att_.getTopicKind() == NO_KEY ? + InstanceHandle_t instance = topic_kind_ == NO_KEY ? HANDLE_NIL : m_changes.front()->instanceHandle; if (history_qos_.kind == KEEP_ALL_HISTORY_QOS) @@ -168,7 +173,7 @@ bool DataWriterHistory::prepare_change( else if (!ret) { EPROSIMA_LOG_WARNING(RTPS_HISTORY, - "Attempting to add Data to Full WriterCache: " << topic_att_.getTopicDataType()); + "Attempting to add Data to Full WriterCache."); return false; } } @@ -176,8 +181,8 @@ bool DataWriterHistory::prepare_change( assert(!m_isHistoryFull); // For NO_KEY we can directly add the change - bool add = (topic_att_.getTopicKind() == NO_KEY); - if (topic_att_.getTopicKind() == WITH_KEY) + bool add = (topic_kind_ == NO_KEY); + if (topic_kind_ == WITH_KEY) { t_m_Inst_Caches::iterator vit; @@ -272,8 +277,7 @@ bool DataWriterHistory::add_pub_change( #endif // if HAVE_STRICT_REALTIME { EPROSIMA_LOG_INFO(RTPS_HISTORY, - topic_att_.getTopicDataType() - << " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle + " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle << " and " << change->serializedPayload.length << " bytes"); returnedValue = true; } @@ -380,7 +384,7 @@ bool DataWriterHistory::remove_change_pub( std::lock_guard guard(*this->mp_mutex); #endif // if HAVE_STRICT_REALTIME - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { if (remove_change(change, max_blocking_time)) { @@ -439,7 +443,7 @@ bool DataWriterHistory::remove_instance_changes( return false; } - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { EPROSIMA_LOG_ERROR(RTPS_HISTORY, "Cannot be removed instance changes of a NO_KEY DataType"); return false; @@ -484,12 +488,12 @@ bool DataWriterHistory::set_next_deadline( } std::lock_guard guard(*this->mp_mutex); - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { next_deadline_us_ = next_deadline_us; return true; } - else if (topic_att_.getTopicKind() == WITH_KEY) + else if (topic_kind_ == WITH_KEY) { if (keyed_changes_.find(handle) == keyed_changes_.end()) { @@ -514,7 +518,7 @@ bool DataWriterHistory::get_next_deadline( } std::lock_guard guard(*this->mp_mutex); - if (topic_att_.getTopicKind() == WITH_KEY) + if (topic_kind_ == WITH_KEY) { auto min = std::min_element( keyed_changes_.begin(), @@ -530,7 +534,7 @@ bool DataWriterHistory::get_next_deadline( next_deadline_us = min->second.next_deadline_us; return true; } - else if (topic_att_.getTopicKind() == NO_KEY) + else if (topic_kind_ == NO_KEY) { next_deadline_us = next_deadline_us_; return true; @@ -558,7 +562,7 @@ bool DataWriterHistory::wait_for_acknowledgement_last_change( std::unique_lock& lock, const std::chrono::time_point& max_blocking_time) { - if (WITH_KEY == topic_att_.getTopicKind()) + if (WITH_KEY == topic_kind_) { // Find the instance t_m_Inst_Caches::iterator vit = keyed_changes_.find(handle); diff --git a/src/cpp/fastdds/publisher/DataWriterHistory.hpp b/src/cpp/fastdds/publisher/DataWriterHistory.hpp index c10245ca03e..86ea840533f 100644 --- a/src/cpp/fastdds/publisher/DataWriterHistory.hpp +++ b/src/cpp/fastdds/publisher/DataWriterHistory.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -48,21 +47,25 @@ class DataWriterHistory : public rtps::WriterHistory public: static rtps::HistoryAttributes to_history_attributes( - const TopicAttributes& topic_att, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, uint32_t payloadMaxSize, rtps::MemoryManagementPolicy_t mempolicy); /** * Constructor of the DataWriterHistory. - * @param topic_att TopicAttributed - * @param payloadMax Maximum payload size. - * @param mempolicy Set whether the payloads can dynamically resized or not. + * @param pub_builtin_data Information on the publication. + * @param payloadMax Maximum payload size. + * @param mempolicy Set whether the payloads can dynamically resized or not. * @param unack_sample_remove_functor Functor to call DDS listener callback on_unacknowledged_sample_removed */ DataWriterHistory( const std::shared_ptr& payload_pool, const std::shared_ptr& change_pool, - const TopicAttributes& topic_att, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, uint32_t payloadMax, rtps::MemoryManagementPolicy_t mempolicy, std::function unack_sample_remove_functor); @@ -152,8 +155,7 @@ class DataWriterHistory : public rtps::WriterHistory #endif // if HAVE_STRICT_REALTIME { EPROSIMA_LOG_INFO(RTPS_HISTORY, - topic_att_.getTopicDataType() - << " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle + " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle << " and " << change->serializedPayload.length << " bytes"); returnedValue = true; } @@ -257,8 +259,8 @@ class DataWriterHistory : public rtps::WriterHistory HistoryQosPolicy history_qos_; //!ResourceLimitsQosPolicy values. ResourceLimitsQosPolicy resource_limited_qos_; - //!Topic Attributes - TopicAttributes topic_att_; + //!TopicKind + rtps::TopicKind_t topic_kind_; //! Unacknowledged sample removed functor std::function unacknowledged_sample_removed_functor_; diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 406155d8f09..dc8af702f5b 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -228,7 +228,9 @@ void DataWriterImpl::create_history( { history_.reset(new DataWriterHistory( payload_pool, change_pool, - get_topic_attributes(qos_, *topic_, type_), + qos_.history(), + qos_.resource_limits(), + (type_->is_compute_key_provided ? WITH_KEY : NO_KEY), type_->max_serialized_type_size, qos_.endpoint().history_memory_policy, [this]( @@ -245,9 +247,10 @@ ReturnCode_t DataWriterImpl::enable() { assert(writer_ == nullptr); - auto topic_att = get_topic_attributes(qos_, *topic_, type_); auto history_att = DataWriterHistory::to_history_attributes( - topic_att, type_->max_serialized_type_size, qos_.endpoint().history_memory_policy); + qos_.history(), + qos_.resource_limits(), (type_->is_compute_key_provided ? WITH_KEY : NO_KEY), type_->max_serialized_type_size, + qos_.endpoint().history_memory_policy); pool_config_ = PoolConfig::from_history_attributes(history_att); // When the user requested PREALLOCATED_WITH_REALLOC, but we know the type cannot diff --git a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp index da2e45fd677..4da80f4aa3b 100644 --- a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp +++ b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include @@ -45,20 +45,22 @@ class DataWriterHistory : public WriterHistory public: static HistoryAttributes to_history_attributes( - const TopicAttributes& topic_att, - uint32_t payloadMaxSize, - MemoryManagementPolicy_t mempolicy) + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, + uint32_t payloadMaxSize, + MemoryManagementPolicy_t mempolicy) { - auto initial_samples = topic_att.resourceLimitsQos.allocated_samples; - auto max_samples = topic_att.resourceLimitsQos.max_samples; - auto extra_samples = topic_att.resourceLimitsQos.extra_samples; + auto initial_samples = resource_limits_qos.allocated_samples; + auto max_samples = resource_limits_qos.max_samples; + auto extra_samples = resource_limits_qos.extra_samples; - if (topic_att.historyQos.kind != KEEP_ALL_HISTORY_QOS) + if (history_qos.kind != KEEP_ALL_HISTORY_QOS) { - max_samples = topic_att.historyQos.depth; - if (topic_att.getTopicKind() != NO_KEY) + max_samples = history_qos.depth; + if (topic_kind != NO_KEY) { - max_samples *= topic_att.resourceLimitsQos.max_instances; + max_samples *= resource_limits_qos.max_instances; } initial_samples = std::min(initial_samples, max_samples); @@ -70,14 +72,16 @@ class DataWriterHistory : public WriterHistory DataWriterHistory( const std::shared_ptr& payload_pool, const std::shared_ptr& change_pool, - const TopicAttributes& topic_att, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, uint32_t payloadMaxSize, MemoryManagementPolicy_t mempolicy, - std::function unack_sample_remove_functor) - : WriterHistory(to_history_attributes(topic_att, payloadMaxSize, mempolicy), payload_pool, change_pool) - , history_qos_(topic_att.historyQos) - , resource_limited_qos_(topic_att.resourceLimitsQos) - , topic_att_(topic_att) + std::function unack_sample_remove_functor) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) + , history_qos_(history_qos) + , resource_limited_qos_(resource_limits_qos) + , topic_kind_(topic_kind) , unacknowledged_sample_removed_functor_(unack_sample_remove_functor) { if (resource_limited_qos_.max_samples <= 0) @@ -122,7 +126,7 @@ class DataWriterHistory : public WriterHistory payload = nullptr; /// Preconditions - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { return false; } @@ -184,8 +188,8 @@ class DataWriterHistory : public WriterHistory bool returnedValue = false; // For NO_KEY we can directly add the change - bool add = (topic_att_.getTopicKind() == NO_KEY); - if (topic_att_.getTopicKind() == WITH_KEY) + bool add = (topic_kind_ == NO_KEY); + if (topic_kind_ == WITH_KEY) { t_m_Inst_Caches::iterator vit; @@ -258,7 +262,7 @@ class DataWriterHistory : public WriterHistory } std::lock_guard guard(*this->mp_mutex); - if (topic_att_.getTopicKind() == NO_KEY) + if (topic_kind_ == NO_KEY) { if (remove_change(change)) { @@ -303,7 +307,7 @@ class DataWriterHistory : public WriterHistory //!ResourceLimitsQosPolicy values. ResourceLimitsQosPolicy resource_limited_qos_; //!Topic Attributes - TopicAttributes topic_att_; + TopicKind_t topic_kind_; //! Unacknowledged sample removed functor std::function unacknowledged_sample_removed_functor_; diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp index 6d8186de30a..5b9f195bd8f 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp @@ -130,7 +130,9 @@ class DataWriterImpl : protected rtps::IReaderDataFilter history_.reset(new DataWriterHistory( payload_pool, change_pool, - atts_, + qos_.history(), + qos_.resource_limits(), + topic_kind_, 500, fastdds::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE, [](const InstanceHandle_t&) @@ -428,7 +430,8 @@ class DataWriterImpl : protected rtps::IReaderDataFilter OfferedIncompatibleQosStatus offered_incompatible_qos_status_; std::chrono::duration> lifespan_duration_us_; std::unique_ptr history_; - fastdds::TopicAttributes atts_; + + rtps::TopicKind_t topic_kind_; }; diff --git a/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp b/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp index ee5799a6411..8ee40d4061b 100644 --- a/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp +++ b/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp @@ -21,17 +21,15 @@ #include +#include #include +#include +#include #include #include -#include -#include namespace eprosima { namespace fastdds { - -class TopicAttributes; - namespace rtps { class WriteParams; @@ -48,9 +46,11 @@ class Topic; static fastdds::rtps::HistoryAttributes to_history_attributes( - const fastdds::TopicAttributes&, + const HistoryQosPolicy&, + const ResourceLimitsQosPolicy&, + const rtps::TopicKind_t&, uint32_t, - fastdds::rtps::MemoryManagementPolicy_t) + rtps::MemoryManagementPolicy_t) { return fastdds::rtps::HistoryAttributes(); @@ -60,14 +60,16 @@ class DataWriterHistory : public fastdds::rtps::WriterHistory { public: - DataWriterHistory( - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - const TopicAttributes& topic_att, - uint32_t payloadMaxSize, - rtps::MemoryManagementPolicy_t mempolicy, - std::function) - : WriterHistory(to_history_attributes(topic_att, payloadMaxSize, mempolicy), payload_pool, change_pool) +DataWriterHistory( + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, + uint32_t payloadMaxSize, + rtps::MemoryManagementPolicy_t mempolicy, + std::function) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) { } From 01de9df6f838d15bb0e92f810625c18926fecb7b Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:19:56 +0200 Subject: [PATCH 10/37] Refs #21357: Add new get_publication_builtin_topic_data() to DataWriter Signed-off-by: Mario Dominguez --- include/fastdds/dds/publisher/DataWriter.hpp | 8 +- src/cpp/fastdds/publisher/DataWriter.cpp | 5 ++ src/cpp/fastdds/publisher/DataWriterImpl.cpp | 86 +++++++++++++++---- src/cpp/fastdds/publisher/DataWriterImpl.hpp | 8 +- .../mock/fastdds/publisher/DataWriterImpl.hpp | 5 ++ 5 files changed, 94 insertions(+), 18 deletions(-) diff --git a/include/fastdds/dds/publisher/DataWriter.hpp b/include/fastdds/dds/publisher/DataWriter.hpp index c7f6227b094..dead3039ca0 100644 --- a/include/fastdds/dds/publisher/DataWriter.hpp +++ b/include/fastdds/dds/publisher/DataWriter.hpp @@ -19,6 +19,7 @@ #ifndef FASTDDS_DDS_PUBLISHER__DATAWRITER_HPP #define FASTDDS_DDS_PUBLISHER__DATAWRITER_HPP +#include #include #include #include @@ -28,9 +29,9 @@ #include #include #include +#include #include #include -#include namespace eprosima { namespace fastdds { @@ -584,6 +585,11 @@ class DataWriter : public DomainEntity const InstanceHandle_t& handle, const fastdds::dds::Duration_t& max_wait); + /** + * @brief A method to retrieve the publication data discovery information of this writer. + */ + FASTDDS_EXPORTED_API PublicationBuiltinTopicData get_publication_builtin_topic_data() const; + protected: DataWriterImpl* impl_; diff --git a/src/cpp/fastdds/publisher/DataWriter.cpp b/src/cpp/fastdds/publisher/DataWriter.cpp index aca2229dfef..82480c89789 100644 --- a/src/cpp/fastdds/publisher/DataWriter.cpp +++ b/src/cpp/fastdds/publisher/DataWriter.cpp @@ -308,6 +308,11 @@ ReturnCode_t DataWriter::wait_for_acknowledgments( return impl_->wait_for_acknowledgments(instance, handle, max_wait); } +PublicationBuiltinTopicData DataWriter::get_publication_builtin_topic_data() const +{ + return impl_->get_publication_builtin_topic_data(); +} + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index dc8af702f5b..72e814ab81c 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1680,17 +1680,49 @@ ReturnCode_t DataWriterImpl::assert_liveliness() return RETCODE_OK; } -fastdds::TopicAttributes DataWriterImpl::get_topic_attributes( - const DataWriterQos& qos, - const Topic& topic, - const TypeSupport& type) +PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() const { - fastdds::TopicAttributes topic_att; - topic_att.historyQos = qos.history(); - topic_att.resourceLimitsQos = qos.resource_limits(); - topic_att.topicName = topic.get_name(); - topic_att.topicDataType = topic.get_type_name(); - topic_att.topicKind = type->is_compute_key_provided ? WITH_KEY : NO_KEY; + PublicationBuiltinTopicData pub_builtin_data; + + // sanity checks + bool writer_is_valid = (nullptr != writer_); + bool publisher_is_valid = (nullptr != publisher_); + bool topic_is_valid = (nullptr != topic_); + bool participant_is_valid = publisher_is_valid ? (nullptr != publisher_->get_participant()) : false; + bool rtps_participant_impl_is_valid = writer_is_valid ? (nullptr != writer_->get_participant_impl()) : false; + + from_proxy_to_builtin(guid_.entityId, pub_builtin_data.key.value); + if (participant_is_valid) + { + from_proxy_to_builtin(publisher_->get_participant()->guid().guidPrefix, pub_builtin_data.participant_key.value); + } + + if (topic_is_valid) + { + pub_builtin_data.topic_name = topic_->get_name(); + pub_builtin_data.type_name = topic_->get_type_name(); + } + + // DataWriter qos + pub_builtin_data.durability = qos_.durability(); + pub_builtin_data.durability_service = qos_.durability_service(); + pub_builtin_data.deadline = qos_.deadline(); + pub_builtin_data.latency_budget = qos_.latency_budget(); + pub_builtin_data.liveliness = qos_.liveliness(); + pub_builtin_data.reliability = qos_.reliability(); + pub_builtin_data.lifespan = qos_.lifespan(); + pub_builtin_data.user_data = qos_.user_data(); + pub_builtin_data.ownership = qos_.ownership(); + pub_builtin_data.ownership_strength = qos_.ownership_strength(); + pub_builtin_data.destination_order = qos_.destination_order(); + + // Publisher qos + if (publisher_is_valid) + { + pub_builtin_data.presentation = publisher_->qos_.presentation(); + pub_builtin_data.partition = publisher_->qos_.partition(); + pub_builtin_data.group_data = publisher_->qos_.group_data(); + } using utils::to_type_propagation; using utils::TypePropagation; @@ -1701,26 +1733,26 @@ fastdds::TopicAttributes DataWriterImpl::get_topic_attributes( (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); - if (should_assign_type_information && (xtypes::TK_NONE != type->type_identifiers().type_identifier1()._d())) + if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) { xtypes::TypeInformation type_info; if (RETCODE_OK == fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type->type_identifiers(), type_info)) + type_->type_identifiers(), type_info)) { switch (type_propagation) { case TypePropagation::TYPEPROPAGATION_ENABLED: { // Use both complete and minimal type information - topic_att.type_information.type_information = type_info; + pub_builtin_data.type_information.type_information = type_info; break; } case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: { // Use minimal type information only - topic_att.type_information.type_information.minimal() = type_info.minimal(); + pub_builtin_data.type_information.type_information.minimal() = type_info.minimal(); break; } default: @@ -1729,10 +1761,32 @@ fastdds::TopicAttributes DataWriterImpl::get_topic_attributes( break; } - topic_att.type_information.assigned(true); + pub_builtin_data.type_information.assigned(true); } } - return topic_att; + pub_builtin_data.representation = qos_.representation(); + + pub_builtin_data.guid = guid(); + if (publisher_is_valid) + { + pub_builtin_data.participant_guid = publisher_->get_participant()->guid(); + } + + if (rtps_participant_impl_is_valid) + { + pub_builtin_data.persistence_guid.guidPrefix = writer_->get_participant_impl()->get_persistence_guid_prefix(); + } + pub_builtin_data.persistence_guid.entityId = c_EntityId_RTPSParticipant; + qos_.endpoint().unicast_locator_list.copy_to(pub_builtin_data.remote_locators.unicast); + qos_.endpoint().multicast_locator_list.copy_to(pub_builtin_data.remote_locators.multicast); + pub_builtin_data.max_serialized_size = type_->max_serialized_type_size; + if (rtps_participant_impl_is_valid) + { + pub_builtin_data.loopback_transformation = + writer_->get_participant_impl()->network_factory().network_configuration(); + } + + return pub_builtin_data; } OfferedIncompatibleQosStatus& DataWriterImpl::update_offered_incompatible_qos( diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.hpp b/src/cpp/fastdds/publisher/DataWriterImpl.hpp index 2b8f13fdce4..be46dadf1c0 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.hpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.hpp @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -33,8 +34,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -380,6 +381,11 @@ class DataWriterImpl : protected rtps::IReaderDataFilter void filter_is_being_removed( const char* filter_class_name); + /** + * @brief A method to retrieve the publication data discovery information. + */ + PublicationBuiltinTopicData get_publication_builtin_topic_data() const; + protected: using IChangePool = eprosima::fastdds::rtps::IChangePool; diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp index 5b9f195bd8f..cd286ced54b 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp @@ -395,6 +395,11 @@ class DataWriterImpl : protected rtps::IReaderDataFilter } } + inline PublicationBuiltinTopicData get_publication_builtin_topic_data() const + { + return PublicationBuiltinTopicData(); + } + static ReturnCode_t check_qos( const ::eprosima::fastdds::dds::DataWriterQos&) { From 5a5fbfe9d057e1fa470778d6b66c90fc6765c4a1 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:22:18 +0200 Subject: [PATCH 11/37] Refs #21357: Add new get_subscription_builtin_topic_data() to DataReader Signed-off-by: Mario Dominguez --- include/fastdds/dds/subscriber/DataReader.hpp | 8 + src/cpp/fastdds/subscriber/DataReader.cpp | 5 + src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 150 +++++++++++------- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 15 +- src/cpp/fastdds/subscriber/SubscriberImpl.cpp | 2 +- 5 files changed, 120 insertions(+), 60 deletions(-) diff --git a/include/fastdds/dds/subscriber/DataReader.hpp b/include/fastdds/dds/subscriber/DataReader.hpp index 0a2222b7eb1..e22037201e5 100644 --- a/include/fastdds/dds/subscriber/DataReader.hpp +++ b/include/fastdds/dds/subscriber/DataReader.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -1076,6 +1077,13 @@ class DataReader : public DomainEntity FASTDDS_EXPORTED_API ReturnCode_t get_listening_locators( rtps::LocatorList& locators) const; + /** + * @brief A method to retrieve the subscription data discovery information. + * + * @return The discovery information of the subscription. + */ + FASTDDS_EXPORTED_API SubscriptionBuiltinTopicData get_subscription_builtin_topic_data() const; + protected: DataReaderImpl* impl_; diff --git a/src/cpp/fastdds/subscriber/DataReader.cpp b/src/cpp/fastdds/subscriber/DataReader.cpp index 4c20043805d..9da2803eef1 100644 --- a/src/cpp/fastdds/subscriber/DataReader.cpp +++ b/src/cpp/fastdds/subscriber/DataReader.cpp @@ -488,6 +488,11 @@ ReturnCode_t DataReader::get_listening_locators( return impl_->get_listening_locators(locators); } +SubscriptionBuiltinTopicData DataReader::get_subscription_builtin_topic_data() const +{ + return impl_->get_subscription_builtin_topic_data(); +} + } /* namespace dds */ } /* namespace fastdds */ } /* namespace eprosima */ diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index ced294f57e8..e64f21f6910 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -1771,59 +1771,6 @@ void DataReaderImpl::set_qos( } } -fastdds::TopicAttributes DataReaderImpl::topic_attributes() const -{ - fastdds::TopicAttributes topic_att; - topic_att.topicKind = type_->is_compute_key_provided ? WITH_KEY : NO_KEY; - topic_att.topicName = topic_->get_impl()->get_rtps_topic_name(); - topic_att.topicDataType = topic_->get_type_name(); - topic_att.historyQos = qos_.history(); - topic_att.resourceLimitsQos = qos_.resource_limits(); - - using utils::to_type_propagation; - using utils::TypePropagation; - - auto properties = subscriber_->get_participant()->get_qos().properties(); - auto type_propagation = to_type_propagation(properties); - bool should_assign_type_information = - (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || - (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); - - if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) - { - xtypes::TypeInformation type_info; - - if (RETCODE_OK == - fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type_->type_identifiers(), type_info)) - { - switch (type_propagation) - { - case TypePropagation::TYPEPROPAGATION_ENABLED: - { - // Use both complete and minimal type information - topic_att.type_information.type_information = type_info; - break; - } - case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: - { - // Use minimal type information only - topic_att.type_information.type_information.minimal() = type_info.minimal(); - break; - } - default: - // This should never happen as other cases are protected by should_assign_type_information - assert(false); - break; - } - - topic_att.type_information.assigned(true); - } - } - - return topic_att; -} - DataReaderListener* DataReaderImpl::get_listener_for( const StatusMask& status) { @@ -2233,6 +2180,103 @@ void DataReaderImpl::try_notify_read_conditions() noexcept } } +SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data() const +{ + SubscriptionBuiltinTopicData sub_builtin_data; + + // sanity checks + bool subscriber_is_valid = (nullptr != subscriber_); + bool topic_is_valid = (nullptr != topic_); + bool participant_is_valid = subscriber_is_valid ? (nullptr != subscriber_->get_participant()) : false; + + from_proxy_to_builtin(guid_.entityId, sub_builtin_data.key.value); + + if (participant_is_valid) + { + from_proxy_to_builtin(subscriber_->get_participant()->guid().guidPrefix, sub_builtin_data.participant_key.value); + } + + if (topic_is_valid) + { + sub_builtin_data.topic_name = topic_->get_impl()->get_rtps_topic_name(); + sub_builtin_data.type_name = topic_->get_type_name(); + } + + // DataReader qos + sub_builtin_data.durability = qos_.durability(); + sub_builtin_data.deadline = qos_.deadline(); + sub_builtin_data.latency_budget = qos_.latency_budget(); + sub_builtin_data.lifespan = qos_.lifespan(); + sub_builtin_data.liveliness = qos_.liveliness(); + sub_builtin_data.reliability = qos_.reliability(); + sub_builtin_data.ownership = qos_.ownership(); + sub_builtin_data.destination_order = qos_.destination_order(); + sub_builtin_data.user_data = qos_.user_data(); + sub_builtin_data.time_based_filter = qos_.time_based_filter(); + + // Subscriber qos + if (subscriber_is_valid) + { + sub_builtin_data.presentation = subscriber_->qos_.presentation(); + sub_builtin_data.partition = subscriber_->qos_.partition(); + sub_builtin_data.group_data = subscriber_->qos_.group_data(); + } + + // X-Types 1.3 + using utils::to_type_propagation; + using utils::TypePropagation; + + auto properties = subscriber_->get_participant()->get_qos().properties(); + auto type_propagation = to_type_propagation(properties); + bool should_assign_type_information = + (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || + (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); + + if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) + { + xtypes::TypeInformation type_info; + + if (RETCODE_OK == + fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( + type_->type_identifiers(), type_info)) + { + switch (type_propagation) + { + case TypePropagation::TYPEPROPAGATION_ENABLED: + { + // Use both complete and minimal type information + sub_builtin_data.type_information.type_information = type_info; + break; + } + case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: + { + // Use minimal type information only + sub_builtin_data.type_information.type_information.minimal() = type_info.minimal(); + break; + } + default: + // This should never happen as other cases are protected by should_assign_type_information + assert(false); + break; + } + + sub_builtin_data.type_information.assigned(true); + } + } + sub_builtin_data.representation = qos_.representation(); + + sub_builtin_data.guid = guid(); + if (subscriber_is_valid) + { + sub_builtin_data.participant_guid = subscriber_->get_participant()->guid(); + } + qos_.endpoint().unicast_locator_list.copy_to(sub_builtin_data.remote_locators.unicast); + qos_.endpoint().multicast_locator_list.copy_to(sub_builtin_data.remote_locators.multicast); + sub_builtin_data.expects_inline_qos = qos_.expects_inline_qos(); + + return sub_builtin_data; +} + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index 41194cd2c20..5a2ebd49072 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -17,9 +17,8 @@ * */ -#ifndef _FASTDDS_DATAREADERIMPL_HPP_ -#define _FASTDDS_DATAREADERIMPL_HPP_ -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC +#ifndef FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP +#define FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP #include @@ -34,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +44,7 @@ #include #include #include +#include #include namespace eprosima { @@ -375,6 +374,11 @@ class DataReaderImpl std::recursive_mutex& get_conditions_mutex() const noexcept; + /** + * @brief A method to retrieve the subscription data discovery information. + */ + SubscriptionBuiltinTopicData get_subscription_builtin_topic_data() const; + protected: //!Subscriber @@ -652,5 +656,4 @@ class DataReaderImpl } /* namespace fastdds */ } /* namespace eprosima */ -#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* _FASTDDS_DATAREADERIMPL_HPP_*/ +#endif /* FASTDDS_SUBSCRIBER__DATAREADERIMPL_HPP*/ diff --git a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp index 03ecc74ebf0..077e0ca323c 100644 --- a/src/cpp/fastdds/subscriber/SubscriberImpl.cpp +++ b/src/cpp/fastdds/subscriber/SubscriberImpl.cpp @@ -564,7 +564,7 @@ bool SubscriberImpl::type_in_use( { for (DataReaderImpl* reader : it.second) { - if (reader->topic_attributes().getTopicDataType() == type_name) + if (reader->get_topicdescription()->get_type_name() == type_name) { return true; // Is in use } From 77b504adaedf917e418950efc1f552bfe13ca7c0 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:24:00 +0200 Subject: [PATCH 12/37] Refs #21357: Refactor Data*Impl Signed-off-by: Mario Dominguez --- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 9 ++++----- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 9 +++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 72e814ab81c..421c63636e3 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #ifdef FASTDDS_STATISTICS #include #include @@ -473,7 +473,7 @@ ReturnCode_t DataWriterImpl::enable() wqos.m_partition.push_back(partition_name.c_str()); } } - publisher_->rtps_participant()->registerWriter(writer_, get_topic_attributes(qos_, *topic_, type_), wqos); + publisher_->rtps_participant()->register_writer(writer_, get_publication_builtin_topic_data(), wqos); return RETCODE_OK; } @@ -1179,7 +1179,7 @@ void DataWriterImpl::publisher_qos_updated() { //NOTIFY THE BUILTIN PROTOCOLS THAT THE WRITER HAS CHANGED WriterQos wqos = qos_.get_writerqos(get_publisher()->get_qos(), topic_->get_qos()); - publisher_->rtps_participant()->updateWriter(writer_, get_topic_attributes(qos_, *topic_, type_), wqos); + publisher_->rtps_participant()->update_writer(writer_, wqos); } } @@ -1228,9 +1228,8 @@ ReturnCode_t DataWriterImpl::set_qos( } //Notify the participant that a Writer has changed its QOS - fastdds::TopicAttributes topic_att = get_topic_attributes(qos_, *topic_, type_); WriterQos wqos = qos_.get_writerqos(get_publisher()->get_qos(), topic_->get_qos()); - publisher_->rtps_participant()->updateWriter(writer_, topic_att, wqos); + publisher_->rtps_participant()->update_writer(writer_, wqos); // Deadline if (qos_.deadline().period != dds::c_TimeInfinite) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index e64f21f6910..c6658d392de 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef FASTDDS_STATISTICS #include #include @@ -297,7 +298,11 @@ ReturnCode_t DataReaderImpl::enable() { filter_property = &content_topic->filter_property; } - if (!subscriber_->rtps_participant()->registerReader(reader_, topic_attributes(), rqos, filter_property)) + if (!subscriber_->rtps_participant()->register_reader( + reader_, + get_subscription_builtin_topic_data(), + rqos, + filter_property)) { EPROSIMA_LOG_ERROR(DATA_READER, "Could not register reader on discovery protocols"); @@ -834,7 +839,7 @@ void DataReaderImpl::update_rtps_reader_qos() filter_property = &content_topic->filter_property; } ReaderQos rqos = qos_.get_readerqos(get_subscriber()->get_qos()); - subscriber_->rtps_participant()->updateReader(reader_, topic_attributes(), rqos, filter_property); + subscriber_->rtps_participant()->update_reader(reader_, rqos, filter_property); // TODO(eduponz): RTPSReader attributes must be updated here } } From 941a12eca770d32d5aab900702b050bd337e6340 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:25:06 +0200 Subject: [PATCH 13/37] Refs #21357: Add some mock methods and remove RTPS unittest Signed-off-by: Mario Dominguez --- .../rtps/network/NetworkFactory.h | 5 +++ .../RTPSWriter/rtps/writer/BaseWriter.hpp | 7 +++- test/unittest/rtps/domain/RTPSDomainTests.cpp | 42 ------------------- 3 files changed, 10 insertions(+), 44 deletions(-) diff --git a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h index 37f911d0682..fae7800f8e1 100644 --- a/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h +++ b/test/mock/rtps/NetworkFactory/rtps/network/NetworkFactory.h @@ -106,6 +106,11 @@ class NetworkFactory return {}; } + NetworkConfigSet_t network_configuration() const + { + return NetworkConfigSet_t{}; + } + }; } // namespace rtps diff --git a/test/mock/rtps/RTPSWriter/rtps/writer/BaseWriter.hpp b/test/mock/rtps/RTPSWriter/rtps/writer/BaseWriter.hpp index 9bdca775d21..ab4dfa21108 100644 --- a/test/mock/rtps/RTPSWriter/rtps/writer/BaseWriter.hpp +++ b/test/mock/rtps/RTPSWriter/rtps/writer/BaseWriter.hpp @@ -76,11 +76,14 @@ class BaseWriter : public RTPSWriter return static_cast(endpoint); } + RTPSParticipantImpl* get_participant_impl() + { + return nullptr; + } + // *INDENT-OFF* Uncrustify makes a mess with MOCK_METHOD macros MOCK_METHOD0(get_max_allowed_payload_size, uint32_t()); - MOCK_METHOD0(get_participant_impl, RTPSParticipantImpl* ()); - MOCK_METHOD4(deliver_sample_nts, DeliveryRetCode( CacheChange_t*, RTPSMessageGroup&, diff --git a/test/unittest/rtps/domain/RTPSDomainTests.cpp b/test/unittest/rtps/domain/RTPSDomainTests.cpp index cb8854c8779..0d4abbe92d6 100644 --- a/test/unittest/rtps/domain/RTPSDomainTests.cpp +++ b/test/unittest/rtps/domain/RTPSDomainTests.cpp @@ -56,48 +56,6 @@ TEST(RTPSDomainTests, library_settings_test) eprosima::fastdds::rtps::RTPSDomain::stopAll(); } -/** - * This test checks get_topic_attributes_from_profile API. - */ -TEST(RTPSDomainTests, get_topic_attributes_from_profile_test) -{ - std::string profile_name = "test_profile_name"; - eprosima::fastdds::TopicAttributes topic_att; - EXPECT_FALSE(eprosima::fastdds::rtps::RTPSDomain::get_topic_attributes_from_profile(profile_name, topic_att)); - - const std::string xml = - R"( - - Test - DataTest - - KEEP_LAST - 20 - - - 5 - 2 - 1 - 20 - 10 - - -)"; - - EXPECT_EQ(eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->load_XML_profiles_string(xml.c_str(), - xml.length()), eprosima::fastdds::dds::RETCODE_OK); - EXPECT_TRUE(eprosima::fastdds::rtps::RTPSDomain::get_topic_attributes_from_profile(profile_name, topic_att)); - EXPECT_EQ(topic_att.topicName, "Test"); - EXPECT_EQ(topic_att.topicDataType, "DataTest"); - EXPECT_EQ(topic_att.historyQos.kind, eprosima::fastdds::dds::HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS); - EXPECT_EQ(topic_att.historyQos.depth, 20); - EXPECT_EQ(topic_att.resourceLimitsQos.max_samples, 5); - EXPECT_EQ(topic_att.resourceLimitsQos.max_instances, 2); - EXPECT_EQ(topic_att.resourceLimitsQos.max_samples_per_instance, 1); - EXPECT_EQ(topic_att.resourceLimitsQos.allocated_samples, 20); - EXPECT_EQ(topic_att.resourceLimitsQos.extra_samples, 10); -} - int main( int argc, char** argv) From d5a526e6f445a7780379ed12f85d40e4283d3ef3 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:26:05 +0200 Subject: [PATCH 14/37] Refs #21357: Improve discovery server example test resilience Signed-off-by: Mario Dominguez --- examples/cpp/discovery_server/ClientPublisherApp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/cpp/discovery_server/ClientPublisherApp.cpp b/examples/cpp/discovery_server/ClientPublisherApp.cpp index 953259d07c1..52422d14afe 100644 --- a/examples/cpp/discovery_server/ClientPublisherApp.cpp +++ b/examples/cpp/discovery_server/ClientPublisherApp.cpp @@ -198,6 +198,11 @@ ClientPublisherApp::ClientPublisherApp( wqos.durability().kind = VOLATILE_DURABILITY_QOS; } + // So as not to overwriter the first sample + // if we publish inmediately after the discovery + // and the suscription is not prepared yet + wqos.history().depth = 5; + writer_ = publisher_->create_datawriter(topic_, wqos, this); if (writer_ == nullptr) From 29225c1ca75bbde096fc05a9bf40fcb41ca432ad Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Thu, 18 Jul 2024 15:49:13 +0200 Subject: [PATCH 15/37] Refs #21357: Linter Signed-off-by: Mario Dominguez --- include/fastdds/rtps/common/LocatorList.hpp | 2 +- .../fastdds/publisher/DataWriterHistory.cpp | 5 +++-- .../fastdds/publisher/DataWriterHistory.hpp | 2 +- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 2 +- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 3 ++- .../rtps/builtin/discovery/endpoint/EDP.cpp | 8 +++++-- .../fastdds/publisher/DataWriterHistory.hpp | 13 ++++++------ .../fastdds/publisher/DataWriterHistory.hpp | 21 ++++++++++--------- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/include/fastdds/rtps/common/LocatorList.hpp b/include/fastdds/rtps/common/LocatorList.hpp index f2a3ad8dfaf..3779cc4beed 100644 --- a/include/fastdds/rtps/common/LocatorList.hpp +++ b/include/fastdds/rtps/common/LocatorList.hpp @@ -381,7 +381,7 @@ class LocatorList FASTDDS_EXPORTED_API void copy_to( eprosima::fastdds::ResourceLimitedVector& locator_list) const { - for(auto& locator : m_locators) + for (auto& locator : m_locators) { locator_list.emplace_back(locator); } diff --git a/src/cpp/fastdds/publisher/DataWriterHistory.cpp b/src/cpp/fastdds/publisher/DataWriterHistory.cpp index 1e55db9f40b..963ae6c3c39 100644 --- a/src/cpp/fastdds/publisher/DataWriterHistory.cpp +++ b/src/cpp/fastdds/publisher/DataWriterHistory.cpp @@ -69,7 +69,8 @@ DataWriterHistory::DataWriterHistory( uint32_t payloadMaxSize, MemoryManagementPolicy_t mempolicy, std::function unack_sample_remove_functor) - : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, + mempolicy), payload_pool, change_pool) , history_qos_(history_qos) , resource_limited_qos_(resource_limits_qos) , topic_kind_(topic_kind) @@ -278,7 +279,7 @@ bool DataWriterHistory::add_pub_change( { EPROSIMA_LOG_INFO(RTPS_HISTORY, " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle - << " and " << change->serializedPayload.length << " bytes"); + << " and " << change->serializedPayload.length << " bytes"); returnedValue = true; } } diff --git a/src/cpp/fastdds/publisher/DataWriterHistory.hpp b/src/cpp/fastdds/publisher/DataWriterHistory.hpp index 86ea840533f..489e0f41bb7 100644 --- a/src/cpp/fastdds/publisher/DataWriterHistory.hpp +++ b/src/cpp/fastdds/publisher/DataWriterHistory.hpp @@ -156,7 +156,7 @@ class DataWriterHistory : public rtps::WriterHistory { EPROSIMA_LOG_INFO(RTPS_HISTORY, " Change " << change->sequenceNumber << " added with key: " << change->instanceHandle - << " and " << change->serializedPayload.length << " bytes"); + << " and " << change->serializedPayload.length << " bytes"); returnedValue = true; } } diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 421c63636e3..fa2ee5e4212 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1782,7 +1782,7 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() if (rtps_participant_impl_is_valid) { pub_builtin_data.loopback_transformation = - writer_->get_participant_impl()->network_factory().network_configuration(); + writer_->get_participant_impl()->network_factory().network_configuration(); } return pub_builtin_data; diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index c6658d392de..fba4ba85dca 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -2198,7 +2198,8 @@ SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data if (participant_is_valid) { - from_proxy_to_builtin(subscriber_->get_participant()->guid().guidPrefix, sub_builtin_data.participant_key.value); + from_proxy_to_builtin(subscriber_->get_participant()->guid().guidPrefix, + sub_builtin_data.participant_key.value); } if (topic_is_valid) diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 8d5dc43fcc3..2a234612f63 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -99,7 +99,9 @@ bool EDP::new_reader_proxy_data( const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_reader->getGuid().entityId << " in topic " << sub_builtin_data.topic_name.to_string()); + EPROSIMA_LOG_INFO(RTPS_EDP, + "Adding " << rtps_reader->getGuid().entityId << " in topic " << + sub_builtin_data.topic_name.to_string()); auto init_fun = [this, rtps_reader, &sub_builtin_data, &rqos, content_filter]( ReaderProxyData* rpd, @@ -239,7 +241,9 @@ bool EDP::new_writer_proxy_data( const PublicationBuiltinTopicData& pub_builtin_data, const fastdds::dds::WriterQos& wqos) { - EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_writer->getGuid().entityId << " in topic " << pub_builtin_data.topic_name.to_string()); + EPROSIMA_LOG_INFO(RTPS_EDP, + "Adding " << rtps_writer->getGuid().entityId << " in topic " << + pub_builtin_data.topic_name.to_string()); auto init_fun = [this, rtps_writer, &pub_builtin_data, &wqos]( WriterProxyData* wpd, diff --git a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp index 4da80f4aa3b..f04652bcf75 100644 --- a/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp +++ b/test/mock/dds/DataWriterHistory/fastdds/publisher/DataWriterHistory.hpp @@ -45,11 +45,11 @@ class DataWriterHistory : public WriterHistory public: static HistoryAttributes to_history_attributes( - const HistoryQosPolicy& history_qos, - const ResourceLimitsQosPolicy& resource_limits_qos, - const rtps::TopicKind_t& topic_kind, - uint32_t payloadMaxSize, - MemoryManagementPolicy_t mempolicy) + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, + uint32_t payloadMaxSize, + MemoryManagementPolicy_t mempolicy) { auto initial_samples = resource_limits_qos.allocated_samples; auto max_samples = resource_limits_qos.max_samples; @@ -78,7 +78,8 @@ class DataWriterHistory : public WriterHistory uint32_t payloadMaxSize, MemoryManagementPolicy_t mempolicy, std::function unack_sample_remove_functor) - : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, + mempolicy), payload_pool, change_pool) , history_qos_(history_qos) , resource_limited_qos_(resource_limits_qos) , topic_kind_(topic_kind) diff --git a/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp b/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp index 8ee40d4061b..c87ffa31714 100644 --- a/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp +++ b/test/unittest/statistics/rtps/mock/Publisher/fastdds/publisher/DataWriterHistory.hpp @@ -60,16 +60,17 @@ class DataWriterHistory : public fastdds::rtps::WriterHistory { public: -DataWriterHistory( - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - const HistoryQosPolicy& history_qos, - const ResourceLimitsQosPolicy& resource_limits_qos, - const rtps::TopicKind_t& topic_kind, - uint32_t payloadMaxSize, - rtps::MemoryManagementPolicy_t mempolicy, - std::function) - : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, mempolicy), payload_pool, change_pool) + DataWriterHistory( + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + const HistoryQosPolicy& history_qos, + const ResourceLimitsQosPolicy& resource_limits_qos, + const rtps::TopicKind_t& topic_kind, + uint32_t payloadMaxSize, + rtps::MemoryManagementPolicy_t mempolicy, + std::function) + : WriterHistory(to_history_attributes(history_qos, resource_limits_qos, topic_kind, payloadMaxSize, + mempolicy), payload_pool, change_pool) { } From 42c1bcc3b068328c680dcc83bc897903e8c8a928 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Tue, 23 Jul 2024 16:45:18 +0200 Subject: [PATCH 16/37] Refs #21357: Update RTPS example Signed-off-by: Mario Dominguez --- examples/cpp/rtps/ReaderApp.cpp | 11 +++++------ examples/cpp/rtps/WriterApp.cpp | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/cpp/rtps/ReaderApp.cpp b/examples/cpp/rtps/ReaderApp.cpp index 1c150835a6d..10acf028f17 100644 --- a/examples/cpp/rtps/ReaderApp.cpp +++ b/examples/cpp/rtps/ReaderApp.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,17 +114,16 @@ ReaderApp::ReaderApp( std::cout << "Registering RTPS Reader" << std::endl; - TopicAttributes topic_att; - topic_att.topicKind = NO_KEY; - topic_att.topicDataType = "HelloWorld"; - topic_att.topicName = topic_name; + SubscriptionBuiltinTopicData sub_builtin_data; + sub_builtin_data.topic_name = topic_name; + sub_builtin_data.type_name = "HelloWorld"; eprosima::fastdds::dds::ReaderQos reader_qos; reader_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; reader_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->registerReader(rtps_reader_, topic_att, reader_qos)) + if (!rtps_participant_->register_reader(rtps_reader_, sub_builtin_data, reader_qos)) { throw std::runtime_error("Entity registration failed"); } diff --git a/examples/cpp/rtps/WriterApp.cpp b/examples/cpp/rtps/WriterApp.cpp index 6929d1b37ec..cc99a6d7d05 100644 --- a/examples/cpp/rtps/WriterApp.cpp +++ b/examples/cpp/rtps/WriterApp.cpp @@ -28,8 +28,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -105,17 +105,16 @@ WriterApp::WriterApp( std::cout << "Registering RTPS Writer" << std::endl; - TopicAttributes topic_att; - topic_att.topicKind = NO_KEY; - topic_att.topicDataType = "HelloWorld"; - topic_att.topicName = topic_name; + PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.type_name = "HelloWorld"; + pub_builtin_data.topic_name = topic_name; eprosima::fastdds::dds::WriterQos writer_qos; writer_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; writer_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->registerWriter(rtps_writer_, topic_att, writer_qos)) + if (!rtps_participant_->register_writer(rtps_writer_, pub_builtin_data, writer_qos)) { throw std::runtime_error("Entity registration failed"); } From d4901d7e3fb3896b20b39b05c7372eafb4730abe Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 24 Jul 2024 14:09:41 +0200 Subject: [PATCH 17/37] Refs #21357. Remove ReaderQos from register_reader. Signed-off-by: Miguel Company --- examples/cpp/rtps/ReaderApp.cpp | 8 +-- .../rtps/participant/RTPSParticipant.hpp | 2 - src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 63 +++++++++++-------- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 1 + src/cpp/rtps/builtin/BuiltinProtocols.cpp | 5 +- src/cpp/rtps/builtin/BuiltinProtocols.h | 8 +-- .../rtps/builtin/discovery/endpoint/EDP.cpp | 8 ++- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 10 +-- src/cpp/rtps/builtin/liveliness/WLP.cpp | 4 +- src/cpp/rtps/builtin/liveliness/WLP.hpp | 6 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 3 +- .../rtps/participant/RTPSParticipantImpl.cpp | 3 +- .../rtps/participant/RTPSParticipantImpl.h | 2 - .../common/RTPSWithRegistrationReader.hpp | 2 +- .../rtps/participant/RTPSParticipant.hpp | 3 +- .../rtps/builtin/data/ReaderProxyData.hpp | 18 ++++++ .../rtps/builtin/data/WriterProxyData.hpp | 23 +++++++ test/unittest/dds/status/ListenerTests.cpp | 2 +- test/unittest/rtps/discovery/CMakeLists.txt | 1 + .../rtps/reader/StatefulReaderTests.cpp | 2 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 15 +++-- 21 files changed, 117 insertions(+), 72 deletions(-) diff --git a/examples/cpp/rtps/ReaderApp.cpp b/examples/cpp/rtps/ReaderApp.cpp index 10acf028f17..c0d6d4ba6c0 100644 --- a/examples/cpp/rtps/ReaderApp.cpp +++ b/examples/cpp/rtps/ReaderApp.cpp @@ -117,13 +117,11 @@ ReaderApp::ReaderApp( SubscriptionBuiltinTopicData sub_builtin_data; sub_builtin_data.topic_name = topic_name; sub_builtin_data.type_name = "HelloWorld"; - - eprosima::fastdds::dds::ReaderQos reader_qos; - reader_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; - reader_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; + sub_builtin_data.durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + sub_builtin_data.reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->register_reader(rtps_reader_, sub_builtin_data, reader_qos)) + if (!rtps_participant_->register_reader(rtps_reader_, sub_builtin_data)) { throw std::runtime_error("Entity registration failed"); } diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 9ea6d4af3d7..0f05f37c0b2 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -154,14 +154,12 @@ class FASTDDS_EXPORTED_API RTPSParticipant * Register a Reader in the BuiltinProtocols. * @param rtps_reader Pointer to the RTPSReader. * @param sub_builtin_data Contains the discovery information of the reader. - * @param rqos ReaderQos. * @param content_filter Optional content filtering information. * @return True if correctly registered. */ bool register_reader( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); /** diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index fba4ba85dca..d6cb41c26f9 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -215,13 +215,13 @@ ReturnCode_t DataReaderImpl::enable() att.endpoint.properties.properties().push_back(std::move(property)); } - bool is_datasharing_compatible = false; - ReturnCode_t ret_code = check_datasharing_compatible(att, is_datasharing_compatible); + is_data_sharing_compatible_ = false; + ReturnCode_t ret_code = check_datasharing_compatible(att, is_data_sharing_compatible_); if (ret_code != RETCODE_OK) { return ret_code; } - if (is_datasharing_compatible) + if (is_data_sharing_compatible_) { DataSharingQosPolicy datasharing(qos_.data_sharing()); if (datasharing.domain_ids().empty()) @@ -276,22 +276,7 @@ ReturnCode_t DataReaderImpl::enable() qos_.lifespan().duration.to_ns() * 1e-6); // Register the reader - ReaderQos rqos = qos_.get_readerqos(subscriber_->get_qos()); - if (!is_datasharing_compatible) - { - rqos.data_sharing.off(); - } - if (endpoint_partitions) - { - std::istringstream partition_string(*endpoint_partitions); - std::string partition_name; - rqos.m_partition.clear(); - - while (std::getline(partition_string, partition_name, ';')) - { - rqos.m_partition.push_back(partition_name.c_str()); - } - } + auto builtin_topic_data = get_subscription_builtin_topic_data(); rtps::ContentFilterProperty* filter_property = nullptr; if (nullptr != content_topic && !content_topic->filter_property.filter_expression.empty()) @@ -300,8 +285,7 @@ ReturnCode_t DataReaderImpl::enable() } if (!subscriber_->rtps_participant()->register_reader( reader_, - get_subscription_builtin_topic_data(), - rqos, + builtin_topic_data, filter_property)) { EPROSIMA_LOG_ERROR(DATA_READER, "Could not register reader on discovery protocols"); @@ -1851,7 +1835,7 @@ void DataReaderImpl::release_payload_pool() ReturnCode_t DataReaderImpl::check_datasharing_compatible( const ReaderAttributes& reader_attributes, - bool& is_datasharing_compatible) const + bool& is_data_sharing_compatible) const { #if HAVE_SECURITY bool has_security_enabled = subscriber_->rtps_participant()->is_security_enabled_for_reader(reader_attributes); @@ -1861,7 +1845,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( bool has_key = type_->is_compute_key_provided; - is_datasharing_compatible = false; + is_data_sharing_compatible = false; switch (qos_.data_sharing().kind()) { case DataSharingKind::OFF: @@ -1887,7 +1871,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( return RETCODE_BAD_PARAMETER; } - is_datasharing_compatible = true; + is_data_sharing_compatible = true; return RETCODE_OK; break; case DataSharingKind::AUTO: @@ -1911,7 +1895,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( return RETCODE_OK; } - is_datasharing_compatible = true; + is_data_sharing_compatible = true; return RETCODE_OK; break; default: @@ -2267,10 +2251,22 @@ SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data } sub_builtin_data.type_information.assigned(true); + sub_builtin_data.type_consistency = qos_.type_consistency(); } } sub_builtin_data.representation = qos_.representation(); + // eProsima Extensions + + sub_builtin_data.disable_positive_acks = qos_.reliable_reader_qos().disable_positive_acks; + sub_builtin_data.data_sharing = qos_.data_sharing(); + + if (sub_builtin_data.data_sharing.kind() != OFF && + sub_builtin_data.data_sharing.domain_ids().empty()) + { + sub_builtin_data.data_sharing.add_domain_id(utils::default_domain_id()); + } + sub_builtin_data.guid = guid(); if (subscriber_is_valid) { @@ -2280,6 +2276,23 @@ SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data qos_.endpoint().multicast_locator_list.copy_to(sub_builtin_data.remote_locators.multicast); sub_builtin_data.expects_inline_qos = qos_.expects_inline_qos(); + if (!is_data_sharing_compatible_) + { + sub_builtin_data.data_sharing.off(); + } + const std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions"); + if (endpoint_partitions) + { + std::istringstream partition_string(*endpoint_partitions); + std::string partition_name; + sub_builtin_data.partition.clear(); + + while (std::getline(partition_string, partition_name, ';')) + { + sub_builtin_data.partition.push_back(partition_name.c_str()); + } + } + return sub_builtin_data; } diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index 5a2ebd49072..e9f2fc9c1bf 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -649,6 +649,7 @@ class DataReaderImpl DataReaderQos get_datareader_qos_from_settings( const DataReaderQos& qos); + bool is_data_sharing_compatible_ = false; }; diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index d4aafc2819c..eab4c955bec 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -232,14 +232,13 @@ bool BuiltinProtocols::add_writer( bool BuiltinProtocols::add_reader( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { bool ok = true; if (nullptr != mp_PDP) { - ok = mp_PDP->get_edp()->new_reader_proxy_data(rtps_reader, sub_builtin_data, rqos, content_filter); + ok = mp_PDP->get_edp()->new_reader_proxy_data(rtps_reader, sub_builtin_data, content_filter); if (!ok) { @@ -254,7 +253,7 @@ bool BuiltinProtocols::add_reader( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_reader(rtps_reader, rqos); + ok &= mp_WLP->add_local_reader(rtps_reader, sub_builtin_data.liveliness); } return ok; diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index 8b55aae7439..18ca3188164 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -140,16 +140,14 @@ class BuiltinProtocols const fastdds::dds::WriterQos& wqos); /** * Add a local reader to the BuiltinProtocols. - * @param rtps_reader Pointer to the RTPSReader. - * @param topicAtt Attributes of the associated topic - * @param rqos QoS policies dictated by the subscriber - * @param content_filter Optional content filtering information. + * @param rtps_reader Pointer to the RTPSReader. + * @param sub_builtin_data QoS policies dictated by the subscriber + * @param content_filter Optional content filtering information. * @return True if correct. */ bool add_reader( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 2a234612f63..6fa1c10e74b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -96,14 +97,13 @@ EDP::~EDP() bool EDP::new_reader_proxy_data( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter) { EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_reader->getGuid().entityId << " in topic " << sub_builtin_data.topic_name.to_string()); - auto init_fun = [this, rtps_reader, &sub_builtin_data, &rqos, content_filter]( + auto init_fun = [this, rtps_reader, &sub_builtin_data, content_filter]( ReaderProxyData* rpd, bool updating, const ParticipantProxyData& participant_data) @@ -119,6 +119,8 @@ bool EDP::new_reader_proxy_data( const NetworkFactory& network = mp_RTPSParticipant->network_factory(); const auto& ratt = rtps_reader->getAttributes(); + from_builtin_to_proxy(sub_builtin_data, *rpd); + rpd->isAlive(true); rpd->m_expectsInlineQos = rtps_reader->expects_inline_qos(); rpd->guid(rtps_reader->getGuid()); @@ -175,7 +177,7 @@ bool EDP::new_reader_proxy_data( } } - rpd->m_qos.setQos(rqos, true); + rpd->m_qos.setQos(rpd->m_qos, true); rpd->userDefinedId(ratt.getUserDefinedID()); if (nullptr != content_filter) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index a93cf1cb54c..c7d273cacbe 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -166,16 +166,16 @@ class EDP /** * Create a new ReaderPD for a local Reader. - * @param rtps_reader Pointer to the RTPSReader. - * @param sub_builtin_data Subscription data for the reader. - * @param qos QoS policies dictated by the subscriber. - * @param content_filter Optional content filtering information. + * + * @param rtps_reader Pointer to the RTPSReader. + * @param sub_builtin_data Subscription data for the reader. + * @param content_filter Optional content filtering information. + * * @return True if correct. */ bool new_reader_proxy_data( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * Create a new ReaderPD for a local Writer. diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index d283943d496..54531198637 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -832,13 +832,13 @@ bool WLP::remove_local_writer( bool WLP::add_local_reader( RTPSReader* reader, - const fastdds::dds::ReaderQos& rqos) + const fastdds::dds::LivelinessQosPolicy& qos) { auto base_reader = BaseReader::downcast(reader); std::lock_guard guard(*mp_builtinProtocols->mp_PDP->getMutex()); - if (rqos.m_liveliness.kind == dds::AUTOMATIC_LIVELINESS_QOS) + if (qos.kind == dds::AUTOMATIC_LIVELINESS_QOS) { automatic_readers_ = true; } diff --git a/src/cpp/rtps/builtin/liveliness/WLP.hpp b/src/cpp/rtps/builtin/liveliness/WLP.hpp index 9849ff8b60e..1a28e51198c 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.hpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.hpp @@ -125,13 +125,13 @@ class WLP /** * @brief Adds a local reader to the liveliness protocol - * @param reader Pointer to the RTPS reader - * @param rqos Quality of service policies for the reader + * @param reader Pointer to the RTPS reader + * @param qos Quality of service policies for the reader * @return True if added successfully */ bool add_local_reader( RTPSReader* reader, - const fastdds::dds::ReaderQos& rqos); + const fastdds::dds::LivelinessQosPolicy& qos); /** * @brief Removes a local reader from the livliness protocol diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 24b08105c75..d822c2d4f58 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -86,10 +86,9 @@ bool RTPSParticipant::register_writer( bool RTPSParticipant::register_reader( RTPSReader* reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return mp_impl->register_reader(reader, sub_builtin_data, rqos, content_filter); + return mp_impl->register_reader(reader, sub_builtin_data, content_filter); } void RTPSParticipant::update_attributes( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 49b9a4c5469..6798d825e37 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1415,10 +1415,9 @@ bool RTPSParticipantImpl::register_writer( bool RTPSParticipantImpl::register_reader( RTPSReader* rtps_reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter) { - return this->mp_builtinProtocols->add_reader(rtps_reader, sub_builtin_data, rqos, content_filter); + return this->mp_builtinProtocols->add_reader(rtps_reader, sub_builtin_data, content_filter); } void RTPSParticipantImpl::update_attributes( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 58b07431a9b..848c7bf68dd 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -909,14 +909,12 @@ class RTPSParticipantImpl * Register a Reader in the BuiltinProtocols. * @param Reader Pointer to the RTPSReader. * @param sub_builtin_data Contains the discovery information of the reader. - * @param rqos ReaderQos. * @param content_filter Optional content filtering information. * @return True if correctly registered. */ bool register_reader( RTPSReader* Reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const ContentFilterProperty* content_filter = nullptr); /** diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index e3702acd245..f552c4929b4 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -193,7 +193,7 @@ class RTPSWithRegistrationReader return; } - initialized_ = participant_->register_reader(reader_, sub_builtin_data_, reader_qos_, content_filter_property_); + initialized_ = participant_->register_reader(reader_, sub_builtin_data_, content_filter_property_); } void update() diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index 7406a2e3cf3..5791386c72f 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -194,10 +194,9 @@ class FASTDDS_EXPORTED_API RTPSParticipant RTPSWriter * Writer, const fastdds::dds::WriterQos& wqos)); - MOCK_METHOD4(register_reader, bool( + MOCK_METHOD3(register_reader, bool( RTPSReader * Reader, const SubscriptionBuiltinTopicData& sub_builtin_data, - const fastdds::dds::ReaderQos& rqos, const fastdds::rtps::ContentFilterProperty* content_filter)); MOCK_METHOD3(update_reader, bool( diff --git a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp index f2565882519..11ee5143594 100644 --- a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp +++ b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp @@ -324,6 +324,23 @@ class ReaderProxyData return content_filter_; } + void networkConfiguration( + const NetworkConfigSet_t& networkConfiguration) + { + m_networkConfiguration = networkConfiguration; + } + + void networkConfiguration( + NetworkConfigSet_t&& networkConfiguration) + { + m_networkConfiguration = std::move(networkConfiguration); + } + + const NetworkConfigSet_t& networkConfiguration() const + { + return m_networkConfiguration; + } + void copy( ReaderProxyData* /*rdat*/) { @@ -351,6 +368,7 @@ class ReaderProxyData InstanceHandle_t m_RTPSParticipantKey; uint16_t m_userDefinedId; fastdds::rtps::ContentFilterProperty content_filter_; + NetworkConfigSet_t m_networkConfiguration; bool has_type_info_ {false}; }; diff --git a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp index 1a67868820b..62f861d961e 100644 --- a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp +++ b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp @@ -297,6 +297,28 @@ class WriterProxyData return m_userDefinedId; } + void networkConfiguration( + const NetworkConfigSet_t& networkConfiguration) + { + m_networkConfiguration = networkConfiguration; + } + + void networkConfiguration( + NetworkConfigSet_t&& networkConfiguration) + { + m_networkConfiguration = std::move(networkConfiguration); + } + + const NetworkConfigSet_t& networkConfiguration() const + { + return m_networkConfiguration; + } + + NetworkConfigSet_t& networkConfiguration() + { + return m_networkConfiguration; + } + void copy( WriterProxyData* /*wdat*/) { @@ -323,6 +345,7 @@ class WriterProxyData InstanceHandle_t m_key; InstanceHandle_t m_RTPSParticipantKey; uint16_t m_userDefinedId; + NetworkConfigSet_t m_networkConfiguration; bool has_type_info_ {false}; }; diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index 91fec1db748..e02ae6d8366 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -585,7 +585,7 @@ class UserListeners : public ::testing::Test ASSERT_NE(subscriber_, nullptr); EXPECT_CALL(participant_mock_, - register_reader(&reader_mock_, ::testing::_, ::testing::_, nullptr)).WillRepeatedly( + register_reader(&reader_mock_, ::testing::_, nullptr)).WillRepeatedly( ::testing::Return(true)); datareader_ = diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index c0a814f300a..45505e83d5b 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -21,6 +21,7 @@ set(EDPTESTS_SOURCE EdpTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/SerializedPayload.cpp diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index f2ba8694054..217b87f6a86 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -96,7 +96,7 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) PublicationBuiltinTopicData pub_builtin_data; pub_builtin_data.type_name = "string"; pub_builtin_data.topic_name = "topic"; - part->register_reader(reader, sub_builtin_data, {}); + part->register_reader(reader, sub_builtin_data); part->register_writer(writer, pub_builtin_data, {}); // After registration, the writer should be matched diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index f5fd0d7120d..40956858a14 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -362,9 +362,15 @@ class RTPSStatisticsTestsImpl pub_builtin_data.type_name = data_type; pub_builtin_data.topic_name = topic_name; + auto& ratt = writer_->getAttributes(); SubscriptionBuiltinTopicData sub_builtin_data; sub_builtin_data.type_name = data_type; sub_builtin_data.topic_name = topic_name; + sub_builtin_data.durability.durabilityKind(ratt.durabilityKind); + sub_builtin_data.reliability.kind = + RELIABLE == + ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; + dds::WriterQos Wqos; auto& watt = writer_->getAttributes(); @@ -373,15 +379,8 @@ class RTPSStatisticsTestsImpl RELIABLE == watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - dds::ReaderQos Rqos; - auto& ratt = writer_->getAttributes(); - Rqos.m_durability.durabilityKind(ratt.durabilityKind); - Rqos.m_reliability.kind = - RELIABLE == - ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - participant_->register_writer(writer_, pub_builtin_data, Wqos); - participant_->register_reader(reader_, sub_builtin_data, Rqos); + participant_->register_reader(reader_, sub_builtin_data); } void destroy_endpoints() From 61ae807de4ab401376a86096c7820bec45160bbb Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Wed, 24 Jul 2024 15:36:13 +0200 Subject: [PATCH 18/37] Refs #21357. Remove WriterQos from register_writer. Signed-off-by: Miguel Company --- examples/cpp/rtps/WriterApp.cpp | 8 ++-- .../rtps/participant/RTPSParticipant.hpp | 4 +- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 48 ++++++++++++------- src/cpp/rtps/builtin/BuiltinProtocols.cpp | 7 ++- src/cpp/rtps/builtin/BuiltinProtocols.h | 8 ++-- .../rtps/builtin/discovery/endpoint/EDP.cpp | 9 ++-- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 8 ++-- src/cpp/rtps/builtin/liveliness/WLP.cpp | 19 ++++---- src/cpp/rtps/builtin/liveliness/WLP.hpp | 4 +- src/cpp/rtps/participant/RTPSParticipant.cpp | 5 +- .../rtps/participant/RTPSParticipantImpl.cpp | 9 ++-- .../rtps/participant/RTPSParticipantImpl.h | 4 +- .../common/RTPSBlackboxTestsBasic.cpp | 3 +- .../common/RTPSWithRegistrationWriter.hpp | 2 +- .../rtps/participant/RTPSParticipant.hpp | 5 +- .../rtps/reader/StatefulReaderTests.cpp | 2 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 15 +++--- 17 files changed, 78 insertions(+), 82 deletions(-) diff --git a/examples/cpp/rtps/WriterApp.cpp b/examples/cpp/rtps/WriterApp.cpp index cc99a6d7d05..f80dc2bb25d 100644 --- a/examples/cpp/rtps/WriterApp.cpp +++ b/examples/cpp/rtps/WriterApp.cpp @@ -108,13 +108,11 @@ WriterApp::WriterApp( PublicationBuiltinTopicData pub_builtin_data; pub_builtin_data.type_name = "HelloWorld"; pub_builtin_data.topic_name = topic_name; - - eprosima::fastdds::dds::WriterQos writer_qos; - writer_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; - writer_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; + pub_builtin_data.durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + pub_builtin_data.reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->register_writer(rtps_writer_, pub_builtin_data, writer_qos)) + if (!rtps_participant_->register_writer(rtps_writer_, pub_builtin_data)) { throw std::runtime_error("Entity registration failed"); } diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 0f05f37c0b2..91de38df483 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -142,13 +142,11 @@ class FASTDDS_EXPORTED_API RTPSParticipant * Register a Writer in the BuiltinProtocols. * @param rtps_writer Pointer to the RTPSWriter. * @param pub_builtin_data Contains the discovery information of the writer. - * @param wqos WriterQos. * @return True if correctly registered. */ bool register_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos); + const PublicationBuiltinTopicData& pub_builtin_data); /** * Register a Reader in the BuiltinProtocols. diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index fa2ee5e4212..fe80c75f38c 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -457,23 +457,8 @@ ReturnCode_t DataWriterImpl::enable() } // REGISTER THE WRITER - WriterQos wqos = qos_.get_writerqos(get_publisher()->get_qos(), topic_->get_qos()); - if (!is_data_sharing_compatible_) - { - wqos.data_sharing.off(); - } - if (endpoint_partitions) - { - std::istringstream partition_string(*endpoint_partitions); - std::string partition_name; - wqos.m_partition.clear(); - - while (std::getline(partition_string, partition_name, ';')) - { - wqos.m_partition.push_back(partition_name.c_str()); - } - } - publisher_->rtps_participant()->register_writer(writer_, get_publication_builtin_topic_data(), wqos); + auto builtin_topic_data = get_publication_builtin_topic_data(); + publisher_->rtps_participant()->register_writer(writer_, builtin_topic_data); return RETCODE_OK; } @@ -1700,6 +1685,7 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() { pub_builtin_data.topic_name = topic_->get_name(); pub_builtin_data.type_name = topic_->get_type_name(); + pub_builtin_data.topic_data = topic_->get_qos().topic_data(); } // DataWriter qos @@ -1765,6 +1751,17 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() } pub_builtin_data.representation = qos_.representation(); + // eProsima extensions + + pub_builtin_data.disable_positive_acks = qos_.reliable_writer_qos().disable_positive_acks; + pub_builtin_data.data_sharing = qos_.data_sharing(); + + if (pub_builtin_data.data_sharing.kind() != OFF && + pub_builtin_data.data_sharing.domain_ids().empty()) + { + pub_builtin_data.data_sharing.add_domain_id(utils::default_domain_id()); + } + pub_builtin_data.guid = guid(); if (publisher_is_valid) { @@ -1785,6 +1782,23 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() writer_->get_participant_impl()->network_factory().network_configuration(); } + if (!is_data_sharing_compatible_) + { + pub_builtin_data.data_sharing.off(); + } + + const std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions"); + if (endpoint_partitions) + { + std::istringstream partition_string(*endpoint_partitions); + std::string partition_name; + pub_builtin_data.partition.clear(); + + while (std::getline(partition_string, partition_name, ';')) + { + pub_builtin_data.partition.push_back(partition_name.c_str()); + } + } return pub_builtin_data; } diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index eab4c955bec..538a28099b1 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -197,14 +197,13 @@ void BuiltinProtocols::filter_server_remote_locators( bool BuiltinProtocols::add_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos) + const PublicationBuiltinTopicData& pub_builtin_data) { bool ok = true; if (nullptr != mp_PDP) { - ok = mp_PDP->get_edp()->new_writer_proxy_data(rtps_writer, pub_builtin_data, wqos); + ok = mp_PDP->get_edp()->new_writer_proxy_data(rtps_writer, pub_builtin_data); if (!ok) { @@ -219,7 +218,7 @@ bool BuiltinProtocols::add_writer( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_writer(rtps_writer, wqos); + ok &= mp_WLP->add_local_writer(rtps_writer, pub_builtin_data.liveliness); } else { diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index 18ca3188164..acf2ee0f638 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -129,15 +129,13 @@ class BuiltinProtocols /** * Add a local writer to the BuiltinProtocols. - * @param writer Pointer to the RTPSWriter - * @param topicAtt Attributes of the associated topic - * @param wqos QoS policies dictated by the publisher + * @param writer Pointer to the RTPSWriter + * @param pub_builtin_data QoS policies dictated by the publisher * @return True if correct. */ bool add_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos); + const PublicationBuiltinTopicData& pub_builtin_data); /** * Add a local reader to the BuiltinProtocols. * @param rtps_reader Pointer to the RTPSReader. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 6fa1c10e74b..7ea6c7906ab 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -240,14 +240,13 @@ bool EDP::new_reader_proxy_data( bool EDP::new_writer_proxy_data( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos) + const PublicationBuiltinTopicData& pub_builtin_data) { EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_writer->getGuid().entityId << " in topic " << pub_builtin_data.topic_name.to_string()); - auto init_fun = [this, rtps_writer, &pub_builtin_data, &wqos]( + auto init_fun = [this, rtps_writer, &pub_builtin_data]( WriterProxyData* wpd, bool updating, const ParticipantProxyData& participant_data) @@ -260,6 +259,8 @@ bool EDP::new_writer_proxy_data( return false; } + from_builtin_to_proxy(pub_builtin_data, *wpd); + const NetworkFactory& network = mp_RTPSParticipant->network_factory(); const auto& watt = rtps_writer->getAttributes(); @@ -320,7 +321,7 @@ bool EDP::new_writer_proxy_data( BaseWriter* base_writer = BaseWriter::downcast(rtps_writer); assert(base_writer->get_history() != nullptr); wpd->typeMaxSerialized(base_writer->get_history()->getTypeMaxSerialized()); - wpd->m_qos.setQos(wqos, true); + wpd->m_qos.setQos(wpd->m_qos, true); wpd->userDefinedId(watt.getUserDefinedID()); wpd->persistence_guid(watt.persistence_guid); #if HAVE_SECURITY diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index c7d273cacbe..ce5f3edebc7 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -179,15 +179,13 @@ class EDP const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * Create a new ReaderPD for a local Writer. - * @param rtps_writer Pointer to the RTPSWriter. - * @param pub_builtin_data Publication data for the writer. - * @param qos QoS policies dictated by the publisher. + * @param rtps_writer Pointer to the RTPSWriter. + * @param pub_builtin_data QoS policies dictated by the publisher. * @return True if correct. */ bool new_writer_proxy_data( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& qos); + const PublicationBuiltinTopicData& pub_builtin_data); /** * A previously created Reader has been updated * @param rtps_reader Pointer to the RTPSReader. diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index 54531198637..a5ce70a149c 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -618,7 +618,7 @@ void WLP::removeRemoteEndpoints( bool WLP::add_local_writer( RTPSWriter* writer, - const fastdds::dds::WriterQos& wqos) + const fastdds::dds::LivelinessQosPolicy& qos) { std::lock_guard guard(*mp_builtinProtocols->mp_PDP->getMutex()); @@ -626,10 +626,9 @@ bool WLP::add_local_writer( BaseWriter* base_writer = BaseWriter::downcast(writer); - double wAnnouncementPeriodMilliSec(fastdds::rtps::TimeConv::Duration_t2MilliSecondsDouble(wqos.m_liveliness. - announcement_period)); + double wAnnouncementPeriodMilliSec(TimeConv::Duration_t2MilliSecondsDouble(qos.announcement_period)); - if (wqos.m_liveliness.kind == dds::AUTOMATIC_LIVELINESS_QOS ) + if (qos.kind == dds::AUTOMATIC_LIVELINESS_QOS ) { if (automatic_liveliness_assertion_ == nullptr) { @@ -656,7 +655,7 @@ bool WLP::add_local_writer( } automatic_writers_.push_back(base_writer); } - else if (wqos.m_liveliness.kind == dds::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS) + else if (qos.kind == dds::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS) { if (manual_liveliness_assertion_ == nullptr) { @@ -685,21 +684,21 @@ bool WLP::add_local_writer( if (!pub_liveliness_manager_->add_writer( writer->getGuid(), - wqos.m_liveliness.kind, - wqos.m_liveliness.lease_duration)) + qos.kind, + qos.lease_duration)) { EPROSIMA_LOG_ERROR(RTPS_LIVELINESS, "Could not add writer " << writer->getGuid() << " to liveliness manager"); } } - else if (wqos.m_liveliness.kind == dds::MANUAL_BY_TOPIC_LIVELINESS_QOS) + else if (qos.kind == dds::MANUAL_BY_TOPIC_LIVELINESS_QOS) { manual_by_topic_writers_.push_back(base_writer); if (!pub_liveliness_manager_->add_writer( writer->getGuid(), - wqos.m_liveliness.kind, - wqos.m_liveliness.lease_duration)) + qos.kind, + qos.lease_duration)) { EPROSIMA_LOG_ERROR(RTPS_LIVELINESS, "Could not add writer " << writer->getGuid() << " to liveliness manager"); diff --git a/src/cpp/rtps/builtin/liveliness/WLP.hpp b/src/cpp/rtps/builtin/liveliness/WLP.hpp index 1a28e51198c..22c6c3dce1c 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.hpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.hpp @@ -109,12 +109,12 @@ class WLP /** * Add a local writer to the liveliness protocol. * @param writer Pointer to the RTPSWriter. - * @param wqos Quality of service policies for the writer. + * @param qos Quality of service policies for the writer. * @return True if correct. */ bool add_local_writer( RTPSWriter* writer, - const fastdds::dds::WriterQos& wqos); + const fastdds::dds::LivelinessQosPolicy& qos); /** * Remove a local writer from the liveliness protocol. * @param writer Pointer to the RTPSWriter. diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index d822c2d4f58..5020f2642ce 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -77,10 +77,9 @@ uint32_t RTPSParticipant::getRTPSParticipantID() const bool RTPSParticipant::register_writer( RTPSWriter* writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos) + const PublicationBuiltinTopicData& pub_builtin_data) { - return mp_impl->register_writer(writer, pub_builtin_data, wqos); + return mp_impl->register_writer(writer, pub_builtin_data); } bool RTPSParticipant::register_reader( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 6798d825e37..304f79f1e6b 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1406,10 +1406,9 @@ void RTPSParticipantImpl::disableReader( bool RTPSParticipantImpl::register_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos) + const PublicationBuiltinTopicData& pub_builtin_data) { - return this->mp_builtinProtocols->add_writer(rtps_writer, pub_builtin_data, wqos); + return this->mp_builtinProtocols->add_writer(rtps_writer, pub_builtin_data); } bool RTPSParticipantImpl::register_reader( @@ -2878,9 +2877,9 @@ const fastdds::statistics::rtps::IStatusObserver* RTPSParticipantImpl::create_mo }, [&](RTPSWriter* w, const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos) -> bool + const fastdds::dds::WriterQos& /*wqos*/) -> bool { - return this->register_writer(w, pub_builtin_data, wqos); + return this->register_writer(w, pub_builtin_data); }, getEventResource() )); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 848c7bf68dd..80001553231 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -897,13 +897,11 @@ class RTPSParticipantImpl * Register a Writer in the BuiltinProtocols. * @param Writer Pointer to the RTPSWriter. * @param pub_builtin_data Contains the discovery information of the writer. - * @param wqos WriterQos. * @return True if correctly registered. */ bool register_writer( RTPSWriter* Writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos); + const PublicationBuiltinTopicData& pub_builtin_data); /** * Register a Reader in the BuiltinProtocols. diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index c1c7e58f0e1..845dfb7d690 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -819,8 +819,7 @@ TEST(RTPS, MultithreadedWriterCreation) pub_builtin_data.type_name = "string"; pub_builtin_data.topic_name = "test_topic"; /* Register writer in participant */ - eprosima::fastdds::dds::WriterQos writer_qos; - ASSERT_EQ(rtps_participant->register_writer(writer, pub_builtin_data, writer_qos), true); + ASSERT_EQ(rtps_participant->register_writer(writer, pub_builtin_data), true); { /* Wait for test completion request */ diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index f2c74236430..6ae65e9114f 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -178,7 +178,7 @@ class RTPSWithRegistrationWriter return; } - ASSERT_EQ(participant_->register_writer(writer_, pub_builtin_data_, writer_qos_), true); + ASSERT_EQ(participant_->register_writer(writer_, pub_builtin_data_), true); initialized_ = true; } diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index 5791386c72f..a304a4932d6 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -185,10 +185,9 @@ class FASTDDS_EXPORTED_API RTPSParticipant MOCK_CONST_METHOD0(typelookup_manager, fastdds::dds::builtin::TypeLookupManager* ()); - MOCK_METHOD3(register_writer, bool( + MOCK_METHOD2(register_writer, bool( RTPSWriter * Writer, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& wqos)); + const PublicationBuiltinTopicData& pub_builtin_data)); MOCK_METHOD2(update_writer, bool( RTPSWriter * Writer, diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index 217b87f6a86..e4b0e129d72 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -97,7 +97,7 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) pub_builtin_data.type_name = "string"; pub_builtin_data.topic_name = "topic"; part->register_reader(reader, sub_builtin_data); - part->register_writer(writer, pub_builtin_data, {}); + part->register_writer(writer, pub_builtin_data); // After registration, the writer should be matched auto writer_guid = writer->getGuid(); diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 40956858a14..d5784fc796a 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -358,9 +358,14 @@ class RTPSStatisticsTestsImpl using namespace fastdds; using namespace fastdds::rtps; + auto& watt = writer_->getAttributes(); PublicationBuiltinTopicData pub_builtin_data; pub_builtin_data.type_name = data_type; pub_builtin_data.topic_name = topic_name; + pub_builtin_data.durability.durabilityKind(watt.durabilityKind); + pub_builtin_data.reliability.kind = + RELIABLE == + watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; auto& ratt = writer_->getAttributes(); SubscriptionBuiltinTopicData sub_builtin_data; @@ -371,15 +376,7 @@ class RTPSStatisticsTestsImpl RELIABLE == ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - - dds::WriterQos Wqos; - auto& watt = writer_->getAttributes(); - Wqos.m_durability.durabilityKind(watt.durabilityKind); - Wqos.m_reliability.kind = - RELIABLE == - watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - - participant_->register_writer(writer_, pub_builtin_data, Wqos); + participant_->register_writer(writer_, pub_builtin_data); participant_->register_reader(reader_, sub_builtin_data); } From 53123118cbbe435e38ebe3eef50588f754ec13b7 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 09:25:26 +0200 Subject: [PATCH 19/37] Refs #21357. Refactor get_subscription_builtin_topic_data. Signed-off-by: Miguel Company --- include/fastdds/dds/subscriber/DataReader.hpp | 10 +- src/cpp/fastdds/subscriber/DataReader.cpp | 5 +- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 106 +++++++++--------- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 10 +- 4 files changed, 69 insertions(+), 62 deletions(-) diff --git a/include/fastdds/dds/subscriber/DataReader.hpp b/include/fastdds/dds/subscriber/DataReader.hpp index e22037201e5..b14d50ba7fe 100644 --- a/include/fastdds/dds/subscriber/DataReader.hpp +++ b/include/fastdds/dds/subscriber/DataReader.hpp @@ -1078,11 +1078,15 @@ class DataReader : public DomainEntity rtps::LocatorList& locators) const; /** - * @brief A method to retrieve the subscription data discovery information. + * Retrieve the subscription data discovery information. * - * @return The discovery information of the subscription. + * @param [out] subscription_data The subscription data discovery information. + * + * @return NOT_ENABLED if the reader has not been enabled. + * @return OK if the subscription data is returned. */ - FASTDDS_EXPORTED_API SubscriptionBuiltinTopicData get_subscription_builtin_topic_data() const; + FASTDDS_EXPORTED_API ReturnCode_t get_subscription_builtin_topic_data( + SubscriptionBuiltinTopicData& subscription_data) const; protected: diff --git a/src/cpp/fastdds/subscriber/DataReader.cpp b/src/cpp/fastdds/subscriber/DataReader.cpp index 9da2803eef1..9e93b84ee03 100644 --- a/src/cpp/fastdds/subscriber/DataReader.cpp +++ b/src/cpp/fastdds/subscriber/DataReader.cpp @@ -488,9 +488,10 @@ ReturnCode_t DataReader::get_listening_locators( return impl_->get_listening_locators(locators); } -SubscriptionBuiltinTopicData DataReader::get_subscription_builtin_topic_data() const +ReturnCode_t DataReader::get_subscription_builtin_topic_data( + SubscriptionBuiltinTopicData& subscription_data) const { - return impl_->get_subscription_builtin_topic_data(); + return impl_->get_subscription_builtin_topic_data(subscription_data); } } /* namespace dds */ diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index d6cb41c26f9..0611ecb1dbf 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -276,7 +276,10 @@ ReturnCode_t DataReaderImpl::enable() qos_.lifespan().duration.to_ns() * 1e-6); // Register the reader - auto builtin_topic_data = get_subscription_builtin_topic_data(); + SubscriptionBuiltinTopicData builtin_topic_data; + auto get_data_ret_code = get_subscription_builtin_topic_data(builtin_topic_data); + static_cast(get_data_ret_code); + assert(RETCODE_OK == get_data_ret_code); rtps::ContentFilterProperty* filter_property = nullptr; if (nullptr != content_topic && !content_topic->filter_property.filter_expression.empty()) @@ -2169,48 +2172,44 @@ void DataReaderImpl::try_notify_read_conditions() noexcept } } -SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data() const +ReturnCode_t DataReaderImpl::get_subscription_builtin_topic_data( + SubscriptionBuiltinTopicData& subscription_data) const { - SubscriptionBuiltinTopicData sub_builtin_data; + if (nullptr == reader_) + { + return RETCODE_NOT_ENABLED; + } // sanity checks - bool subscriber_is_valid = (nullptr != subscriber_); - bool topic_is_valid = (nullptr != topic_); - bool participant_is_valid = subscriber_is_valid ? (nullptr != subscriber_->get_participant()) : false; + assert(nullptr != subscriber_); + assert(nullptr != topic_); + assert(nullptr != subscriber_->get_participant()); - from_proxy_to_builtin(guid_.entityId, sub_builtin_data.key.value); + subscription_data = SubscriptionBuiltinTopicData{}; - if (participant_is_valid) - { - from_proxy_to_builtin(subscriber_->get_participant()->guid().guidPrefix, - sub_builtin_data.participant_key.value); - } + from_proxy_to_builtin(guid_.entityId, subscription_data.key.value); + from_proxy_to_builtin(subscriber_->get_participant()->guid().guidPrefix, + subscription_data.participant_key.value); - if (topic_is_valid) - { - sub_builtin_data.topic_name = topic_->get_impl()->get_rtps_topic_name(); - sub_builtin_data.type_name = topic_->get_type_name(); - } + subscription_data.topic_name = topic_->get_impl()->get_rtps_topic_name(); + subscription_data.type_name = topic_->get_type_name(); // DataReader qos - sub_builtin_data.durability = qos_.durability(); - sub_builtin_data.deadline = qos_.deadline(); - sub_builtin_data.latency_budget = qos_.latency_budget(); - sub_builtin_data.lifespan = qos_.lifespan(); - sub_builtin_data.liveliness = qos_.liveliness(); - sub_builtin_data.reliability = qos_.reliability(); - sub_builtin_data.ownership = qos_.ownership(); - sub_builtin_data.destination_order = qos_.destination_order(); - sub_builtin_data.user_data = qos_.user_data(); - sub_builtin_data.time_based_filter = qos_.time_based_filter(); + subscription_data.durability = qos_.durability(); + subscription_data.deadline = qos_.deadline(); + subscription_data.latency_budget = qos_.latency_budget(); + subscription_data.lifespan = qos_.lifespan(); + subscription_data.liveliness = qos_.liveliness(); + subscription_data.reliability = qos_.reliability(); + subscription_data.ownership = qos_.ownership(); + subscription_data.destination_order = qos_.destination_order(); + subscription_data.user_data = qos_.user_data(); + subscription_data.time_based_filter = qos_.time_based_filter(); // Subscriber qos - if (subscriber_is_valid) - { - sub_builtin_data.presentation = subscriber_->qos_.presentation(); - sub_builtin_data.partition = subscriber_->qos_.partition(); - sub_builtin_data.group_data = subscriber_->qos_.group_data(); - } + subscription_data.presentation = subscriber_->qos_.presentation(); + subscription_data.partition = subscriber_->qos_.partition(); + subscription_data.group_data = subscriber_->qos_.group_data(); // X-Types 1.3 using utils::to_type_propagation; @@ -2235,13 +2234,13 @@ SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data case TypePropagation::TYPEPROPAGATION_ENABLED: { // Use both complete and minimal type information - sub_builtin_data.type_information.type_information = type_info; + subscription_data.type_information.type_information = type_info; break; } case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: { // Use minimal type information only - sub_builtin_data.type_information.type_information.minimal() = type_info.minimal(); + subscription_data.type_information.type_information.minimal() = type_info.minimal(); break; } default: @@ -2250,50 +2249,47 @@ SubscriptionBuiltinTopicData DataReaderImpl::get_subscription_builtin_topic_data break; } - sub_builtin_data.type_information.assigned(true); - sub_builtin_data.type_consistency = qos_.type_consistency(); + subscription_data.type_information.assigned(true); + subscription_data.type_consistency = qos_.type_consistency(); } } - sub_builtin_data.representation = qos_.representation(); + subscription_data.representation = qos_.representation(); // eProsima Extensions - sub_builtin_data.disable_positive_acks = qos_.reliable_reader_qos().disable_positive_acks; - sub_builtin_data.data_sharing = qos_.data_sharing(); + subscription_data.disable_positive_acks = qos_.reliable_reader_qos().disable_positive_acks; + subscription_data.data_sharing = qos_.data_sharing(); - if (sub_builtin_data.data_sharing.kind() != OFF && - sub_builtin_data.data_sharing.domain_ids().empty()) + if (subscription_data.data_sharing.kind() != OFF && + subscription_data.data_sharing.domain_ids().empty()) { - sub_builtin_data.data_sharing.add_domain_id(utils::default_domain_id()); + subscription_data.data_sharing.add_domain_id(utils::default_domain_id()); } - sub_builtin_data.guid = guid(); - if (subscriber_is_valid) - { - sub_builtin_data.participant_guid = subscriber_->get_participant()->guid(); - } - qos_.endpoint().unicast_locator_list.copy_to(sub_builtin_data.remote_locators.unicast); - qos_.endpoint().multicast_locator_list.copy_to(sub_builtin_data.remote_locators.multicast); - sub_builtin_data.expects_inline_qos = qos_.expects_inline_qos(); + subscription_data.guid = guid(); + subscription_data.participant_guid = subscriber_->get_participant()->guid(); + qos_.endpoint().unicast_locator_list.copy_to(subscription_data.remote_locators.unicast); + qos_.endpoint().multicast_locator_list.copy_to(subscription_data.remote_locators.multicast); + subscription_data.expects_inline_qos = qos_.expects_inline_qos(); if (!is_data_sharing_compatible_) { - sub_builtin_data.data_sharing.off(); + subscription_data.data_sharing.off(); } const std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions"); if (endpoint_partitions) { std::istringstream partition_string(*endpoint_partitions); std::string partition_name; - sub_builtin_data.partition.clear(); + subscription_data.partition.clear(); while (std::getline(partition_string, partition_name, ';')) { - sub_builtin_data.partition.push_back(partition_name.c_str()); + subscription_data.partition.push_back(partition_name.c_str()); } } - return sub_builtin_data; + return RETCODE_OK; } } // namespace dds diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index e9f2fc9c1bf..c9e8075db22 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -375,9 +375,15 @@ class DataReaderImpl std::recursive_mutex& get_conditions_mutex() const noexcept; /** - * @brief A method to retrieve the subscription data discovery information. + * Retrieve the subscription data discovery information. + * + * @param [out] subscription_data The subscription data discovery information. + * + * @return NOT_ENABLED if the reader has not been enabled. + * @return OK if the subscription data is returned. */ - SubscriptionBuiltinTopicData get_subscription_builtin_topic_data() const; + ReturnCode_t get_subscription_builtin_topic_data( + SubscriptionBuiltinTopicData& subscription_data) const; protected: From 5a40246776ebe7414c2e9e3e5a9ba8ddb0d23f5c Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 09:38:20 +0200 Subject: [PATCH 20/37] Refs #21357. Refactor get_publication_builtin_topic_data. Signed-off-by: Miguel Company --- include/fastdds/dds/publisher/DataWriter.hpp | 10 +- src/cpp/fastdds/publisher/DataWriter.cpp | 5 +- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 129 +++++++++--------- src/cpp/fastdds/publisher/DataWriterImpl.hpp | 10 +- .../mock/fastdds/publisher/DataWriterImpl.hpp | 6 +- 5 files changed, 85 insertions(+), 75 deletions(-) diff --git a/include/fastdds/dds/publisher/DataWriter.hpp b/include/fastdds/dds/publisher/DataWriter.hpp index dead3039ca0..a81dc314ac5 100644 --- a/include/fastdds/dds/publisher/DataWriter.hpp +++ b/include/fastdds/dds/publisher/DataWriter.hpp @@ -586,9 +586,15 @@ class DataWriter : public DomainEntity const fastdds::dds::Duration_t& max_wait); /** - * @brief A method to retrieve the publication data discovery information of this writer. + * Retrieve the publication data discovery information. + * + * @param [out] publication_data The publication data discovery information. + * + * @return NOT_ENABLED if the writer has not been enabled. + * @return OK if the publication data is returned. */ - FASTDDS_EXPORTED_API PublicationBuiltinTopicData get_publication_builtin_topic_data() const; + FASTDDS_EXPORTED_API ReturnCode_t get_publication_builtin_topic_data( + PublicationBuiltinTopicData& publication_data) const; protected: diff --git a/src/cpp/fastdds/publisher/DataWriter.cpp b/src/cpp/fastdds/publisher/DataWriter.cpp index 82480c89789..7ca2dbda822 100644 --- a/src/cpp/fastdds/publisher/DataWriter.cpp +++ b/src/cpp/fastdds/publisher/DataWriter.cpp @@ -308,9 +308,10 @@ ReturnCode_t DataWriter::wait_for_acknowledgments( return impl_->wait_for_acknowledgments(instance, handle, max_wait); } -PublicationBuiltinTopicData DataWriter::get_publication_builtin_topic_data() const +ReturnCode_t DataWriter::get_publication_builtin_topic_data( + PublicationBuiltinTopicData& publication_data) const { - return impl_->get_publication_builtin_topic_data(); + return impl_->get_publication_builtin_topic_data(publication_data); } } // namespace dds diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index fe80c75f38c..d7efe2758bc 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -457,7 +457,10 @@ ReturnCode_t DataWriterImpl::enable() } // REGISTER THE WRITER - auto builtin_topic_data = get_publication_builtin_topic_data(); + PublicationBuiltinTopicData builtin_topic_data; + auto get_data_ret_code = get_publication_builtin_topic_data(builtin_topic_data); + static_cast(get_data_ret_code); + assert(RETCODE_OK == get_data_ret_code); publisher_->rtps_participant()->register_writer(writer_, builtin_topic_data); return RETCODE_OK; @@ -1664,50 +1667,48 @@ ReturnCode_t DataWriterImpl::assert_liveliness() return RETCODE_OK; } -PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() const +ReturnCode_t DataWriterImpl::get_publication_builtin_topic_data( + PublicationBuiltinTopicData& publication_data) const { - PublicationBuiltinTopicData pub_builtin_data; + if (nullptr == writer_) + { + return RETCODE_NOT_ENABLED; + } // sanity checks - bool writer_is_valid = (nullptr != writer_); - bool publisher_is_valid = (nullptr != publisher_); - bool topic_is_valid = (nullptr != topic_); - bool participant_is_valid = publisher_is_valid ? (nullptr != publisher_->get_participant()) : false; - bool rtps_participant_impl_is_valid = writer_is_valid ? (nullptr != writer_->get_participant_impl()) : false; + assert(nullptr != publisher_); + assert(nullptr != topic_); + assert(nullptr != publisher_->get_participant()); + assert(nullptr != writer_->get_participant_impl()); - from_proxy_to_builtin(guid_.entityId, pub_builtin_data.key.value); - if (participant_is_valid) - { - from_proxy_to_builtin(publisher_->get_participant()->guid().guidPrefix, pub_builtin_data.participant_key.value); - } + publication_data = PublicationBuiltinTopicData{}; - if (topic_is_valid) - { - pub_builtin_data.topic_name = topic_->get_name(); - pub_builtin_data.type_name = topic_->get_type_name(); - pub_builtin_data.topic_data = topic_->get_qos().topic_data(); - } + from_proxy_to_builtin(guid_.entityId, publication_data.key.value); + from_proxy_to_builtin(publisher_->get_participant()->guid().guidPrefix, publication_data.participant_key.value); + + publication_data.topic_name = topic_->get_name(); + publication_data.type_name = topic_->get_type_name(); + publication_data.topic_data = topic_->get_qos().topic_data(); // DataWriter qos - pub_builtin_data.durability = qos_.durability(); - pub_builtin_data.durability_service = qos_.durability_service(); - pub_builtin_data.deadline = qos_.deadline(); - pub_builtin_data.latency_budget = qos_.latency_budget(); - pub_builtin_data.liveliness = qos_.liveliness(); - pub_builtin_data.reliability = qos_.reliability(); - pub_builtin_data.lifespan = qos_.lifespan(); - pub_builtin_data.user_data = qos_.user_data(); - pub_builtin_data.ownership = qos_.ownership(); - pub_builtin_data.ownership_strength = qos_.ownership_strength(); - pub_builtin_data.destination_order = qos_.destination_order(); + publication_data.durability = qos_.durability(); + publication_data.durability_service = qos_.durability_service(); + publication_data.deadline = qos_.deadline(); + publication_data.latency_budget = qos_.latency_budget(); + publication_data.liveliness = qos_.liveliness(); + publication_data.reliability = qos_.reliability(); + publication_data.lifespan = qos_.lifespan(); + publication_data.user_data = qos_.user_data(); + publication_data.ownership = qos_.ownership(); + publication_data.ownership_strength = qos_.ownership_strength(); + publication_data.destination_order = qos_.destination_order(); // Publisher qos - if (publisher_is_valid) - { - pub_builtin_data.presentation = publisher_->qos_.presentation(); - pub_builtin_data.partition = publisher_->qos_.partition(); - pub_builtin_data.group_data = publisher_->qos_.group_data(); - } + publication_data.presentation = publisher_->qos_.presentation(); + publication_data.partition = publisher_->qos_.partition(); + publication_data.group_data = publisher_->qos_.group_data(); + + // XTypes 1.3 using utils::to_type_propagation; using utils::TypePropagation; @@ -1731,13 +1732,13 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() case TypePropagation::TYPEPROPAGATION_ENABLED: { // Use both complete and minimal type information - pub_builtin_data.type_information.type_information = type_info; + publication_data.type_information.type_information = type_info; break; } case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: { // Use minimal type information only - pub_builtin_data.type_information.type_information.minimal() = type_info.minimal(); + publication_data.type_information.type_information.minimal() = type_info.minimal(); break; } default: @@ -1746,45 +1747,38 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() break; } - pub_builtin_data.type_information.assigned(true); + publication_data.type_information.assigned(true); } } - pub_builtin_data.representation = qos_.representation(); + publication_data.representation = qos_.representation(); // eProsima extensions - pub_builtin_data.disable_positive_acks = qos_.reliable_writer_qos().disable_positive_acks; - pub_builtin_data.data_sharing = qos_.data_sharing(); + publication_data.disable_positive_acks = qos_.reliable_writer_qos().disable_positive_acks; + publication_data.data_sharing = qos_.data_sharing(); - if (pub_builtin_data.data_sharing.kind() != OFF && - pub_builtin_data.data_sharing.domain_ids().empty()) + if (publication_data.data_sharing.kind() != OFF && + publication_data.data_sharing.domain_ids().empty()) { - pub_builtin_data.data_sharing.add_domain_id(utils::default_domain_id()); + publication_data.data_sharing.add_domain_id(utils::default_domain_id()); } - pub_builtin_data.guid = guid(); - if (publisher_is_valid) - { - pub_builtin_data.participant_guid = publisher_->get_participant()->guid(); - } + publication_data.guid = guid(); + publication_data.participant_guid = publisher_->get_participant()->guid(); - if (rtps_participant_impl_is_valid) - { - pub_builtin_data.persistence_guid.guidPrefix = writer_->get_participant_impl()->get_persistence_guid_prefix(); - } - pub_builtin_data.persistence_guid.entityId = c_EntityId_RTPSParticipant; - qos_.endpoint().unicast_locator_list.copy_to(pub_builtin_data.remote_locators.unicast); - qos_.endpoint().multicast_locator_list.copy_to(pub_builtin_data.remote_locators.multicast); - pub_builtin_data.max_serialized_size = type_->max_serialized_type_size; - if (rtps_participant_impl_is_valid) - { - pub_builtin_data.loopback_transformation = - writer_->get_participant_impl()->network_factory().network_configuration(); - } + + publication_data.persistence_guid.guidPrefix = writer_->get_participant_impl()->get_persistence_guid_prefix(); + publication_data.persistence_guid.entityId = c_EntityId_RTPSParticipant; + + qos_.endpoint().unicast_locator_list.copy_to(publication_data.remote_locators.unicast); + qos_.endpoint().multicast_locator_list.copy_to(publication_data.remote_locators.multicast); + publication_data.max_serialized_size = type_->max_serialized_type_size; + publication_data.loopback_transformation = + writer_->get_participant_impl()->network_factory().network_configuration(); if (!is_data_sharing_compatible_) { - pub_builtin_data.data_sharing.off(); + publication_data.data_sharing.off(); } const std::string* endpoint_partitions = PropertyPolicyHelper::find_property(qos_.properties(), "partitions"); @@ -1792,14 +1786,15 @@ PublicationBuiltinTopicData DataWriterImpl::get_publication_builtin_topic_data() { std::istringstream partition_string(*endpoint_partitions); std::string partition_name; - pub_builtin_data.partition.clear(); + publication_data.partition.clear(); while (std::getline(partition_string, partition_name, ';')) { - pub_builtin_data.partition.push_back(partition_name.c_str()); + publication_data.partition.push_back(partition_name.c_str()); } } - return pub_builtin_data; + + return RETCODE_OK; } OfferedIncompatibleQosStatus& DataWriterImpl::update_offered_incompatible_qos( diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.hpp b/src/cpp/fastdds/publisher/DataWriterImpl.hpp index be46dadf1c0..7ddd8927e24 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.hpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.hpp @@ -382,9 +382,15 @@ class DataWriterImpl : protected rtps::IReaderDataFilter const char* filter_class_name); /** - * @brief A method to retrieve the publication data discovery information. + * Retrieve the publication data discovery information. + * + * @param [out] publication_data The publication data discovery information. + * + * @return NOT_ENABLED if the writer has not been enabled. + * @return OK if the publication data is returned. */ - PublicationBuiltinTopicData get_publication_builtin_topic_data() const; + ReturnCode_t get_publication_builtin_topic_data( + PublicationBuiltinTopicData& publication_data) const; protected: diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp index cd286ced54b..72ef193bbf1 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests/mock/fastdds/publisher/DataWriterImpl.hpp @@ -395,9 +395,11 @@ class DataWriterImpl : protected rtps::IReaderDataFilter } } - inline PublicationBuiltinTopicData get_publication_builtin_topic_data() const + inline ReturnCode_t get_publication_builtin_topic_data( + PublicationBuiltinTopicData& publication_data) const { - return PublicationBuiltinTopicData(); + publication_data = PublicationBuiltinTopicData{}; + return RETCODE_OK; } static ReturnCode_t check_qos( From d10d4cf916c8b22bd9c305f72c708fb5409a16a1 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 09:53:09 +0200 Subject: [PATCH 21/37] Refs #21357. Fix calculation of persistence_guid. Signed-off-by: Miguel Company --- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index d7efe2758bc..1b4dfd0d10d 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1766,9 +1766,12 @@ ReturnCode_t DataWriterImpl::get_publication_builtin_topic_data( publication_data.guid = guid(); publication_data.participant_guid = publisher_->get_participant()->guid(); - - publication_data.persistence_guid.guidPrefix = writer_->get_participant_impl()->get_persistence_guid_prefix(); - publication_data.persistence_guid.entityId = c_EntityId_RTPSParticipant; + const std::string* pers_guid = PropertyPolicyHelper::find_property(qos_.properties(), "dds.persistence.guid"); + if (pers_guid) + { + // Load persistence_guid from property + std::istringstream(pers_guid->c_str()) >> publication_data.persistence_guid; + } qos_.endpoint().unicast_locator_list.copy_to(publication_data.remote_locators.unicast); qos_.endpoint().multicast_locator_list.copy_to(publication_data.remote_locators.multicast); From 3498efd4dd181cf5b4f7565a5cf1151ae86e3d5d Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 10:32:47 +0200 Subject: [PATCH 22/37] Refs #21357. Builtin key conversion method not inline. Signed-off-by: Miguel Company --- .../rtps/builtin/data/ProxyDataConverters.cpp | 60 +++++++++++++++++++ src/cpp/utils/BuiltinTopicKeyConversions.hpp | 60 +++---------------- test/unittest/dds/status/CMakeLists.txt | 4 ++ 3 files changed, 72 insertions(+), 52 deletions(-) diff --git a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp index e21c492135b..a7f4e2640b4 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp +++ b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp @@ -38,6 +38,66 @@ namespace eprosima { namespace fastdds { namespace rtps { +void from_proxy_to_builtin( + const EntityId_t& entity_id, + BuiltinTopicKeyValue& builtin_key_value) +{ + builtin_key_value[0] = 0; + builtin_key_value[1] = 0; + builtin_key_value[2] = static_cast(entity_id.value[0]) << 24 + | static_cast(entity_id.value[1]) << 16 + | static_cast(entity_id.value[2]) << 8 + | static_cast(entity_id.value[3]); +} + +void from_proxy_to_builtin( + const GuidPrefix_t& guid_prefix, + BuiltinTopicKeyValue& dds_key) +{ + dds_key[0] = static_cast(guid_prefix.value[0]) << 24 + | static_cast(guid_prefix.value[1]) << 16 + | static_cast(guid_prefix.value[2]) << 8 + | static_cast(guid_prefix.value[3]); + dds_key[1] = static_cast(guid_prefix.value[4]) << 24 + | static_cast(guid_prefix.value[5]) << 16 + | static_cast(guid_prefix.value[6]) << 8 + | static_cast(guid_prefix.value[7]); + dds_key[2] = static_cast(guid_prefix.value[8]) << 24 + | static_cast(guid_prefix.value[9]) << 16 + | static_cast(guid_prefix.value[10]) << 8 + | static_cast(guid_prefix.value[11]); +} + +void from_builtin_to_proxy( + const BuiltinTopicKeyValue& dds_key, + EntityId_t& entity_id) +{ + entity_id.value[0] = static_cast((dds_key[2] >> 24) & 0xFF); + entity_id.value[1] = static_cast((dds_key[2] >> 16) & 0xFF); + entity_id.value[2] = static_cast((dds_key[2] >> 8) & 0xFF); + entity_id.value[3] = static_cast(dds_key[2] & 0xFF); +} + +void from_builtin_to_proxy( + const BuiltinTopicKeyValue& dds_key, + GuidPrefix_t& guid_prefix) +{ + guid_prefix.value[0] = static_cast((dds_key[0] >> 24) & 0xFF); + guid_prefix.value[1] = static_cast((dds_key[0] >> 16) & 0xFF); + guid_prefix.value[2] = static_cast((dds_key[0] >> 8) & 0xFF); + guid_prefix.value[3] = static_cast(dds_key[0] & 0xFF); + + guid_prefix.value[4] = static_cast((dds_key[1] >> 24) & 0xFF); + guid_prefix.value[5] = static_cast((dds_key[1] >> 16) & 0xFF); + guid_prefix.value[6] = static_cast((dds_key[1] >> 8) & 0xFF); + guid_prefix.value[7] = static_cast(dds_key[1] & 0xFF); + + guid_prefix.value[8] = static_cast((dds_key[2] >> 24) & 0xFF); + guid_prefix.value[9] = static_cast((dds_key[2] >> 16) & 0xFF); + guid_prefix.value[10] = static_cast((dds_key[2] >> 8) & 0xFF); + guid_prefix.value[11] = static_cast(dds_key[2] & 0xFF); +} + void from_proxy_to_builtin( const ParticipantProxyData& proxy_data, ParticipantBuiltinTopicData& builtin_data) diff --git a/src/cpp/utils/BuiltinTopicKeyConversions.hpp b/src/cpp/utils/BuiltinTopicKeyConversions.hpp index 58684949852..9560c41789b 100644 --- a/src/cpp/utils/BuiltinTopicKeyConversions.hpp +++ b/src/cpp/utils/BuiltinTopicKeyConversions.hpp @@ -26,65 +26,21 @@ namespace rtps { typedef uint32_t BuiltinTopicKeyValue[3]; -inline void from_proxy_to_builtin( +void from_proxy_to_builtin( const EntityId_t& entity_id, - BuiltinTopicKeyValue& builtin_key_value) -{ - builtin_key_value[0] = 0; - builtin_key_value[1] = 0; - builtin_key_value[2] = static_cast(entity_id.value[0]) << 24 - | static_cast(entity_id.value[1]) << 16 - | static_cast(entity_id.value[2]) << 8 - | static_cast(entity_id.value[3]); -} + BuiltinTopicKeyValue& builtin_key_value); -inline void from_proxy_to_builtin( +void from_proxy_to_builtin( const GuidPrefix_t& guid_prefix, - BuiltinTopicKeyValue& dds_key) -{ - dds_key[0] = static_cast(guid_prefix.value[0]) << 24 - | static_cast(guid_prefix.value[1]) << 16 - | static_cast(guid_prefix.value[2]) << 8 - | static_cast(guid_prefix.value[3]); - dds_key[1] = static_cast(guid_prefix.value[4]) << 24 - | static_cast(guid_prefix.value[5]) << 16 - | static_cast(guid_prefix.value[6]) << 8 - | static_cast(guid_prefix.value[7]); - dds_key[2] = static_cast(guid_prefix.value[8]) << 24 - | static_cast(guid_prefix.value[9]) << 16 - | static_cast(guid_prefix.value[10]) << 8 - | static_cast(guid_prefix.value[11]); -} + BuiltinTopicKeyValue& dds_key); -inline void from_builtin_to_proxy( +void from_builtin_to_proxy( const BuiltinTopicKeyValue& dds_key, - EntityId_t& entity_id) -{ - entity_id.value[0] = static_cast((dds_key[2] >> 24) & 0xFF); - entity_id.value[1] = static_cast((dds_key[2] >> 16) & 0xFF); - entity_id.value[2] = static_cast((dds_key[2] >> 8) & 0xFF); - entity_id.value[3] = static_cast(dds_key[2] & 0xFF); -} + EntityId_t& entity_id); -inline void from_builtin_to_proxy( +void from_builtin_to_proxy( const BuiltinTopicKeyValue& dds_key, - GuidPrefix_t& guid_prefix) -{ - guid_prefix.value[0] = static_cast((dds_key[0] >> 24) & 0xFF); - guid_prefix.value[1] = static_cast((dds_key[0] >> 16) & 0xFF); - guid_prefix.value[2] = static_cast((dds_key[0] >> 8) & 0xFF); - guid_prefix.value[3] = static_cast(dds_key[0] & 0xFF); - - guid_prefix.value[4] = static_cast((dds_key[1] >> 24) & 0xFF); - guid_prefix.value[5] = static_cast((dds_key[1] >> 16) & 0xFF); - guid_prefix.value[6] = static_cast((dds_key[1] >> 8) & 0xFF); - guid_prefix.value[7] = static_cast(dds_key[1] & 0xFF); - - guid_prefix.value[8] = static_cast((dds_key[2] >> 24) & 0xFF); - guid_prefix.value[9] = static_cast((dds_key[2] >> 16) & 0xFF); - guid_prefix.value[10] = static_cast((dds_key[2] >> 8) & 0xFF); - guid_prefix.value[11] = static_cast(dds_key[2] & 0xFF); -} + GuidPrefix_t& guid_prefix); } // namespace rtps } // namespace fastdds diff --git a/test/unittest/dds/status/CMakeLists.txt b/test/unittest/dds/status/CMakeLists.txt index 5fd0ed83ad6..2613d36762a 100644 --- a/test/unittest/dds/status/CMakeLists.txt +++ b/test/unittest/dds/status/CMakeLists.txt @@ -58,6 +58,10 @@ set(LISTENERTESTS_SOURCE ListenerTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/TypePropagation.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ReaderProxyData.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/WriterProxyData.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/GuidPrefix_t.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/SerializedPayload.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Time_t.cpp From 975f77c73c14c8fb091ce9bdc8c4aba175fe5462 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 10:33:31 +0200 Subject: [PATCH 23/37] Refs #21357. Fix doxygen on DataWriterHistory. Signed-off-by: Miguel Company --- src/cpp/fastdds/publisher/DataWriterHistory.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterHistory.hpp b/src/cpp/fastdds/publisher/DataWriterHistory.hpp index 489e0f41bb7..f941581ed1f 100644 --- a/src/cpp/fastdds/publisher/DataWriterHistory.hpp +++ b/src/cpp/fastdds/publisher/DataWriterHistory.hpp @@ -55,10 +55,15 @@ class DataWriterHistory : public rtps::WriterHistory /** * Constructor of the DataWriterHistory. - * @param pub_builtin_data Information on the publication. - * @param payloadMax Maximum payload size. - * @param mempolicy Set whether the payloads can dynamically resized or not. - * @param unack_sample_remove_functor Functor to call DDS listener callback on_unacknowledged_sample_removed + * + * @param payload_pool Pool to use for allocation of payloads. + * @param change_pool Pool to use for allocation of changes. + * @param history_qos HistoryQosPolicy of the DataWriter creating this history. + * @param resource_limits_qos ResourceLimitsQosPolicy of the DataWriter creating this history. + * @param topic_kind TopicKind of the DataWriter creating this history. + * @param payloadMax Maximum payload size. + * @param mempolicy Set whether the payloads can dynamically resized or not. + * @param unack_sample_remove_functor Functor to call DDS listener callback on_unacknowledged_sample_removed */ DataWriterHistory( const std::shared_ptr& payload_pool, From 52bc3eb677e406894f820b84d6ecdbe99f34f398 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 10:52:56 +0200 Subject: [PATCH 24/37] Refs #21357. Refactor MonitorService. Signed-off-by: Miguel Company --- src/cpp/rtps/participant/RTPSParticipantImpl.cpp | 3 +-- .../rtps/monitor-service/MonitorService.cpp | 11 ++++------- .../rtps/monitor-service/MonitorService.hpp | 3 +-- test/unittest/statistics/rtps/MonitorServiceTests.cpp | 3 +-- .../rtps/monitor-service/MonitorService.hpp | 3 +-- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 304f79f1e6b..620730522f6 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -2876,8 +2876,7 @@ const fastdds::statistics::rtps::IStatusObserver* RTPSParticipantImpl::create_mo return this->createWriter(WriterOut, param, hist, listen, entityId, isBuiltin); }, [&](RTPSWriter* w, - const PublicationBuiltinTopicData& pub_builtin_data, - const fastdds::dds::WriterQos& /*wqos*/) -> bool + const PublicationBuiltinTopicData& pub_builtin_data) -> bool { return this->register_writer(w, pub_builtin_data); }, diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 17299ff7114..72f9fc95a05 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -482,17 +482,14 @@ bool MonitorService::create_endpoint() { status_writer_ = dynamic_cast(tmp_writer); - //! Register the writer in the participant - fastdds::dds::WriterQos wqos; - - wqos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; - wqos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; - + // Register the writer in the participant PublicationBuiltinTopicData pub_builtin_data; + pub_builtin_data.reliability.kind = dds::RELIABLE_RELIABILITY_QOS; + pub_builtin_data.durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; pub_builtin_data.topic_name = MONITOR_SERVICE_TOPIC; pub_builtin_data.type_name = type_.get_name(); - endpoint_registrator_(status_writer_, pub_builtin_data, wqos); + endpoint_registrator_(status_writer_, pub_builtin_data); } else { diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp index 02e19feb004..574aecab706 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp @@ -82,8 +82,7 @@ class MonitorService using endpoint_registrator_t = std::function; + const eprosima::fastdds::rtps::PublicationBuiltinTopicData&)>; MonitorService( const fastdds::rtps::GUID_t& guid, diff --git a/test/unittest/statistics/rtps/MonitorServiceTests.cpp b/test/unittest/statistics/rtps/MonitorServiceTests.cpp index b6ac7b8c386..fe33788347b 100644 --- a/test/unittest/statistics/rtps/MonitorServiceTests.cpp +++ b/test/unittest/statistics/rtps/MonitorServiceTests.cpp @@ -78,8 +78,7 @@ class MonitorServiceTests : public ::testing::Test }, [&]( fastdds::rtps::RTPSWriter*, - const ::eprosima::fastdds::rtps::PublicationBuiltinTopicData&, - const fastdds::dds::WriterQos&)->bool + const ::eprosima::fastdds::rtps::PublicationBuiltinTopicData&)->bool { return true; }, diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index 28e5d6e64cc..5191c4bd664 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -69,8 +69,7 @@ class MonitorService using endpoint_registrator_t = std::function; + const eprosima::fastdds::rtps::PublicationBuiltinTopicData&)>; MonitorService( const fastdds::rtps::GUID_t& guid, From 9dad7e061046cbc62b7f666c11709fee8a4ade6e Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 11:04:54 +0200 Subject: [PATCH 25/37] Refs #21357. Uncrustify. Signed-off-by: Miguel Company --- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 2 +- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 10 +++++----- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 1b4dfd0d10d..14e1794f70a 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1758,7 +1758,7 @@ ReturnCode_t DataWriterImpl::get_publication_builtin_topic_data( publication_data.data_sharing = qos_.data_sharing(); if (publication_data.data_sharing.kind() != OFF && - publication_data.data_sharing.domain_ids().empty()) + publication_data.data_sharing.domain_ids().empty()) { publication_data.data_sharing.add_domain_id(utils::default_domain_id()); } diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index 0611ecb1dbf..ad41da409ac 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -2218,16 +2218,16 @@ ReturnCode_t DataReaderImpl::get_subscription_builtin_topic_data( auto properties = subscriber_->get_participant()->get_qos().properties(); auto type_propagation = to_type_propagation(properties); bool should_assign_type_information = - (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || - (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); + (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || + (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) { xtypes::TypeInformation type_info; if (RETCODE_OK == - fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type_->type_identifiers(), type_info)) + fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( + type_->type_identifiers(), type_info)) { switch (type_propagation) { @@ -2261,7 +2261,7 @@ ReturnCode_t DataReaderImpl::get_subscription_builtin_topic_data( subscription_data.data_sharing = qos_.data_sharing(); if (subscription_data.data_sharing.kind() != OFF && - subscription_data.data_sharing.domain_ids().empty()) + subscription_data.data_sharing.domain_ids().empty()) { subscription_data.data_sharing.add_domain_id(utils::default_domain_id()); } diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index c9e8075db22..9b5856c4058 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -383,7 +383,7 @@ class DataReaderImpl * @return OK if the subscription data is returned. */ ReturnCode_t get_subscription_builtin_topic_data( - SubscriptionBuiltinTopicData& subscription_data) const; + SubscriptionBuiltinTopicData& subscription_data) const; protected: From 8f7713c2abf64a1babcd91e1d9fb3a7567e14181 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 13:58:33 +0200 Subject: [PATCH 26/37] Refs #21357. Fix default initialization of builtin data structures. Signed-off-by: Miguel Company --- .../rtps/builtin/data/PublicationBuiltinTopicData.hpp | 9 +++++++-- .../rtps/builtin/data/SubscriptionBuiltinTopicData.hpp | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/fastdds/rtps/builtin/data/PublicationBuiltinTopicData.hpp b/include/fastdds/rtps/builtin/data/PublicationBuiltinTopicData.hpp index 5fe3f9a1616..0e75bbbe265 100644 --- a/include/fastdds/rtps/builtin/data/PublicationBuiltinTopicData.hpp +++ b/include/fastdds/rtps/builtin/data/PublicationBuiltinTopicData.hpp @@ -37,11 +37,16 @@ namespace rtps { /// Structure PublicationBuiltinTopicData, contains the information on a discovered publication. struct PublicationBuiltinTopicData { + PublicationBuiltinTopicData() + { + reliability.kind = dds::RELIABLE_RELIABILITY_QOS; + } + /// Builtin topic Key - BuiltinTopicKey_t key; + BuiltinTopicKey_t key{{0, 0, 0}}; /// Builtin participant topic Key - BuiltinTopicKey_t participant_key; + BuiltinTopicKey_t participant_key{{0, 0, 0}}; /// Topic name fastcdr::string_255 topic_name; diff --git a/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp b/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp index 136242a4dd2..9b9d19e6add 100644 --- a/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp +++ b/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp @@ -36,10 +36,10 @@ namespace rtps { struct SubscriptionBuiltinTopicData { /// Builtin topic Key - BuiltinTopicKey_t key; + BuiltinTopicKey_t key{{0, 0, 0}}; /// Builtin participant topic Key - BuiltinTopicKey_t participant_key; + BuiltinTopicKey_t participant_key{{0,0,0}}; /// Topic name fastcdr::string_255 topic_name; From ccb0c0b66134acc453087a0f0f9730127e9bbcc7 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 13:00:41 +0200 Subject: [PATCH 27/37] Refs #21357. Fix blackbox tests. Signed-off-by: Miguel Company --- test/blackbox/common/RTPSWithRegistrationReader.hpp | 4 ++++ test/blackbox/common/RTPSWithRegistrationWriter.hpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index f552c4929b4..c89f4709d3e 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -448,6 +448,7 @@ class RTPSWithRegistrationReader { reader_qos_.m_reliability.kind = eprosima::fastdds::dds::BEST_EFFORT_RELIABILITY_QOS; } + sub_builtin_data_.reliability = reader_qos_.m_reliability; return *this; } @@ -457,6 +458,7 @@ class RTPSWithRegistrationReader { reader_attr_.endpoint.durabilityKind = kind; reader_qos_.m_durability.durabilityKind(kind); + sub_builtin_data_.durability = reader_qos_.m_durability; return *this; } @@ -518,6 +520,7 @@ class RTPSWithRegistrationReader const std::vector& user_data) { reader_qos_.m_userData = user_data; + sub_builtin_data_.user_data = reader_qos_.m_userData; return *this; } @@ -532,6 +535,7 @@ class RTPSWithRegistrationReader std::vector& partitions) { reader_qos_.m_partition.setNames(partitions); + sub_builtin_data_.partition = reader_qos_.m_partition; return *this; } diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index 6ae65e9114f..a7c1c73985b 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -130,6 +130,9 @@ class RTPSWithRegistrationWriter t << topic_name << "_" << asio::ip::host_name() << "_" << GET_PID(); pub_builtin_data_.topic_name = t.str(); + // The tests are assuming a default durability of TRANSIENT_LOCAL, which is not the default mandated by the DDS standard. + pub_builtin_data_.durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + // By default, heartbeat period and nack response delay are 100 milliseconds. writer_attr_.times.heartbeat_period.seconds = 0; writer_attr_.times.heartbeat_period.nanosec = 100000000; @@ -393,6 +396,7 @@ class RTPSWithRegistrationWriter { writer_qos_.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; } + pub_builtin_data_.reliability = writer_qos_.m_reliability; return *this; } @@ -402,6 +406,7 @@ class RTPSWithRegistrationWriter { writer_attr_.endpoint.durabilityKind = kind; writer_qos_.m_durability.durabilityKind(kind); + pub_builtin_data_.durability = writer_qos_.m_durability; return *this; } @@ -517,6 +522,7 @@ class RTPSWithRegistrationWriter const std::vector& user_data) { writer_qos_.m_userData = user_data; + pub_builtin_data_.user_data = writer_qos_.m_userData; return *this; } @@ -531,6 +537,7 @@ class RTPSWithRegistrationWriter std::vector& partitions) { writer_qos_.m_partition.setNames(partitions); + pub_builtin_data_.partition = writer_qos_.m_partition; return *this; } From 947cca42c74f386bdf6a71d5a1cf3a8c7d1ea05f Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 26 Jul 2024 14:18:44 +0200 Subject: [PATCH 28/37] Refs #21357. Uncrustify. Signed-off-by: Miguel Company --- .../fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp b/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp index 9b9d19e6add..4227009b395 100644 --- a/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp +++ b/include/fastdds/rtps/builtin/data/SubscriptionBuiltinTopicData.hpp @@ -39,7 +39,7 @@ struct SubscriptionBuiltinTopicData BuiltinTopicKey_t key{{0, 0, 0}}; /// Builtin participant topic Key - BuiltinTopicKey_t participant_key{{0,0,0}}; + BuiltinTopicKey_t participant_key{{0, 0, 0}}; /// Topic name fastcdr::string_255 topic_name; From 8d1997bf2e80147c720f235bfb6fd3eeda0a54cd Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Sun, 28 Jul 2024 13:05:39 +0200 Subject: [PATCH 29/37] Refs #21357. Improve `from_builtin_to_proxy`. Signed-off-by: Miguel Company --- .../rtps/builtin/data/ProxyDataConverters.cpp | 87 +++++++++++-------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp index a7f4e2640b4..0c91e9c1cf5 100644 --- a/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp +++ b/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -203,78 +205,87 @@ void from_builtin_to_proxy( const PublicationBuiltinTopicData& builtin_data, WriterProxyData& proxy_data) { + fastdds::dds::WriterQos qos{}; + from_builtin_to_proxy(builtin_data.participant_key.value, proxy_data.guid().guidPrefix); from_builtin_to_proxy(builtin_data.key.value, proxy_data.guid().entityId); proxy_data.topicName(builtin_data.topic_name); proxy_data.typeName(builtin_data.type_name); - proxy_data.m_qos.m_durability = builtin_data.durability; - proxy_data.m_qos.m_durabilityService = builtin_data.durability_service; - proxy_data.m_qos.m_deadline = builtin_data.deadline; - proxy_data.m_qos.m_latencyBudget = builtin_data.latency_budget; - proxy_data.m_qos.m_liveliness = builtin_data.liveliness; - proxy_data.m_qos.m_reliability = builtin_data.reliability; - proxy_data.m_qos.m_lifespan = builtin_data.lifespan; - proxy_data.m_qos.m_userData = builtin_data.user_data; - proxy_data.m_qos.m_ownership = builtin_data.ownership; - proxy_data.m_qos.m_ownershipStrength = builtin_data.ownership_strength; - proxy_data.m_qos.m_destinationOrder = builtin_data.destination_order; - - proxy_data.m_qos.m_presentation = builtin_data.presentation; - proxy_data.m_qos.m_partition = builtin_data.partition; - proxy_data.m_qos.m_topicData = builtin_data.topic_data; - proxy_data.m_qos.m_groupData = builtin_data.group_data; + + qos.m_durability = builtin_data.durability; + qos.m_durabilityService = builtin_data.durability_service; + qos.m_deadline = builtin_data.deadline; + qos.m_latencyBudget = builtin_data.latency_budget; + qos.m_liveliness = builtin_data.liveliness; + qos.m_reliability = builtin_data.reliability; + qos.m_lifespan = builtin_data.lifespan; + qos.m_userData = builtin_data.user_data; + qos.m_ownership = builtin_data.ownership; + qos.m_ownershipStrength = builtin_data.ownership_strength; + qos.m_destinationOrder = builtin_data.destination_order; + + qos.m_presentation = builtin_data.presentation; + qos.m_partition = builtin_data.partition; + qos.m_topicData = builtin_data.topic_data; + qos.m_groupData = builtin_data.group_data; proxy_data.type_information(builtin_data.type_information); - proxy_data.m_qos.representation = builtin_data.representation; + qos.representation = builtin_data.representation; - proxy_data.m_qos.m_disablePositiveACKs = builtin_data.disable_positive_acks; - proxy_data.m_qos.data_sharing = builtin_data.data_sharing; + qos.m_disablePositiveACKs = builtin_data.disable_positive_acks; + qos.data_sharing = builtin_data.data_sharing; proxy_data.guid(builtin_data.guid); proxy_data.persistence_guid(builtin_data.persistence_guid); proxy_data.RTPSParticipantKey(builtin_data.participant_guid); proxy_data.set_locators(builtin_data.remote_locators); proxy_data.typeMaxSerialized(builtin_data.max_serialized_size); proxy_data.networkConfiguration(builtin_data.loopback_transformation); + + proxy_data.m_qos.setQos(qos, true); } void from_builtin_to_proxy( const SubscriptionBuiltinTopicData& builtin_data, ReaderProxyData& proxy_data) { + fastdds::dds::ReaderQos qos{}; + from_builtin_to_proxy(builtin_data.participant_key.value, proxy_data.guid().guidPrefix); from_builtin_to_proxy(builtin_data.key.value, proxy_data.guid().entityId); proxy_data.topicName(builtin_data.topic_name); proxy_data.typeName(builtin_data.type_name); - proxy_data.m_qos.m_durability = builtin_data.durability; - proxy_data.m_qos.m_deadline = builtin_data.deadline; - proxy_data.m_qos.m_latencyBudget = builtin_data.latency_budget; - proxy_data.m_qos.m_lifespan = builtin_data.lifespan; - proxy_data.m_qos.m_liveliness = builtin_data.liveliness; - proxy_data.m_qos.m_reliability = builtin_data.reliability; - proxy_data.m_qos.m_ownership = builtin_data.ownership; - proxy_data.m_qos.m_destinationOrder = builtin_data.destination_order; - proxy_data.m_qos.m_userData = builtin_data.user_data; - proxy_data.m_qos.m_timeBasedFilter = builtin_data.time_based_filter; - - proxy_data.m_qos.m_presentation = builtin_data.presentation; - proxy_data.m_qos.m_partition = builtin_data.partition; - proxy_data.m_qos.m_topicData = builtin_data.topic_data; - proxy_data.m_qos.m_groupData = builtin_data.group_data; + qos.m_durability = builtin_data.durability; + qos.m_deadline = builtin_data.deadline; + qos.m_latencyBudget = builtin_data.latency_budget; + qos.m_lifespan = builtin_data.lifespan; + qos.m_liveliness = builtin_data.liveliness; + qos.m_reliability = builtin_data.reliability; + qos.m_ownership = builtin_data.ownership; + qos.m_destinationOrder = builtin_data.destination_order; + qos.m_userData = builtin_data.user_data; + qos.m_timeBasedFilter = builtin_data.time_based_filter; + + qos.m_presentation = builtin_data.presentation; + qos.m_partition = builtin_data.partition; + qos.m_topicData = builtin_data.topic_data; + qos.m_groupData = builtin_data.group_data; proxy_data.type_information(builtin_data.type_information); - proxy_data.m_qos.representation = builtin_data.representation; - proxy_data.m_qos.type_consistency = builtin_data.type_consistency; + qos.representation = builtin_data.representation; + qos.type_consistency = builtin_data.type_consistency; proxy_data.content_filter(builtin_data.content_filter); - proxy_data.m_qos.m_disablePositiveACKs = builtin_data.disable_positive_acks; - proxy_data.m_qos.data_sharing = builtin_data.data_sharing; + qos.m_disablePositiveACKs = builtin_data.disable_positive_acks; + qos.data_sharing = builtin_data.data_sharing; proxy_data.guid(builtin_data.guid); proxy_data.RTPSParticipantKey(builtin_data.participant_guid); proxy_data.set_locators(builtin_data.remote_locators); proxy_data.networkConfiguration(builtin_data.loopback_transformation); proxy_data.m_expectsInlineQos = builtin_data.expects_inline_qos; + + proxy_data.m_qos.setQos(qos, true); } } // namespace rtps From fbdd68b33a8cd29725215e381c04eb00eee970c6 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 12:30:47 +0200 Subject: [PATCH 30/37] Refs #21357. Add `fill_type_information` to DomainParticipantImpl. Signed-off-by: Miguel Company --- .../fastdds/domain/DomainParticipantImpl.cpp | 49 +++++++++++++++++++ .../fastdds/domain/DomainParticipantImpl.hpp | 12 +++++ .../fastdds/domain/DomainParticipantImpl.hpp | 8 +++ 3 files changed, 69 insertions(+) diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index c9b7d19ceb2..95de983d160 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1885,6 +1885,55 @@ DomainParticipantListener* DomainParticipantImpl::get_listener_for( return nullptr; } +bool DomainParticipantImpl::fill_type_information( + const TypeSupport& type, + xtypes::TypeInformationParameter& type_information) +{ + using utils::to_type_propagation; + using utils::TypePropagation; + + auto properties = qos_.properties(); + auto type_propagation = to_type_propagation(properties); + bool should_assign_type_information = + (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || + (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); + + if (should_assign_type_information && (xtypes::TK_NONE != type->type_identifiers().type_identifier1()._d())) + { + xtypes::TypeInformation type_info; + + if (RETCODE_OK == + fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( + type->type_identifiers(), type_info)) + { + switch (type_propagation) + { + case TypePropagation::TYPEPROPAGATION_ENABLED: + { + // Use both complete and minimal type information + type_information.type_information = type_info; + break; + } + case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: + { + // Use minimal type information only + type_information.type_information.minimal() = type_info.minimal(); + break; + } + default: + // This should never happen as other cases are protected by should_assign_type_information + assert(false); + break; + } + + type_information.assigned(true); + return true; + } + } + + return false; +} + } // namespace dds } // namespace fastdds } // namespace eprosima diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp index ba481ff0717..58e40721bef 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.hpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.hpp @@ -508,6 +508,18 @@ class DomainParticipantImpl return id_counter_; } + /** + * @brief Fill a TypeInformationParameter with the type information of a TypeSupport. + * + * @param type TypeSupport to get the type information from. + * @param type_information TypeInformationParameter to fill. + * + * @return true if the constraints for propagating the type information are met. + */ + bool fill_type_information( + const TypeSupport& type, + xtypes::TypeInformationParameter& type_information); + protected: //!Domain id diff --git a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp index 6a7d45538b7..89547354da7 100644 --- a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp +++ b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp @@ -712,6 +712,14 @@ class DomainParticipantImpl return id_counter_; } + bool fill_type_information( + const TypeSupport& /*type*/, + xtypes::TypeInformationParameter& /*type_information*/) + { + return false; + } + + protected: DomainId_t domain_id_; From 9131e24ee798315f98bd280e370df4f5e6476cb0 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 10:13:19 +0200 Subject: [PATCH 31/37] Refs #21357. Refactor `register_writer` again. Signed-off-by: Miguel Company --- examples/cpp/rtps/WriterApp.cpp | 16 +++-- .../rtps/builtin/data/TopicDescription.hpp | 51 ++++++++++++++ .../rtps/participant/RTPSParticipant.hpp | 14 ++-- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 70 +++++++------------ src/cpp/rtps/builtin/BuiltinProtocols.cpp | 7 +- src/cpp/rtps/builtin/BuiltinProtocols.h | 11 ++- .../rtps/builtin/discovery/endpoint/EDP.cpp | 21 +++--- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 13 ++-- src/cpp/rtps/participant/RTPSParticipant.cpp | 5 +- .../rtps/participant/RTPSParticipantImpl.cpp | 10 +-- .../rtps/participant/RTPSParticipantImpl.h | 11 ++- .../rtps/monitor-service/MonitorService.cpp | 19 +++-- .../rtps/monitor-service/MonitorService.hpp | 5 +- .../common/RTPSBlackboxTestsBasic.cpp | 10 +-- .../common/RTPSWithRegistrationWriter.hpp | 6 +- .../rtps/participant/RTPSParticipant.hpp | 6 +- .../rtps/reader/StatefulReaderTests.cpp | 9 +-- .../statistics/rtps/MonitorServiceTests.cpp | 3 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 22 +++--- .../rtps/monitor-service/MonitorService.hpp | 5 +- 20 files changed, 194 insertions(+), 120 deletions(-) create mode 100644 include/fastdds/rtps/builtin/data/TopicDescription.hpp diff --git a/examples/cpp/rtps/WriterApp.cpp b/examples/cpp/rtps/WriterApp.cpp index f80dc2bb25d..75acf558f23 100644 --- a/examples/cpp/rtps/WriterApp.cpp +++ b/examples/cpp/rtps/WriterApp.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -105,14 +105,16 @@ WriterApp::WriterApp( std::cout << "Registering RTPS Writer" << std::endl; - PublicationBuiltinTopicData pub_builtin_data; - pub_builtin_data.type_name = "HelloWorld"; - pub_builtin_data.topic_name = topic_name; - pub_builtin_data.durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; - pub_builtin_data.reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; + TopicDescription topic_desc; + topic_desc.type_name = "HelloWorld"; + topic_desc.topic_name = topic_name; + + eprosima::fastdds::dds::WriterQos writer_qos; + writer_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + writer_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->register_writer(rtps_writer_, pub_builtin_data)) + if (!rtps_participant_->register_writer(rtps_writer_, topic_desc, writer_qos)) { throw std::runtime_error("Entity registration failed"); } diff --git a/include/fastdds/rtps/builtin/data/TopicDescription.hpp b/include/fastdds/rtps/builtin/data/TopicDescription.hpp new file mode 100644 index 00000000000..e8d445d1506 --- /dev/null +++ b/include/fastdds/rtps/builtin/data/TopicDescription.hpp @@ -0,0 +1,51 @@ +// Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file TopicDescription.hpp + */ + +#ifndef FASTDDS_RTPS_BUILTIN_DATA__TOPICDESCRIPTION_HPP +#define FASTDDS_RTPS_BUILTIN_DATA__TOPICDESCRIPTION_HPP + +#include +#include + +#include + +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +/// Structure TopicDescription, used to register an endpoint on a topic. +struct TopicDescription +{ + /// Topic name + fastcdr::string_255 topic_name; + + /// Type name + fastcdr::string_255 type_name; + + /// Type information + dds::xtypes::TypeInformationParameter type_information; + +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // FASTDDS_RTPS_BUILTIN_DATA__TOPICDESCRIPTION_HPP diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 91de38df483..9cfab3f42d9 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -53,9 +53,6 @@ struct IStatusObserver; #endif //FASTDDS_STATISTICS namespace fastdds { - -class TopicAttributes; - namespace rtps { struct PublicationBuiltinTopicData; @@ -64,6 +61,7 @@ class RTPSParticipantListener; class RTPSWriter; class RTPSReader; struct SubscriptionBuiltinTopicData; +struct TopicDescription; class EndpointAttributes; class WriterAttributes; class ReaderAttributes; @@ -140,13 +138,17 @@ class FASTDDS_EXPORTED_API RTPSParticipant /** * Register a Writer in the BuiltinProtocols. - * @param rtps_writer Pointer to the RTPSWriter. - * @param pub_builtin_data Contains the discovery information of the writer. + * + * @param rtps_writer Pointer to the RTPSWriter. + * @param topic Information regarding the topic where the writer is registering. + * @param qos Qos policies of the writer. + * * @return True if correctly registered. */ bool register_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data); + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos); /** * Register a Reader in the BuiltinProtocols. diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 14e1794f70a..c3900f5324c 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -457,11 +458,28 @@ ReturnCode_t DataWriterImpl::enable() } // REGISTER THE WRITER - PublicationBuiltinTopicData builtin_topic_data; - auto get_data_ret_code = get_publication_builtin_topic_data(builtin_topic_data); - static_cast(get_data_ret_code); - assert(RETCODE_OK == get_data_ret_code); - publisher_->rtps_participant()->register_writer(writer_, builtin_topic_data); + fastdds::rtps::TopicDescription topic_desc; + topic_desc.topic_name = topic_->get_name(); + topic_desc.type_name = topic_->get_type_name(); + publisher_->get_participant_impl()->fill_type_information(type_, topic_desc.type_information); + + WriterQos wqos = qos_.get_writerqos(get_publisher()->get_qos(), topic_->get_qos()); + if (!is_data_sharing_compatible_) + { + wqos.data_sharing.off(); + } + if (endpoint_partitions) + { + std::istringstream partition_string(*endpoint_partitions); + std::string partition_name; + wqos.m_partition.clear(); + + while (std::getline(partition_string, partition_name, ';')) + { + wqos.m_partition.push_back(partition_name.c_str()); + } + } + publisher_->rtps_participant()->register_writer(writer_, topic_desc, wqos); return RETCODE_OK; } @@ -1709,47 +1727,7 @@ ReturnCode_t DataWriterImpl::get_publication_builtin_topic_data( publication_data.group_data = publisher_->qos_.group_data(); // XTypes 1.3 - - using utils::to_type_propagation; - using utils::TypePropagation; - - auto properties = publisher_->get_participant()->get_qos().properties(); - auto type_propagation = to_type_propagation(properties); - bool should_assign_type_information = - (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || - (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); - - if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) - { - xtypes::TypeInformation type_info; - - if (RETCODE_OK == - fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type_->type_identifiers(), type_info)) - { - switch (type_propagation) - { - case TypePropagation::TYPEPROPAGATION_ENABLED: - { - // Use both complete and minimal type information - publication_data.type_information.type_information = type_info; - break; - } - case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: - { - // Use minimal type information only - publication_data.type_information.type_information.minimal() = type_info.minimal(); - break; - } - default: - // This should never happen as other cases are protected by should_assign_type_information - assert(false); - break; - } - - publication_data.type_information.assigned(true); - } - } + publisher_->get_participant_impl()->fill_type_information(type_, publication_data.type_information); publication_data.representation = qos_.representation(); // eProsima extensions diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 538a28099b1..3bc72f41a38 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -197,13 +197,14 @@ void BuiltinProtocols::filter_server_remote_locators( bool BuiltinProtocols::add_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data) + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos) { bool ok = true; if (nullptr != mp_PDP) { - ok = mp_PDP->get_edp()->new_writer_proxy_data(rtps_writer, pub_builtin_data); + ok = mp_PDP->get_edp()->new_writer_proxy_data(rtps_writer, topic, qos); if (!ok) { @@ -218,7 +219,7 @@ bool BuiltinProtocols::add_writer( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_writer(rtps_writer, pub_builtin_data.liveliness); + ok &= mp_WLP->add_local_writer(rtps_writer, qos.m_liveliness); } else { diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index acf2ee0f638..450fa162029 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -25,6 +25,7 @@ #include #include +#include #include @@ -129,13 +130,17 @@ class BuiltinProtocols /** * Add a local writer to the BuiltinProtocols. - * @param writer Pointer to the RTPSWriter - * @param pub_builtin_data QoS policies dictated by the publisher + * + * @param writer Pointer to the RTPSWriter + * @param topic Information regarding the topic where the writer is registering + * @param wqos QoS policies dictated by the publisher + * * @return True if correct. */ bool add_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data); + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos); /** * Add a local reader to the BuiltinProtocols. * @param rtps_reader Pointer to the RTPSReader. diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 7ea6c7906ab..8b6ba90edfa 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include #include @@ -240,13 +242,14 @@ bool EDP::new_reader_proxy_data( bool EDP::new_writer_proxy_data( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data) + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos) { EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_writer->getGuid().entityId << " in topic " << - pub_builtin_data.topic_name.to_string()); + topic.topic_name.to_string()); - auto init_fun = [this, rtps_writer, &pub_builtin_data]( + auto init_fun = [this, rtps_writer, &topic, &qos]( WriterProxyData* wpd, bool updating, const ParticipantProxyData& participant_data) @@ -255,12 +258,10 @@ bool EDP::new_writer_proxy_data( { EPROSIMA_LOG_ERROR(RTPS_EDP, "Adding already existent writer " << rtps_writer->getGuid().entityId << " in topic " - << pub_builtin_data.topic_name.to_string()); + << topic.topic_name.to_string()); return false; } - from_builtin_to_proxy(pub_builtin_data, *wpd); - const NetworkFactory& network = mp_RTPSParticipant->network_factory(); const auto& watt = rtps_writer->getAttributes(); @@ -278,8 +279,8 @@ bool EDP::new_writer_proxy_data( watt.external_unicast_locators); } wpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); - wpd->topicName(pub_builtin_data.topic_name); - wpd->typeName(pub_builtin_data.type_name); + wpd->topicName(topic.topic_name); + wpd->typeName(topic.type_name); wpd->topicKind((wpd->guid().entityId.value[3] & 0x0F) == 0x02 ? WITH_KEY : NO_KEY); using dds::utils::TypePropagation; @@ -288,7 +289,7 @@ bool EDP::new_writer_proxy_data( auto type_propagation = mp_RTPSParticipant->type_propagation(); assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation); - const auto& type_info = pub_builtin_data.type_information; + const auto& type_info = topic.type_information; if (type_info.assigned()) { switch (type_propagation) @@ -321,7 +322,7 @@ bool EDP::new_writer_proxy_data( BaseWriter* base_writer = BaseWriter::downcast(rtps_writer); assert(base_writer->get_history() != nullptr); wpd->typeMaxSerialized(base_writer->get_history()->getTypeMaxSerialized()); - wpd->m_qos.setQos(wpd->m_qos, true); + wpd->m_qos.setQos(qos, true); wpd->userDefinedId(watt.getUserDefinedID()); wpd->persistence_guid(watt.persistence_guid); #if HAVE_SECURITY diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index ce5f3edebc7..f11fdf1820a 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -54,6 +54,7 @@ class WriterProxyData; class RTPSParticipantImpl; struct PublicationBuiltinTopicData; struct SubscriptionBuiltinTopicData; +struct TopicDescription; /** * Class EDP, base class for Endpoint Discovery Protocols. It contains generic methods used by the two EDP implemented (EDPSimple and EDPStatic), as well as abstract methods @@ -178,14 +179,18 @@ class EDP const SubscriptionBuiltinTopicData& sub_builtin_data, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** - * Create a new ReaderPD for a local Writer. - * @param rtps_writer Pointer to the RTPSWriter. - * @param pub_builtin_data QoS policies dictated by the publisher. + * Create a new WriterPD for a local Writer. + * + * @param rtps_writer Pointer to the RTPSWriter. + * @param topic Information regarding the topic where the writer is registering. + * @param qos QoS policies dictated by the publisher. + * * @return True if correct. */ bool new_writer_proxy_data( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data); + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos); /** * A previously created Reader has been updated * @param rtps_reader Pointer to the RTPSReader. diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 5020f2642ce..8277cf6d1fd 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -77,9 +77,10 @@ uint32_t RTPSParticipant::getRTPSParticipantID() const bool RTPSParticipant::register_writer( RTPSWriter* writer, - const PublicationBuiltinTopicData& pub_builtin_data) + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos) { - return mp_impl->register_writer(writer, pub_builtin_data); + return mp_impl->register_writer(writer, topic, qos); } bool RTPSParticipant::register_reader( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 620730522f6..5a67df06f24 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1406,9 +1406,10 @@ void RTPSParticipantImpl::disableReader( bool RTPSParticipantImpl::register_writer( RTPSWriter* rtps_writer, - const PublicationBuiltinTopicData& pub_builtin_data) + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos) { - return this->mp_builtinProtocols->add_writer(rtps_writer, pub_builtin_data); + return this->mp_builtinProtocols->add_writer(rtps_writer, topic, qos); } bool RTPSParticipantImpl::register_reader( @@ -2876,9 +2877,10 @@ const fastdds::statistics::rtps::IStatusObserver* RTPSParticipantImpl::create_mo return this->createWriter(WriterOut, param, hist, listen, entityId, isBuiltin); }, [&](RTPSWriter* w, - const PublicationBuiltinTopicData& pub_builtin_data) -> bool + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos) -> bool { - return this->register_writer(w, pub_builtin_data); + return this->register_writer(w, topic, qos); }, getEventResource() )); diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index 80001553231..e2951297baa 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -113,6 +113,7 @@ class MessageReceiver; namespace rtps { struct PublicationBuiltinTopicData; +struct TopicDescription; class RTPSParticipant; class RTPSParticipantListener; class BuiltinProtocols; @@ -895,13 +896,17 @@ class RTPSParticipantImpl /** * Register a Writer in the BuiltinProtocols. - * @param Writer Pointer to the RTPSWriter. - * @param pub_builtin_data Contains the discovery information of the writer. + * + * @param Writer Pointer to the RTPSWriter. + * @param topic Information regarding the topic where the writer is registering. + * @param qos Qos policies of the writer. + * * @return True if correctly registered. */ bool register_writer( RTPSWriter* Writer, - const PublicationBuiltinTopicData& pub_builtin_data); + const TopicDescription& topic, + const fastdds::dds::WriterQos& qos); /** * Register a Reader in the BuiltinProtocols. diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp index 72f9fc95a05..96fa9d0ba9a 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp @@ -18,6 +18,8 @@ #include +#include + #include #include @@ -482,14 +484,17 @@ bool MonitorService::create_endpoint() { status_writer_ = dynamic_cast(tmp_writer); - // Register the writer in the participant - PublicationBuiltinTopicData pub_builtin_data; - pub_builtin_data.reliability.kind = dds::RELIABLE_RELIABILITY_QOS; - pub_builtin_data.durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; - pub_builtin_data.topic_name = MONITOR_SERVICE_TOPIC; - pub_builtin_data.type_name = type_.get_name(); + //! Register the writer in the participant + fastdds::dds::WriterQos wqos; + + wqos.m_reliability.kind = dds::RELIABLE_RELIABILITY_QOS; + wqos.m_durability.kind = dds::TRANSIENT_LOCAL_DURABILITY_QOS; + + TopicDescription topic_desc; + topic_desc.topic_name = MONITOR_SERVICE_TOPIC; + topic_desc.type_name = type_.get_name(); - endpoint_registrator_(status_writer_, pub_builtin_data); + endpoint_registrator_(status_writer_, topic_desc, wqos); } else { diff --git a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp index 574aecab706..5e94517f876 100644 --- a/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp +++ b/src/cpp/statistics/rtps/monitor-service/MonitorService.hpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include @@ -82,7 +82,8 @@ class MonitorService using endpoint_registrator_t = std::function; + const eprosima::fastdds::rtps::TopicDescription&, + const eprosima::fastdds::dds::WriterQos&)>; MonitorService( const fastdds::rtps::GUID_t& guid, diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index 845dfb7d690..91c0afe060b 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -815,11 +816,12 @@ TEST(RTPS, MultithreadedWriterCreation) eprosima::fastdds::rtps::RTPSWriter* writer = eprosima::fastdds::rtps::RTPSDomain::createRTPSWriter( rtps_participant, writer_attr, history, nullptr); - PublicationBuiltinTopicData pub_builtin_data; - pub_builtin_data.type_name = "string"; - pub_builtin_data.topic_name = "test_topic"; + TopicDescription topic_desc; + topic_desc.type_name = "string"; + topic_desc.topic_name = "test_topic"; /* Register writer in participant */ - ASSERT_EQ(rtps_participant->register_writer(writer, pub_builtin_data), true); + eprosima::fastdds::dds::WriterQos writer_qos; + ASSERT_EQ(rtps_participant->register_writer(writer, topic_desc, writer_qos), true); { /* Wait for test completion request */ diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index a7c1c73985b..c3e6d53df8e 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -181,7 +182,10 @@ class RTPSWithRegistrationWriter return; } - ASSERT_EQ(participant_->register_writer(writer_, pub_builtin_data_), true); + TopicDescription topic_desc; + topic_desc.type_name = type_.get_name(); + topic_desc.topic_name = pub_builtin_data_.topic_name; + ASSERT_EQ(participant_->register_writer(writer_, topic_desc, writer_qos_), true); initialized_ = true; } diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index a304a4932d6..d7b69dfe71a 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -66,6 +66,7 @@ class RTPSParticipantListener; class RTPSWriter; class RTPSReader; struct SubscriptionBuiltinTopicData; +struct TopicDescription; class ResourceEvent; class WLP; @@ -185,9 +186,10 @@ class FASTDDS_EXPORTED_API RTPSParticipant MOCK_CONST_METHOD0(typelookup_manager, fastdds::dds::builtin::TypeLookupManager* ()); - MOCK_METHOD2(register_writer, bool( + MOCK_METHOD3(register_writer, bool( RTPSWriter * Writer, - const PublicationBuiltinTopicData& pub_builtin_data)); + const fastdds::rtps::TopicDescription& topic, + const fastdds::dds::WriterQos& qos)); MOCK_METHOD2(update_writer, bool( RTPSWriter * Writer, diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index e4b0e129d72..7308b73a12e 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -93,11 +94,11 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) SubscriptionBuiltinTopicData sub_builtin_data; sub_builtin_data.type_name = "string"; sub_builtin_data.topic_name = "topic"; - PublicationBuiltinTopicData pub_builtin_data; - pub_builtin_data.type_name = "string"; - pub_builtin_data.topic_name = "topic"; + TopicDescription topic_desc; + topic_desc.type_name = "string"; + topic_desc.topic_name = "topic"; part->register_reader(reader, sub_builtin_data); - part->register_writer(writer, pub_builtin_data); + part->register_writer(writer, topic_desc, {}); // After registration, the writer should be matched auto writer_guid = writer->getGuid(); diff --git a/test/unittest/statistics/rtps/MonitorServiceTests.cpp b/test/unittest/statistics/rtps/MonitorServiceTests.cpp index fe33788347b..6fc233b98ca 100644 --- a/test/unittest/statistics/rtps/MonitorServiceTests.cpp +++ b/test/unittest/statistics/rtps/MonitorServiceTests.cpp @@ -78,7 +78,8 @@ class MonitorServiceTests : public ::testing::Test }, [&]( fastdds::rtps::RTPSWriter*, - const ::eprosima::fastdds::rtps::PublicationBuiltinTopicData&)->bool + const ::eprosima::fastdds::rtps::TopicDescription&, + const ::eprosima::fastdds::dds::WriterQos&)->bool { return true; }, diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index d5784fc796a..218d6712602 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -358,14 +359,9 @@ class RTPSStatisticsTestsImpl using namespace fastdds; using namespace fastdds::rtps; - auto& watt = writer_->getAttributes(); - PublicationBuiltinTopicData pub_builtin_data; - pub_builtin_data.type_name = data_type; - pub_builtin_data.topic_name = topic_name; - pub_builtin_data.durability.durabilityKind(watt.durabilityKind); - pub_builtin_data.reliability.kind = - RELIABLE == - watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; + TopicDescription topic_desc; + topic_desc.type_name = data_type; + topic_desc.topic_name = topic_name; auto& ratt = writer_->getAttributes(); SubscriptionBuiltinTopicData sub_builtin_data; @@ -376,7 +372,15 @@ class RTPSStatisticsTestsImpl RELIABLE == ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - participant_->register_writer(writer_, pub_builtin_data); + + dds::WriterQos Wqos; + auto& watt = writer_->getAttributes(); + Wqos.m_durability.durabilityKind(watt.durabilityKind); + Wqos.m_reliability.kind = + RELIABLE == + watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; + + participant_->register_writer(writer_, topic_desc, Wqos); participant_->register_reader(reader_, sub_builtin_data); } diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index 5191c4bd664..7c35c22dc88 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -45,7 +45,7 @@ namespace fastdds { namespace rtps { -struct PublicationBuiltinTopicData; +struct TopicDescription; } // namespace rtps @@ -69,7 +69,8 @@ class MonitorService using endpoint_registrator_t = std::function; + const eprosima::fastdds::rtps::TopicDescription&, + const eprosima::fastdds::dds::WriterQos&)>; MonitorService( const fastdds::rtps::GUID_t& guid, From 7b349e403744c4e93473ed1a0100a1d8e43abda5 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 11:33:27 +0200 Subject: [PATCH 32/37] Refs #21357. Refactor `register_reader` again. Signed-off-by: Miguel Company --- examples/cpp/rtps/ReaderApp.cpp | 16 ++-- .../rtps/participant/RTPSParticipant.hpp | 12 ++- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 78 +++++++------------ src/cpp/rtps/builtin/BuiltinProtocols.cpp | 7 +- src/cpp/rtps/builtin/BuiltinProtocols.h | 13 ++-- .../rtps/builtin/discovery/endpoint/EDP.cpp | 20 +++-- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 12 +-- src/cpp/rtps/participant/RTPSParticipant.cpp | 5 +- .../rtps/participant/RTPSParticipantImpl.cpp | 5 +- .../rtps/participant/RTPSParticipantImpl.h | 12 ++- .../common/RTPSWithRegistrationReader.hpp | 6 +- .../rtps/participant/RTPSParticipant.hpp | 5 +- .../rtps/builtin/data/ReaderProxyData.hpp | 18 ----- .../rtps/builtin/data/WriterProxyData.hpp | 23 ------ test/unittest/dds/status/ListenerTests.cpp | 2 +- test/unittest/rtps/discovery/CMakeLists.txt | 1 - .../rtps/reader/StatefulReaderTests.cpp | 5 +- .../statistics/rtps/RTPSStatisticsTests.cpp | 19 ++--- 18 files changed, 106 insertions(+), 153 deletions(-) diff --git a/examples/cpp/rtps/ReaderApp.cpp b/examples/cpp/rtps/ReaderApp.cpp index c0d6d4ba6c0..fd7f5a71f73 100644 --- a/examples/cpp/rtps/ReaderApp.cpp +++ b/examples/cpp/rtps/ReaderApp.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,14 +114,16 @@ ReaderApp::ReaderApp( std::cout << "Registering RTPS Reader" << std::endl; - SubscriptionBuiltinTopicData sub_builtin_data; - sub_builtin_data.topic_name = topic_name; - sub_builtin_data.type_name = "HelloWorld"; - sub_builtin_data.durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; - sub_builtin_data.reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; + TopicDescription topic_desc; + topic_desc.topic_name = topic_name; + topic_desc.type_name = "HelloWorld"; + + eprosima::fastdds::dds::ReaderQos reader_qos; + reader_qos.m_durability.kind = eprosima::fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + reader_qos.m_reliability.kind = eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS; // Register entity - if (!rtps_participant_->register_reader(rtps_reader_, sub_builtin_data)) + if (!rtps_participant_->register_reader(rtps_reader_, topic_desc, reader_qos)) { throw std::runtime_error("Entity registration failed"); } diff --git a/include/fastdds/rtps/participant/RTPSParticipant.hpp b/include/fastdds/rtps/participant/RTPSParticipant.hpp index 9cfab3f42d9..30f27ac906d 100644 --- a/include/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/include/fastdds/rtps/participant/RTPSParticipant.hpp @@ -152,14 +152,18 @@ class FASTDDS_EXPORTED_API RTPSParticipant /** * Register a Reader in the BuiltinProtocols. - * @param rtps_reader Pointer to the RTPSReader. - * @param sub_builtin_data Contains the discovery information of the reader. - * @param content_filter Optional content filtering information. + * + * @param rtps_reader Pointer to the RTPSReader. + * @param topic Information regarding the topic where the reader is registering. + * @param qos Qos policies of the reader. + * @param content_filter Optional content filtering information. + * * @return True if correctly registered. */ bool register_reader( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const ContentFilterProperty* content_filter = nullptr); /** diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index ad41da409ac..0a1f8f8a71e 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -276,10 +277,27 @@ ReturnCode_t DataReaderImpl::enable() qos_.lifespan().duration.to_ns() * 1e-6); // Register the reader - SubscriptionBuiltinTopicData builtin_topic_data; - auto get_data_ret_code = get_subscription_builtin_topic_data(builtin_topic_data); - static_cast(get_data_ret_code); - assert(RETCODE_OK == get_data_ret_code); + fastdds::rtps::TopicDescription topic_desc; + topic_desc.topic_name = topic_->get_name(); + topic_desc.type_name = topic_->get_type_name(); + subscriber_->get_participant_impl()->fill_type_information(type_, topic_desc.type_information); + + ReaderQos rqos = qos_.get_readerqos(subscriber_->get_qos()); + if (!is_data_sharing_compatible_) + { + rqos.data_sharing.off(); + } + if (endpoint_partitions) + { + std::istringstream partition_string(*endpoint_partitions); + std::string partition_name; + rqos.m_partition.clear(); + + while (std::getline(partition_string, partition_name, ';')) + { + rqos.m_partition.push_back(partition_name.c_str()); + } + } rtps::ContentFilterProperty* filter_property = nullptr; if (nullptr != content_topic && !content_topic->filter_property.filter_expression.empty()) @@ -288,7 +306,8 @@ ReturnCode_t DataReaderImpl::enable() } if (!subscriber_->rtps_participant()->register_reader( reader_, - builtin_topic_data, + topic_desc, + rqos, filter_property)) { EPROSIMA_LOG_ERROR(DATA_READER, "Could not register reader on discovery protocols"); @@ -1838,7 +1857,7 @@ void DataReaderImpl::release_payload_pool() ReturnCode_t DataReaderImpl::check_datasharing_compatible( const ReaderAttributes& reader_attributes, - bool& is_data_sharing_compatible) const + bool& is_datasharing_compatible) const { #if HAVE_SECURITY bool has_security_enabled = subscriber_->rtps_participant()->is_security_enabled_for_reader(reader_attributes); @@ -1848,7 +1867,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( bool has_key = type_->is_compute_key_provided; - is_data_sharing_compatible = false; + is_datasharing_compatible = false; switch (qos_.data_sharing().kind()) { case DataSharingKind::OFF: @@ -1874,7 +1893,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( return RETCODE_BAD_PARAMETER; } - is_data_sharing_compatible = true; + is_datasharing_compatible = true; return RETCODE_OK; break; case DataSharingKind::AUTO: @@ -1898,7 +1917,7 @@ ReturnCode_t DataReaderImpl::check_datasharing_compatible( return RETCODE_OK; } - is_data_sharing_compatible = true; + is_datasharing_compatible = true; return RETCODE_OK; break; default: @@ -2212,46 +2231,9 @@ ReturnCode_t DataReaderImpl::get_subscription_builtin_topic_data( subscription_data.group_data = subscriber_->qos_.group_data(); // X-Types 1.3 - using utils::to_type_propagation; - using utils::TypePropagation; - - auto properties = subscriber_->get_participant()->get_qos().properties(); - auto type_propagation = to_type_propagation(properties); - bool should_assign_type_information = - (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || - (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); - - if (should_assign_type_information && (xtypes::TK_NONE != type_->type_identifiers().type_identifier1()._d())) + if(subscriber_->get_participant_impl()->fill_type_information(type_, subscription_data.type_information)) { - xtypes::TypeInformation type_info; - - if (RETCODE_OK == - fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type_->type_identifiers(), type_info)) - { - switch (type_propagation) - { - case TypePropagation::TYPEPROPAGATION_ENABLED: - { - // Use both complete and minimal type information - subscription_data.type_information.type_information = type_info; - break; - } - case TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH: - { - // Use minimal type information only - subscription_data.type_information.type_information.minimal() = type_info.minimal(); - break; - } - default: - // This should never happen as other cases are protected by should_assign_type_information - assert(false); - break; - } - - subscription_data.type_information.assigned(true); - subscription_data.type_consistency = qos_.type_consistency(); - } + subscription_data.type_consistency = qos_.type_consistency(); } subscription_data.representation = qos_.representation(); diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.cpp b/src/cpp/rtps/builtin/BuiltinProtocols.cpp index 3bc72f41a38..dc6416da062 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.cpp +++ b/src/cpp/rtps/builtin/BuiltinProtocols.cpp @@ -231,14 +231,15 @@ bool BuiltinProtocols::add_writer( bool BuiltinProtocols::add_reader( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter) { bool ok = true; if (nullptr != mp_PDP) { - ok = mp_PDP->get_edp()->new_reader_proxy_data(rtps_reader, sub_builtin_data, content_filter); + ok = mp_PDP->get_edp()->new_reader_proxy_data(rtps_reader, topic, qos, content_filter); if (!ok) { @@ -253,7 +254,7 @@ bool BuiltinProtocols::add_reader( if (nullptr != mp_WLP) { - ok &= mp_WLP->add_local_reader(rtps_reader, sub_builtin_data.liveliness); + ok &= mp_WLP->add_local_reader(rtps_reader, qos.m_liveliness); } return ok; diff --git a/src/cpp/rtps/builtin/BuiltinProtocols.h b/src/cpp/rtps/builtin/BuiltinProtocols.h index 450fa162029..d167a44a4e8 100644 --- a/src/cpp/rtps/builtin/BuiltinProtocols.h +++ b/src/cpp/rtps/builtin/BuiltinProtocols.h @@ -133,7 +133,7 @@ class BuiltinProtocols * * @param writer Pointer to the RTPSWriter * @param topic Information regarding the topic where the writer is registering - * @param wqos QoS policies dictated by the publisher + * @param qos QoS policies dictated by the publisher * * @return True if correct. */ @@ -143,14 +143,17 @@ class BuiltinProtocols const fastdds::dds::WriterQos& qos); /** * Add a local reader to the BuiltinProtocols. - * @param rtps_reader Pointer to the RTPSReader. - * @param sub_builtin_data QoS policies dictated by the subscriber - * @param content_filter Optional content filtering information. + * + * @param rtps_reader Pointer to the RTPSReader. + * @param topic Information regarding the topic where the writer is registering + * @param qos QoS policies dictated by the subscriber + * @param content_filter Optional content filtering information. * @return True if correct. */ bool add_reader( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 8b6ba90edfa..bfd74046dc3 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -37,7 +37,6 @@ #include #include -#include #include #include #include @@ -98,14 +97,15 @@ EDP::~EDP() bool EDP::new_reader_proxy_data( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter) { EPROSIMA_LOG_INFO(RTPS_EDP, "Adding " << rtps_reader->getGuid().entityId << " in topic " << - sub_builtin_data.topic_name.to_string()); + topic.topic_name.to_string()); - auto init_fun = [this, rtps_reader, &sub_builtin_data, content_filter]( + auto init_fun = [this, rtps_reader, &topic, &qos, content_filter]( ReaderProxyData* rpd, bool updating, const ParticipantProxyData& participant_data) @@ -114,15 +114,13 @@ bool EDP::new_reader_proxy_data( { EPROSIMA_LOG_ERROR(RTPS_EDP, "Adding already existent reader " << rtps_reader->getGuid().entityId << " in topic " - << sub_builtin_data.topic_name.to_string()); + << topic.topic_name.to_string()); return false; } const NetworkFactory& network = mp_RTPSParticipant->network_factory(); const auto& ratt = rtps_reader->getAttributes(); - from_builtin_to_proxy(sub_builtin_data, *rpd); - rpd->isAlive(true); rpd->m_expectsInlineQos = rtps_reader->expects_inline_qos(); rpd->guid(rtps_reader->getGuid()); @@ -139,8 +137,8 @@ bool EDP::new_reader_proxy_data( ratt.external_unicast_locators); } rpd->RTPSParticipantKey() = mp_RTPSParticipant->getGuid(); - rpd->topicName(sub_builtin_data.topic_name); - rpd->typeName(sub_builtin_data.type_name); + rpd->topicName(topic.topic_name); + rpd->typeName(topic.type_name); rpd->topicKind((rpd->guid().entityId.value[3] & 0x0F) == 0x07 ? WITH_KEY : NO_KEY); using dds::utils::TypePropagation; @@ -149,7 +147,7 @@ bool EDP::new_reader_proxy_data( auto type_propagation = mp_RTPSParticipant->type_propagation(); assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation); - const auto& type_info = sub_builtin_data.type_information; + const auto& type_info = topic.type_information; if (type_info.assigned()) { switch (type_propagation) @@ -179,7 +177,7 @@ bool EDP::new_reader_proxy_data( } } - rpd->m_qos.setQos(rpd->m_qos, true); + rpd->m_qos.setQos(qos, true); rpd->userDefinedId(ratt.getUserDefinedID()); if (nullptr != content_filter) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index f11fdf1820a..df585a607f9 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -52,8 +52,6 @@ class RTPSWriter; class RTPSReader; class WriterProxyData; class RTPSParticipantImpl; -struct PublicationBuiltinTopicData; -struct SubscriptionBuiltinTopicData; struct TopicDescription; /** @@ -168,15 +166,17 @@ class EDP /** * Create a new ReaderPD for a local Reader. * - * @param rtps_reader Pointer to the RTPSReader. - * @param sub_builtin_data Subscription data for the reader. - * @param content_filter Optional content filtering information. + * @param rtps_reader Pointer to the RTPSReader. + * @param topic Information regarding the topic where the writer is registering. + * @param qos QoS policies dictated by the subscriber. + * @param content_filter Optional content filtering information. * * @return True if correct. */ bool new_reader_proxy_data( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter = nullptr); /** * Create a new WriterPD for a local Writer. diff --git a/src/cpp/rtps/participant/RTPSParticipant.cpp b/src/cpp/rtps/participant/RTPSParticipant.cpp index 8277cf6d1fd..362f70f42da 100644 --- a/src/cpp/rtps/participant/RTPSParticipant.cpp +++ b/src/cpp/rtps/participant/RTPSParticipant.cpp @@ -85,10 +85,11 @@ bool RTPSParticipant::register_writer( bool RTPSParticipant::register_reader( RTPSReader* reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const ContentFilterProperty* content_filter) { - return mp_impl->register_reader(reader, sub_builtin_data, content_filter); + return mp_impl->register_reader(reader, topic, qos, content_filter); } void RTPSParticipant::update_attributes( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index 5a67df06f24..5191ff89379 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -1414,10 +1414,11 @@ bool RTPSParticipantImpl::register_writer( bool RTPSParticipantImpl::register_reader( RTPSReader* rtps_reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const ContentFilterProperty* content_filter) { - return this->mp_builtinProtocols->add_reader(rtps_reader, sub_builtin_data, content_filter); + return this->mp_builtinProtocols->add_reader(rtps_reader, topic, qos, content_filter); } void RTPSParticipantImpl::update_attributes( diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index e2951297baa..d125141d786 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -910,14 +910,18 @@ class RTPSParticipantImpl /** * Register a Reader in the BuiltinProtocols. - * @param Reader Pointer to the RTPSReader. - * @param sub_builtin_data Contains the discovery information of the reader. - * @param content_filter Optional content filtering information. + * + * @param Reader Pointer to the RTPSReader. + * @param topic Information regarding the topic where the reader is registering. + * @param qos Qos policies of the reader. + * @param content_filter Optional content filtering information. + * * @return True if correctly registered. */ bool register_reader( RTPSReader* Reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const ContentFilterProperty* content_filter = nullptr); /** diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index c89f4709d3e..4455bb408ea 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -193,7 +193,11 @@ class RTPSWithRegistrationReader return; } - initialized_ = participant_->register_reader(reader_, sub_builtin_data_, content_filter_property_); + eprosima::fastdds::rtps::TopicDescription topic_desc; + topic_desc.topic_name = sub_builtin_data_.topic_name; + topic_desc.type_name = sub_builtin_data_.type_name; + + initialized_ = participant_->register_reader(reader_, topic_desc, reader_qos_, content_filter_property_); } void update() diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp index d7b69dfe71a..d56e0ed65dc 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.hpp @@ -195,9 +195,10 @@ class FASTDDS_EXPORTED_API RTPSParticipant RTPSWriter * Writer, const fastdds::dds::WriterQos& wqos)); - MOCK_METHOD3(register_reader, bool( + MOCK_METHOD4(register_reader, bool( RTPSReader * Reader, - const SubscriptionBuiltinTopicData& sub_builtin_data, + const fastdds::rtps::TopicDescription& topic, + const fastdds::dds::ReaderQos& qos, const fastdds::rtps::ContentFilterProperty* content_filter)); MOCK_METHOD3(update_reader, bool( diff --git a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp index 11ee5143594..f2565882519 100644 --- a/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp +++ b/test/mock/rtps/ReaderProxyData/rtps/builtin/data/ReaderProxyData.hpp @@ -324,23 +324,6 @@ class ReaderProxyData return content_filter_; } - void networkConfiguration( - const NetworkConfigSet_t& networkConfiguration) - { - m_networkConfiguration = networkConfiguration; - } - - void networkConfiguration( - NetworkConfigSet_t&& networkConfiguration) - { - m_networkConfiguration = std::move(networkConfiguration); - } - - const NetworkConfigSet_t& networkConfiguration() const - { - return m_networkConfiguration; - } - void copy( ReaderProxyData* /*rdat*/) { @@ -368,7 +351,6 @@ class ReaderProxyData InstanceHandle_t m_RTPSParticipantKey; uint16_t m_userDefinedId; fastdds::rtps::ContentFilterProperty content_filter_; - NetworkConfigSet_t m_networkConfiguration; bool has_type_info_ {false}; }; diff --git a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp index 62f861d961e..1a67868820b 100644 --- a/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp +++ b/test/mock/rtps/WriterProxyData/rtps/builtin/data/WriterProxyData.hpp @@ -297,28 +297,6 @@ class WriterProxyData return m_userDefinedId; } - void networkConfiguration( - const NetworkConfigSet_t& networkConfiguration) - { - m_networkConfiguration = networkConfiguration; - } - - void networkConfiguration( - NetworkConfigSet_t&& networkConfiguration) - { - m_networkConfiguration = std::move(networkConfiguration); - } - - const NetworkConfigSet_t& networkConfiguration() const - { - return m_networkConfiguration; - } - - NetworkConfigSet_t& networkConfiguration() - { - return m_networkConfiguration; - } - void copy( WriterProxyData* /*wdat*/) { @@ -345,7 +323,6 @@ class WriterProxyData InstanceHandle_t m_key; InstanceHandle_t m_RTPSParticipantKey; uint16_t m_userDefinedId; - NetworkConfigSet_t m_networkConfiguration; bool has_type_info_ {false}; }; diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index e02ae6d8366..91fec1db748 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -585,7 +585,7 @@ class UserListeners : public ::testing::Test ASSERT_NE(subscriber_, nullptr); EXPECT_CALL(participant_mock_, - register_reader(&reader_mock_, ::testing::_, nullptr)).WillRepeatedly( + register_reader(&reader_mock_, ::testing::_, ::testing::_, nullptr)).WillRepeatedly( ::testing::Return(true)); datareader_ = diff --git a/test/unittest/rtps/discovery/CMakeLists.txt b/test/unittest/rtps/discovery/CMakeLists.txt index 45505e83d5b..c0a814f300a 100644 --- a/test/unittest/rtps/discovery/CMakeLists.txt +++ b/test/unittest/rtps/discovery/CMakeLists.txt @@ -21,7 +21,6 @@ set(EDPTESTS_SOURCE EdpTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp - ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ProxyDataConverters.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/SerializedPayload.cpp diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp index 7308b73a12e..4bcbce5b02c 100644 --- a/test/unittest/rtps/reader/StatefulReaderTests.cpp +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -91,13 +91,10 @@ TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) ASSERT_NE(writer, nullptr); // Register both endpoints - SubscriptionBuiltinTopicData sub_builtin_data; - sub_builtin_data.type_name = "string"; - sub_builtin_data.topic_name = "topic"; TopicDescription topic_desc; topic_desc.type_name = "string"; topic_desc.topic_name = "topic"; - part->register_reader(reader, sub_builtin_data); + part->register_reader(reader, topic_desc, {}); part->register_writer(writer, topic_desc, {}); // After registration, the writer should be matched diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 218d6712602..dbc8a093c40 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -363,16 +363,6 @@ class RTPSStatisticsTestsImpl topic_desc.type_name = data_type; topic_desc.topic_name = topic_name; - auto& ratt = writer_->getAttributes(); - SubscriptionBuiltinTopicData sub_builtin_data; - sub_builtin_data.type_name = data_type; - sub_builtin_data.topic_name = topic_name; - sub_builtin_data.durability.durabilityKind(ratt.durabilityKind); - sub_builtin_data.reliability.kind = - RELIABLE == - ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; - - dds::WriterQos Wqos; auto& watt = writer_->getAttributes(); Wqos.m_durability.durabilityKind(watt.durabilityKind); @@ -380,8 +370,15 @@ class RTPSStatisticsTestsImpl RELIABLE == watt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; + dds::ReaderQos Rqos; + auto& ratt = writer_->getAttributes(); + Rqos.m_durability.durabilityKind(ratt.durabilityKind); + Rqos.m_reliability.kind = + RELIABLE == + ratt.reliabilityKind ? dds::RELIABLE_RELIABILITY_QOS : dds::BEST_EFFORT_RELIABILITY_QOS; + participant_->register_writer(writer_, topic_desc, Wqos); - participant_->register_reader(reader_, sub_builtin_data); + participant_->register_reader(reader_, topic_desc, Rqos); } void destroy_endpoints() From ab475b43dbc4d53e44af327206c8b29423d96576 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 14:23:29 +0200 Subject: [PATCH 33/37] Refs #21357. Fix blackbox build. Signed-off-by: Miguel Company --- test/blackbox/common/RTPSWithRegistrationReader.hpp | 1 + test/blackbox/common/RTPSWithRegistrationWriter.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index 4455bb408ea..4883fc2dfea 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/test/blackbox/common/RTPSWithRegistrationWriter.hpp b/test/blackbox/common/RTPSWithRegistrationWriter.hpp index c3e6d53df8e..a54c75758d4 100644 --- a/test/blackbox/common/RTPSWithRegistrationWriter.hpp +++ b/test/blackbox/common/RTPSWithRegistrationWriter.hpp @@ -182,7 +182,7 @@ class RTPSWithRegistrationWriter return; } - TopicDescription topic_desc; + eprosima::fastdds::rtps::TopicDescription topic_desc; topic_desc.type_name = type_.get_name(); topic_desc.topic_name = pub_builtin_data_.topic_name; ASSERT_EQ(participant_->register_writer(writer_, topic_desc, writer_qos_), true); From 4c3d06ed9b4a525f44523329336be8d658471954 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 15:01:54 +0200 Subject: [PATCH 34/37] Refs #21357. Fix content filter topic name. Signed-off-by: Miguel Company --- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index 0a1f8f8a71e..5f67a977f11 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -278,7 +278,7 @@ ReturnCode_t DataReaderImpl::enable() // Register the reader fastdds::rtps::TopicDescription topic_desc; - topic_desc.topic_name = topic_->get_name(); + topic_desc.topic_name = topic_->get_impl()->get_rtps_topic_name(); topic_desc.type_name = topic_->get_type_name(); subscriber_->get_participant_impl()->fill_type_information(type_, topic_desc.type_information); From dfbfd8a1efd18764817e87287c7fd4e5fc2381d8 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 29 Jul 2024 15:43:22 +0200 Subject: [PATCH 35/37] Refs #21357. Uncrustify. Signed-off-by: Miguel Company --- src/cpp/fastdds/domain/DomainParticipantImpl.cpp | 8 ++++---- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 2 +- .../fastdds/domain/DomainParticipantImpl.hpp | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp index 95de983d160..1fa326eedba 100644 --- a/src/cpp/fastdds/domain/DomainParticipantImpl.cpp +++ b/src/cpp/fastdds/domain/DomainParticipantImpl.cpp @@ -1895,16 +1895,16 @@ bool DomainParticipantImpl::fill_type_information( auto properties = qos_.properties(); auto type_propagation = to_type_propagation(properties); bool should_assign_type_information = - (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || - (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); + (TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) || + (TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation); if (should_assign_type_information && (xtypes::TK_NONE != type->type_identifiers().type_identifier1()._d())) { xtypes::TypeInformation type_info; if (RETCODE_OK == - fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( - type->type_identifiers(), type_info)) + fastdds::rtps::RTPSDomainImpl::get_instance()->type_object_registry_observer().get_type_information( + type->type_identifiers(), type_info)) { switch (type_propagation) { diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index 5f67a977f11..10e9e8de36a 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -2231,7 +2231,7 @@ ReturnCode_t DataReaderImpl::get_subscription_builtin_topic_data( subscription_data.group_data = subscriber_->qos_.group_data(); // X-Types 1.3 - if(subscriber_->get_participant_impl()->fill_type_information(type_, subscription_data.type_information)) + if (subscriber_->get_participant_impl()->fill_type_information(type_, subscription_data.type_information)) { subscription_data.type_consistency = qos_.type_consistency(); } diff --git a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp index 89547354da7..fed9eddfb7b 100644 --- a/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp +++ b/test/mock/dds/DomainParticipantImpl/fastdds/domain/DomainParticipantImpl.hpp @@ -719,7 +719,6 @@ class DomainParticipantImpl return false; } - protected: DomainId_t domain_id_; From d99f997aaa9f794ed998220dde227cdc3658424f Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 30 Jul 2024 07:36:55 +0200 Subject: [PATCH 36/37] Refs #21357. Update `versions.md`. Signed-off-by: Miguel Company --- versions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versions.md b/versions.md index 04e6d83f82c..1a78a62e6f6 100644 --- a/versions.md +++ b/versions.md @@ -16,6 +16,9 @@ Forthcoming * Several methods that were meant for internal use have been removed from public API * All public methods now have `snake_case` names * All public attributes now have `snake_case` names + * RTPSParticipant: + * Some methods changed to `snake_case`: `register_reader`, `register_writer`, `update_reader`, `update_writer`. + * Register methods take a `TopicDescription` instead of `TopicAttributes`. * Discovery callbacks refactor: * on_participant_discovery now receives a `ParticipantDiscoveryStatus` and a `ParticipantBuiltinTopicData` instead of a `ParticipantDiscoveryInfo` * on_data_reader_discovery now receives a `ReaderDiscoveryStatus` and a `SubscriptionBuiltinTopicData` instead of a `ReaderDiscoveryInfo` @@ -33,6 +36,7 @@ Forthcoming * RequesterAttributes * PublisherAttributes * SubscriberAttributes + * TopicAttributes * All discovery implementation related API * ProxyPool * Semaphore From 3a8a5a857876603734481a477c770834d6f70063 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 30 Jul 2024 08:02:49 +0200 Subject: [PATCH 37/37] Refs #21357. Apply suggestions on `versions.md`. Signed-off-by: Miguel Company --- versions.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versions.md b/versions.md index 1a78a62e6f6..682992bde1f 100644 --- a/versions.md +++ b/versions.md @@ -19,10 +19,14 @@ Forthcoming * RTPSParticipant: * Some methods changed to `snake_case`: `register_reader`, `register_writer`, `update_reader`, `update_writer`. * Register methods take a `TopicDescription` instead of `TopicAttributes`. + * Update methods no longer take `TopicAttributes`. * Discovery callbacks refactor: * on_participant_discovery now receives a `ParticipantDiscoveryStatus` and a `ParticipantBuiltinTopicData` instead of a `ParticipantDiscoveryInfo` * on_data_reader_discovery now receives a `ReaderDiscoveryStatus` and a `SubscriptionBuiltinTopicData` instead of a `ReaderDiscoveryInfo` * on_data_writer_discovery now receives a `WriterDiscoveryStatus` and a `PublicationBuiltinTopicData` instead of a `WriterDiscoveryInfo` +* New methods to get local discovery information: + * `DataWriter::get_publication_builtin_topic_data` + * `DataReader::get_subscription_builtin_topic_data` * Public API that is no longer public: * XML Parser API no longer public. * ReaderProxyData