From 830807342b6581cd67141df8d0b4e1397a4b47b7 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 11 Jun 2024 15:31:35 +0200 Subject: [PATCH] RTPS reader APIs refactor (#4875) * Refs #21082. Add `BaseReader` alias. Signed-off-by: Miguel Company * Refs #21082. Refactor on `StatefulReader`. Signed-off-by: Miguel Company * Refs #21082. Refactor on `StatelessReader`. Signed-off-by: Miguel Company * Refs #21082. Refactor on `ListenerTests`. Signed-off-by: Miguel Company * Refs #21082. Refactor on `MessageReceiver`. Signed-off-by: Miguel Company * Refs #21082. Refactor on `RTPSMessageGroup`. Signed-off-by: Miguel Company * Refs #21082. Refactor on `StatisticsReaderImpl`. Signed-off-by: Miguel Company * Refs #21082. Refactor on writers (intraprocess). Signed-off-by: Miguel Company * Refs #21082. Turn `BaseReader` into a class. Signed-off-by: Miguel Company * Refs #21082. Move `BaseReader` into its own private header. Signed-off-by: Miguel Company * Refs #21082. Move `StatisticsReaderImpl` to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Move `BaseReader` implementation to source file. Signed-off-by: Miguel Company * Refs #21082. Refactor on `DataSharingListener`. Signed-off-by: Miguel Company * Refs #21082. Move submessage processing to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Remove friend `MessageReceiver`. Signed-off-by: Miguel Company * Refs #21082. Remove friend `RTPSParticipantImpl`. Signed-off-by: Miguel Company * Refs #21082. Remove friend `EDP`. Signed-off-by: Miguel Company * Refs #21082. Remove friend `WLP`. Signed-off-by: Miguel Company * Refs #21082. Remove friend `ReaderHistory`. Signed-off-by: Miguel Company * Refs #21082. Use `BaseReader` on `forEachUserReader`. Signed-off-by: Miguel Company * Refs #21082. Move protected methods to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Move unread related methods to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Move destructor actions to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Move some protected fields to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Move data-sharing related fields to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Remove unnecessary forward declarations. Signed-off-by: Miguel Company * Refs #21082. Move `liveliness_changed_status_` to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Rearrange inline methods. Signed-off-by: Miguel Company * Refs #21082. Add `downcast` methods. Signed-off-by: Miguel Company * Refs #21082. Expose `assert_writer_liveliness`. Signed-off-by: Miguel Company * Refs #21082. Move history related methods to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Expose `isInCleanState`. Signed-off-by: Miguel Company * Refs #21082. Refactor `nextXxxCache` methods. Signed-off-by: Miguel Company * Refs #21082. Move sample access related methods to `BaseReader`. Signed-off-by: Miguel Company * Refs #21082. Minor improvements. Signed-off-by: Miguel Company * Refs #21082. Snake case for public methods. Signed-off-by: Miguel Company * Refs #21082. Use correct names for attributes. Signed-off-by: Miguel Company * Refs #21120. Uncrustify. Signed-off-by: Miguel Company * Refs #21120. Suggestions on MessageReceiver. Signed-off-by: Miguel Company * Refs #21120. Using alias for BaseReader. Signed-off-by: Miguel Company * Refs #21120. Snake case for `expects_inline_qos`. Signed-off-by: Miguel Company * Refs #21120. Correct name for `ReaderAttributes::liveliness_kind`. Signed-off-by: Miguel Company * Refs #21120. Refactor on ReaderAttributes. Signed-off-by: Miguel Company * Refs #21120. Getters on `RTPSReader` made const. Signed-off-by: Miguel Company * Refs #21120. Initialize `accept_messages_from_unkown_writers_` from new attribute. Signed-off-by: Miguel Company * Refs #21120. Method `init` moved to `BaseReader`. Signed-off-by: Miguel Company * Refs #21120. Naming style on BaseReader. Signed-off-by: Miguel Company * Refs #21120. Naming style on BaseReader (`reserve_cache` / `release_cache`). Signed-off-by: Miguel Company * Refs #21120. Naming style on BaseReader (submessages). Signed-off-by: Miguel Company * Refs #21120. Naming style on BaseReader (`find_cache_in_fragmented_process`). Signed-off-by: Miguel Company * Refs #21120. Move `find_cache_in_fragmented_process` to `StatefulReader`. Signed-off-by: Miguel Company * Refs #21120. Naming style on BaseReader (fields). Signed-off-by: Miguel Company * Refs #21120. Suggestions on RTPSReader. Signed-off-by: Miguel Company * Refs #21120. Remove `change_read_by_user` references. Signed-off-by: Miguel Company * Refs #21120. Made all API in `RTPSReader` pure virtual. Signed-off-by: Miguel Company * Refs #21120. Includes in `RTPSReader`. Signed-off-by: Miguel Company * Refs #21120. Declaration order on BaseReader. Signed-off-by: Miguel Company * Refs #21120. Refactor `persist_last_notified_nts`. Signed-off-by: Miguel Company * Refs #21120. Remove `onReaderMatched` overload. Signed-off-by: Miguel Company * Refs #21120. Rename to `on_reader_matched`. Signed-off-by: Miguel Company * Refs #21120. Rename to `on_new_cache_change_added`. Signed-off-by: Miguel Company * Refs #21120. Uncrustify. Signed-off-by: Miguel Company * Refs #21120. Refactor of mocks. Signed-off-by: Miguel Company * Refs #21120. Add StatefulReader unit test. Signed-off-by: Miguel Company * Refs #21120. Remove RTPS blackbox test. Signed-off-by: Miguel Company * Refs #21120. Uncrustify. Signed-off-by: Miguel Company * Refs #21120. Fix discovery server tests. Signed-off-by: Miguel Company * Refs #21120. Improve test `sample_lost_be_dw_be_dr_fragments`. Signed-off-by: Miguel Company * Refs #21120. Improve `find_cache_in_fragmented_process`. Signed-off-by: Miguel Company * Refs #21120. Doxygen motivated refactor. Signed-off-by: Miguel Company * Refs #21120. Refactor `reserve_cache`. Signed-off-by: Miguel Company * Refs #21120. Refactor `allow_unknown_writers`. Signed-off-by: Miguel Company * Refs #21120. Refactor `change_removed_by_history`. Signed-off-by: Miguel Company * Refs #21120. Improve `update_liveliness_changed_status`. Signed-off-by: Miguel Company * Refs #21120. More doxygen improvements. Signed-off-by: Miguel Company * Refs #21120. Remove `accept_messages_to_unknown_readers`. Signed-off-by: Miguel Company * Refs #21120. More doxygen improvements. Signed-off-by: Miguel Company * Refs #21120. Snake case for `ReaderTimes`. Signed-off-by: Miguel Company * Refs #21120. Update versions.md. Signed-off-by: Miguel Company --------- Signed-off-by: Miguel Company --- .../cpp/rtps/AsSocket/TestReaderSocket.cpp | 6 +- examples/cpp/rtps/AsSocket/TestReaderSocket.h | 2 +- .../rtps/Persistent/TestReaderPersistent.cpp | 4 +- .../rtps/Persistent/TestReaderPersistent.h | 9 +- .../rtps/Registered/TestReaderRegistered.cpp | 4 +- .../rtps/Registered/TestReaderRegistered.h | 9 +- .../dds/subscriber/qos/DataReaderQos.hpp | 8 +- .../rtps/attributes/ReaderAttributes.h | 56 +- include/fastdds/rtps/reader/RTPSReader.h | 461 ++++------------ include/fastdds/rtps/reader/ReaderListener.h | 23 +- resources/xsd/fastdds_profiles.xsd | 14 +- resources/xsd/fastdds_static_discovery.xsd | 2 +- src/cpp/CMakeLists.txt | 1 + .../type_lookup_service/TypeLookupManager.cpp | 2 +- .../TypeLookupReplyListener.cpp | 6 +- .../TypeLookupReplyListener.hpp | 2 +- .../TypeLookupRequestListener.cpp | 6 +- .../TypeLookupRequestListener.hpp | 2 +- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 20 +- src/cpp/fastdds/subscriber/DataReaderImpl.hpp | 9 +- .../DataReaderImpl/ReadTakeCommand.hpp | 5 +- .../subscriber/history/DataReaderHistory.cpp | 6 +- src/cpp/fastdds/utils/QosConverters.cpp | 2 +- .../rtps/DataSharing/DataSharingListener.cpp | 15 +- .../rtps/DataSharing/DataSharingListener.hpp | 21 +- src/cpp/rtps/RTPSDomain.cpp | 4 +- src/cpp/rtps/RTPSDomainImpl.hpp | 6 +- .../rtps/builtin/discovery/endpoint/EDP.cpp | 119 +--- src/cpp/rtps/builtin/discovery/endpoint/EDP.h | 7 - .../builtin/discovery/endpoint/EDPServer.cpp | 2 +- .../discovery/endpoint/EDPServerListeners.cpp | 37 +- .../discovery/endpoint/EDPServerListeners.hpp | 13 +- .../builtin/discovery/endpoint/EDPSimple.cpp | 9 +- .../discovery/endpoint/EDPSimpleListeners.cpp | 4 +- .../discovery/endpoint/EDPSimpleListeners.h | 4 +- .../builtin/discovery/participant/PDP.cpp | 2 +- .../discovery/participant/PDPClient.cpp | 11 +- .../discovery/participant/PDPListener.cpp | 2 +- .../discovery/participant/PDPListener.h | 4 +- .../discovery/participant/PDPServer.cpp | 39 +- .../participant/PDPServerListener.cpp | 4 +- .../participant/PDPServerListener.hpp | 2 +- src/cpp/rtps/builtin/liveliness/WLP.cpp | 38 +- src/cpp/rtps/builtin/liveliness/WLP.hpp | 15 +- .../rtps/builtin/liveliness/WLPListener.cpp | 4 +- src/cpp/rtps/builtin/liveliness/WLPListener.h | 2 +- src/cpp/rtps/history/ReaderHistory.cpp | 12 +- src/cpp/rtps/messages/MessageReceiver.cpp | 109 ++-- src/cpp/rtps/messages/MessageReceiver.h | 17 +- src/cpp/rtps/messages/RTPSMessageGroup.cpp | 9 +- .../rtps/participant/RTPSParticipantImpl.cpp | 17 +- .../rtps/participant/RTPSParticipantImpl.h | 19 +- src/cpp/rtps/reader/BaseReader.cpp | 517 ++++++++++++++++++ src/cpp/rtps/reader/BaseReader.hpp | 474 ++++++++++++++++ src/cpp/rtps/reader/RTPSReader.cpp | 422 +------------- .../rtps/reader/StatefulPersistentReader.cpp | 2 +- .../rtps/reader/StatefulPersistentReader.hpp | 2 +- src/cpp/rtps/reader/StatefulReader.cpp | 262 ++++----- src/cpp/rtps/reader/StatefulReader.hpp | 75 ++- .../rtps/reader/StatelessPersistentReader.cpp | 2 +- .../rtps/reader/StatelessPersistentReader.hpp | 2 +- src/cpp/rtps/reader/StatelessReader.cpp | 112 ++-- src/cpp/rtps/reader/StatelessReader.hpp | 56 +- src/cpp/rtps/reader/WriterProxy.cpp | 4 +- src/cpp/rtps/security/SecurityManager.cpp | 8 +- src/cpp/rtps/security/SecurityManager.h | 4 +- src/cpp/rtps/writer/ReaderLocator.cpp | 5 +- src/cpp/rtps/writer/StatefulWriter.cpp | 13 +- src/cpp/rtps/writer/StatelessWriter.cpp | 4 +- .../rtps/reader/StatisticsReaderImpl.cpp | 12 +- src/cpp/xmlparser/XMLElementParser.cpp | 18 +- src/cpp/xmlparser/XMLEndpointParser.cpp | 2 +- src/cpp/xmlparser/XMLParserCommon.cpp | 8 +- .../attributes/SubscriberAttributes.hpp | 2 +- ...PubSubWriterPersistence_static_disc.xml.in | 2 +- test/blackbox/PubSubWriter_static_disc.xml.in | 2 +- .../api/dds-pim/PubSubParticipant.hpp | 2 +- test/blackbox/api/dds-pim/PubSubReader.hpp | 10 +- .../api/dds-pim/PubSubWriterReader.hpp | 4 +- .../blackbox/common/BlackboxTestsVolatile.cpp | 2 +- .../common/DDSBlackboxTestsListeners.cpp | 9 +- .../DDSBlackboxTestsPersistenceGuid.cpp | 4 +- test/blackbox/common/RTPSAsSocketReader.hpp | 17 +- .../common/RTPSBlackboxTestsBasic.cpp | 28 - .../common/RTPSWithRegistrationReader.hpp | 15 +- .../rtps/Endpoint/fastdds/rtps/Endpoint.h | 10 +- .../rtps/RTPSDomain/fastdds/rtps/RTPSDomain.h | 12 +- .../rtps/participant/RTPSParticipantImpl.h | 5 +- .../fastdds/rtps/reader/RTPSReader.h | 160 ++---- .../RTPSReader/rtps/reader/BaseReader.hpp | 166 ++++++ .../rtps/reader/StatefulReader.hpp | 10 +- .../rtps/reader/StatelessReader.hpp | 9 +- test/realtime/UserThreadNonBlockedTest.cpp | 4 +- .../XMLTesterExample_profile.xml | 10 +- .../tools/xmlvalidation/all_profile.xml | 10 +- .../xmlvalidation/dataReader_profile.xml | 10 +- .../xmlvalidation/discovery_static_disc.xml | 4 +- .../profiles/test_xml_for_string_profile.xml | 20 +- .../dds/profiles/test_xml_profile.xml | 20 +- test/unittest/dds/publisher/CMakeLists.txt | 1 + test/unittest/dds/status/ListenerTests.cpp | 34 +- .../dds/subscriber/SubscriberTests.cpp | 16 +- .../rtps/history/ReaderHistoryTests.cpp | 10 +- test/unittest/rtps/reader/CMakeLists.txt | 267 ++++++++- .../rtps/reader/StatefulReaderTests.cpp | 126 +++++ .../rtps/reader/WriterProxyAcknackTests.cpp | 10 +- .../rtps/reader/WriterProxyStopTest.cpp | 2 +- .../unittest/rtps/reader/WriterProxyTests.cpp | 16 +- .../SecurityHandshakeProcessTests.cpp | 34 +- test/unittest/rtps/security/SecurityTests.cpp | 4 +- test/unittest/statistics/dds/CMakeLists.txt | 2 + .../statistics/rtps/RTPSStatisticsTests.cpp | 16 +- .../xmlparser/XMLElementParserTests.cpp | 10 +- .../xmlparser/XMLEndpointParserTests.cpp | 12 +- .../xmlparser/XMLProfileParserTests.cpp | 24 +- .../xmlparser/test_xml_deprecated.xml | 10 +- test/unittest/xmlparser/test_xml_profile.xml | 10 +- .../xmlparser/test_xml_profile_env_var.xml | 10 +- .../xmlparser/test_xml_rooted_deprecated.xml | 10 +- .../xmlparser/test_xml_rooted_profile.xml | 10 +- versions.md | 4 + 121 files changed, 2521 insertions(+), 1874 deletions(-) create mode 100644 src/cpp/rtps/reader/BaseReader.cpp create mode 100644 src/cpp/rtps/reader/BaseReader.hpp create mode 100644 test/mock/rtps/RTPSReader/rtps/reader/BaseReader.hpp create mode 100644 test/unittest/rtps/reader/StatefulReaderTests.cpp diff --git a/examples/cpp/rtps/AsSocket/TestReaderSocket.cpp b/examples/cpp/rtps/AsSocket/TestReaderSocket.cpp index 32f08e6f877..c42c61862da 100644 --- a/examples/cpp/rtps/AsSocket/TestReaderSocket.cpp +++ b/examples/cpp/rtps/AsSocket/TestReaderSocket.cpp @@ -71,8 +71,8 @@ bool TestReaderSocket::init( IPLocator::setIPv4(loc, ip); loc.port = static_cast(port); ratt.endpoint.multicastLocatorList.push_back(loc); + ratt.accept_messages_from_unkown_writers = true; mp_reader = RTPSDomain::createRTPSReader(mp_participant, ratt, mp_history, &m_listener); - mp_reader->enableMessagesFromUnkownWriters(true); if (mp_reader == nullptr) { return false; @@ -88,11 +88,11 @@ void TestReaderSocket::run() std::cin >> aux; } -void TestReaderSocket::MyListener::onNewCacheChangeAdded( +void TestReaderSocket::MyListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { printf("Received: %s\n", change->serializedPayload.data); - reader->getHistory()->remove_change((CacheChange_t*)change); + reader->get_history()->remove_change((CacheChange_t*)change); m_received++; } diff --git a/examples/cpp/rtps/AsSocket/TestReaderSocket.h b/examples/cpp/rtps/AsSocket/TestReaderSocket.h index 4fe2daefdd2..5acfc19ebba 100644 --- a/examples/cpp/rtps/AsSocket/TestReaderSocket.h +++ b/examples/cpp/rtps/AsSocket/TestReaderSocket.h @@ -65,7 +65,7 @@ class TestReaderSocket { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; uint32_t m_received; diff --git a/examples/cpp/rtps/Persistent/TestReaderPersistent.cpp b/examples/cpp/rtps/Persistent/TestReaderPersistent.cpp index 533ca73bc64..7f3c9b409da 100644 --- a/examples/cpp/rtps/Persistent/TestReaderPersistent.cpp +++ b/examples/cpp/rtps/Persistent/TestReaderPersistent.cpp @@ -101,11 +101,11 @@ void TestReaderPersistent::run() std::cin.ignore(); } -void TestReaderPersistent::MyListener::onNewCacheChangeAdded( +void TestReaderPersistent::MyListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { printf("Received: %s\n", change->serializedPayload.data); - reader->getHistory()->remove_change((CacheChange_t*)change); + reader->get_history()->remove_change((CacheChange_t*)change); n_received++; } diff --git a/examples/cpp/rtps/Persistent/TestReaderPersistent.h b/examples/cpp/rtps/Persistent/TestReaderPersistent.h index 82238981843..1f52314504c 100644 --- a/examples/cpp/rtps/Persistent/TestReaderPersistent.h +++ b/examples/cpp/rtps/Persistent/TestReaderPersistent.h @@ -58,12 +58,12 @@ class TestReaderPersistent { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; - void onReaderMatched( + void on_reader_matched( eprosima::fastrtps::rtps::RTPSReader*, - eprosima::fastrtps::rtps::MatchingInfo& info) override + const eprosima::fastrtps::rtps::MatchingInfo& info) override { if (info.status == eprosima::fastrtps::rtps::MATCHED_MATCHING) { @@ -74,9 +74,6 @@ class TestReaderPersistent uint32_t n_received; uint32_t n_matched; - private: - - using eprosima::fastrtps::rtps::ReaderListener::onReaderMatched; } m_listener; }; diff --git a/examples/cpp/rtps/Registered/TestReaderRegistered.cpp b/examples/cpp/rtps/Registered/TestReaderRegistered.cpp index e5cfb2ffd67..32f95f7b87d 100644 --- a/examples/cpp/rtps/Registered/TestReaderRegistered.cpp +++ b/examples/cpp/rtps/Registered/TestReaderRegistered.cpp @@ -93,11 +93,11 @@ void TestReaderRegistered::run() std::cin.ignore(); } -void TestReaderRegistered::MyListener::onNewCacheChangeAdded( +void TestReaderRegistered::MyListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { printf("Received: %s\n", change->serializedPayload.data); - reader->getHistory()->remove_change((CacheChange_t*)change); + reader->get_history()->remove_change((CacheChange_t*)change); n_received++; } diff --git a/examples/cpp/rtps/Registered/TestReaderRegistered.h b/examples/cpp/rtps/Registered/TestReaderRegistered.h index 9f96d49e14a..bd8f9da4e8b 100644 --- a/examples/cpp/rtps/Registered/TestReaderRegistered.h +++ b/examples/cpp/rtps/Registered/TestReaderRegistered.h @@ -59,12 +59,12 @@ class TestReaderRegistered { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; - void onReaderMatched( + void on_reader_matched( eprosima::fastrtps::rtps::RTPSReader*, - eprosima::fastrtps::rtps::MatchingInfo& info) override + const eprosima::fastrtps::rtps::MatchingInfo& info) override { if (info.status == eprosima::fastrtps::rtps::MATCHED_MATCHING) { @@ -75,9 +75,6 @@ class TestReaderRegistered uint32_t n_received; uint32_t n_matched; - private: - - using eprosima::fastrtps::rtps::ReaderListener::onReaderMatched; } m_listener; }; diff --git a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp index 41b43c49cec..06e6321c096 100644 --- a/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp +++ b/include/fastdds/dds/subscriber/qos/DataReaderQos.hpp @@ -703,9 +703,9 @@ class DataReaderQos } /** - * Getter for expectsInlineQos + * Getter for expects_inline_qos * - * @return expectsInlineQos + * @return expects_inline_qos */ FASTDDS_EXPORTED_API bool expects_inline_qos() const { @@ -713,9 +713,9 @@ class DataReaderQos } /** - * Setter for expectsInlineQos + * Setter for expects_inline_qos * - * @param new_value new value for the expectsInlineQos + * @param new_value new value for the expects_inline_qos */ FASTDDS_EXPORTED_API void expects_inline_qos( bool new_value) diff --git a/include/fastdds/rtps/attributes/ReaderAttributes.h b/include/fastdds/rtps/attributes/ReaderAttributes.h index 4c0d5e67f61..7336f1a03a6 100644 --- a/include/fastdds/rtps/attributes/ReaderAttributes.h +++ b/include/fastdds/rtps/attributes/ReaderAttributes.h @@ -38,27 +38,17 @@ class ReaderTimes { public: - ReaderTimes() - { - initialAcknackDelay.nanosec = 70 * 1000 * 1000; - heartbeatResponseDelay.nanosec = 5 * 1000 * 1000; - } - - virtual ~ReaderTimes() - { - } - bool operator ==( const ReaderTimes& b) const { - return (this->initialAcknackDelay == b.initialAcknackDelay) && - (this->heartbeatResponseDelay == b.heartbeatResponseDelay); + return (initial_acknack_delay == b.initial_acknack_delay) && + (heartbeat_response_delay == b.heartbeat_response_delay); } - //!Initial AckNack delay. Default value 70ms. - Duration_t initialAcknackDelay; - //!Delay to be applied when a HEARTBEAT message is received, default value 5ms. - Duration_t heartbeatResponseDelay; + //! Initial AckNack delay. Default value 70ms. + Duration_t initial_acknack_delay {0, 70 * 1000 * 1000}; + //! Delay to be applied when a HEARTBEAT message is received, default value 5ms. + Duration_t heartbeat_response_delay {0, 5 * 1000 * 1000}; }; /** @@ -70,43 +60,39 @@ class ReaderAttributes public: ReaderAttributes() - : liveliness_kind_(fastdds::dds::LivelinessQosPolicyKind::AUTOMATIC_LIVELINESS_QOS) - , liveliness_lease_duration(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS) - , expectsInlineQos(false) - , disable_positive_acks(false) { endpoint.endpointKind = READER; endpoint.durabilityKind = VOLATILE; endpoint.reliabilityKind = BEST_EFFORT; } - virtual ~ReaderAttributes() - { - } + //! Attributes of the associated endpoint. + EndpointAttributes endpoint {}; - //!Attributes of the associated endpoint. - EndpointAttributes endpoint; - - //!Times associated with this reader (only for stateful readers) - ReaderTimes times; + //! Times associated with this reader (only for stateful readers) + ReaderTimes times {}; //! Liveliness kind - fastdds::dds::LivelinessQosPolicyKind liveliness_kind_; + fastdds::dds::LivelinessQosPolicyKind liveliness_kind = + fastdds::dds::LivelinessQosPolicyKind::AUTOMATIC_LIVELINESS_QOS; //! Liveliness lease duration - Duration_t liveliness_lease_duration; + Duration_t liveliness_lease_duration {TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS}; - //!Indicates if the reader expects Inline qos, default value 0. - bool expectsInlineQos; + //! Indicates if the reader expects Inline qos, default value false. + bool expects_inline_qos = false; //! Disable positive ACKs - bool disable_positive_acks; + bool disable_positive_acks = false; + + //! Enable or disable the reception of messages from unknown writers. + bool accept_messages_from_unkown_writers = false; //! Define the allocation behaviour for matched-writer-dependent collections. - ResourceLimitedContainerConfig matched_writers_allocation; + ResourceLimitedContainerConfig matched_writers_allocation {}; //! Thread settings for the data-sharing listener thread - fastdds::rtps::ThreadSettings data_sharing_listener_thread; + fastdds::rtps::ThreadSettings data_sharing_listener_thread {}; }; } /* namespace rtps */ diff --git a/include/fastdds/rtps/reader/RTPSReader.h b/include/fastdds/rtps/reader/RTPSReader.h index 0a6de1de600..92c09bd8c8c 100644 --- a/include/fastdds/rtps/reader/RTPSReader.h +++ b/include/fastdds/rtps/reader/RTPSReader.h @@ -19,90 +19,57 @@ #ifndef _FASTDDS_RTPS_READER_RTPSREADER_H_ #define _FASTDDS_RTPS_READER_RTPSREADER_H_ -#include +#include +#include -#include +#include #include -#include +#include #include #include -#include #include #include #include +#include #include #include -#include namespace eprosima { namespace fastrtps { namespace rtps { // Forward declarations -class LivelinessManager; -class ReaderListener; -class WriterProxy; struct CacheChange_t; -struct ReaderHistoryState; +class ReaderListener; +class RTPSParticipantImpl; class WriterProxyData; -class IDataSharingListener; /** * Class RTPSReader, manages the reception of data from its matched writers. + * Needs to be constructed using the createRTPSReader method from the RTPSDomain. * @ingroup READER_MODULE */ -class RTPSReader - : public Endpoint - , public fastdds::statistics::StatisticsReaderImpl +class RTPSReader : public Endpoint { - friend class ReaderHistory; - friend class RTPSParticipantImpl; - friend class MessageReceiver; - friend class EDP; - friend class WLP; - -protected: - - RTPSReader( - RTPSParticipantImpl* pimpl, - const GUID_t& guid, - const ReaderAttributes& att, - ReaderHistory* hist, - ReaderListener* listen = nullptr); - - RTPSReader( - RTPSParticipantImpl* pimpl, - const GUID_t& guid, - const ReaderAttributes& att, - const std::shared_ptr& payload_pool, - ReaderHistory* hist, - ReaderListener* listen = nullptr); - - RTPSReader( - RTPSParticipantImpl* pimpl, - const GUID_t& guid, - const ReaderAttributes& att, - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - ReaderHistory* hist, - ReaderListener* listen = nullptr); - - virtual ~RTPSReader(); public: /** - * Add a matched writer represented by its attributes. - * @param wdata Attributes of the writer to add. + * @brief Add a matched writer represented by its attributes. + * + * @param wdata Discovery information regarding the writer to add. + * * @return True if correctly added. */ FASTDDS_EXPORTED_API virtual bool matched_writer_add( const WriterProxyData& wdata) = 0; /** - * Remove a writer represented by its attributes from the matched writers. - * @param writer_guid GUID of the writer to remove. - * @param removed_by_lease Whether the writer is being unmatched due to a participant drop. + * @brief Remove a writer from the matched writers. + * + * @param writer_guid GUID of the writer to remove. + * @param removed_by_lease Whether the writer is being unmatched due to a participant drop. + * * @return True if correctly removed. */ FASTDDS_EXPORTED_API virtual bool matched_writer_remove( @@ -110,238 +77,109 @@ class RTPSReader bool removed_by_lease = false) = 0; /** - * Tells us if a specific Writer is matched against this reader. - * @param writer_guid GUID of the writer to check. - * @return True if it is matched. + * @brief Check if a specific writer is matched against this reader. + * + * @param writer_guid GUID of the writer to check. + * + * @return True if the specified writer is matched with this reader. */ FASTDDS_EXPORTED_API virtual bool matched_writer_is_matched( const GUID_t& writer_guid) = 0; /** - * Processes a new DATA message. Previously the message must have been accepted by function acceptMsgDirectedTo. + * @brief Assert the liveliness of a matched writer. * - * @param change Pointer to the CacheChange_t. - * @return true if the reader accepts messages from the. + * @param writer GUID of the writer on which to assert liveliness. */ - FASTDDS_EXPORTED_API virtual bool processDataMsg( - CacheChange_t* change) = 0; + FASTDDS_EXPORTED_API virtual void assert_writer_liveliness( + const GUID_t& writer) = 0; /** - * Processes a new DATA FRAG message. + * @brief Check if this reader is in a clean state with all its matched writers. + * This will happen when the reader has received all samples announced by all its matched writers. * - * @param change Pointer to the CacheChange_t. - * @param sampleSize Size of the complete, assembled message. - * @param fragmentStartingNum Starting number of this particular message. - * @param fragmentsInSubmessage Number of fragments on this particular message. - * @return true if the reader accepts message. + * @return Whether the reader is in a clean state with all its matched writers. */ - FASTDDS_EXPORTED_API virtual bool processDataFragMsg( - CacheChange_t* change, - uint32_t sampleSize, - uint32_t fragmentStartingNum, - uint16_t fragmentsInSubmessage) = 0; + FASTDDS_EXPORTED_API virtual bool is_in_clean_state() = 0; /** - * Processes a new HEARTBEAT message. - * @param writerGUID - * @param hbCount - * @param firstSN - * @param lastSN - * @param finalFlag - * @param livelinessFlag - * @param origin_vendor_id - * @return true if the reader accepts messages from the. - */ - FASTDDS_EXPORTED_API virtual bool processHeartbeatMsg( - const GUID_t& writerGUID, - uint32_t hbCount, - const SequenceNumber_t& firstSN, - const SequenceNumber_t& lastSN, - bool finalFlag, - bool livelinessFlag, - fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0; - - /** - * Processes a new GAP message. - * @param writerGUID - * @param gapStart - * @param gapList - * @param origin_vendor_id - * @return true if the reader accepts messages from the. - */ - FASTDDS_EXPORTED_API virtual bool processGapMsg( - const GUID_t& writerGUID, - const SequenceNumber_t& gapStart, - const SequenceNumberSet_t& gapList, - fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0; - - /** - * Method to indicate the reader that some change has been removed due to HistoryQos requirements. - * @param change Pointer to the CacheChange_t. - * @param prox Pointer to the WriterProxy. - * @return True if correctly removed. - */ - FASTDDS_EXPORTED_API virtual bool change_removed_by_history( - CacheChange_t* change, - WriterProxy* prox = nullptr) = 0; - - /** - * Get the associated listener, secondary attached Listener in case it is of compound type + * @brief Get the associated listener. + * * @return Pointer to the associated reader listener. */ - FASTDDS_EXPORTED_API ReaderListener* getListener() const; + FASTDDS_EXPORTED_API virtual ReaderListener* get_listener() const = 0; /** - * Switch the ReaderListener kind for the Reader. - * If the RTPSReader does not belong to the built-in protocols it switches out the old one. - * If it belongs to the built-in protocols, it sets the new ReaderListener callbacks to be called after the - * built-in ReaderListener ones. - * @param target Pointed to ReaderLister to attach - * @return True is correctly set. + * @brief Change the listener associated to this reader. + * + * @param listener The new listener to associate to this reader. */ - FASTDDS_EXPORTED_API bool setListener( - ReaderListener* target); + FASTDDS_EXPORTED_API virtual void set_listener( + ReaderListener* listener) = 0; /** - * Reserve a CacheChange_t. - * @param change Pointer to pointer to the Cache. - * @param dataCdrSerializedSize Size of the Cache. - * @return True if correctly reserved. + * @return True if the reader expects Inline QoS. */ - FASTDDS_EXPORTED_API bool reserveCache( - CacheChange_t** change, - uint32_t dataCdrSerializedSize); + FASTDDS_EXPORTED_API virtual bool expects_inline_qos() const = 0; /** - * Release a cacheChange. + * @return a pointer to the associated History. */ - FASTDDS_EXPORTED_API void releaseCache( - CacheChange_t* change); + FASTDDS_EXPORTED_API virtual ReaderHistory* get_history() const = 0; /** - * Read the next unread CacheChange_t from the history - * @param change Pointer to pointer of CacheChange_t - * @param wp Pointer to pointer to the WriterProxy - * @return True if read. + * @return The content filter associated to this reader. */ - FASTDDS_EXPORTED_API virtual bool nextUnreadCache( - CacheChange_t** change, - WriterProxy** wp) = 0; + FASTDDS_EXPORTED_API virtual eprosima::fastdds::rtps::IReaderDataFilter* get_content_filter() const = 0; /** - * Get the next CacheChange_t from the history to take. - * @param change Pointer to pointer of CacheChange_t. - * @param wp Pointer to pointer to the WriterProxy. - * @return True if read. + * Set the content filter associated to this reader. + * + * @param filter Pointer to the content filter to associate to this reader. */ - FASTDDS_EXPORTED_API virtual bool nextUntakenCache( - CacheChange_t** change, - WriterProxy** wp) = 0; - - FASTDDS_EXPORTED_API bool wait_for_unread_cache( - const eprosima::fastrtps::Duration_t& timeout); - - FASTDDS_EXPORTED_API uint64_t get_unread_count() const; - - FASTDDS_EXPORTED_API uint64_t get_unread_count( - bool mark_as_read); + FASTDDS_EXPORTED_API virtual void set_content_filter( + eprosima::fastdds::rtps::IReaderDataFilter* filter) = 0; /** - * @return True if the reader expects Inline QOS. - */ - FASTDDS_EXPORTED_API inline bool expectsInlineQos() - { - return m_expectsInlineQos; - } - - //! Returns a pointer to the associated History. - FASTDDS_EXPORTED_API inline ReaderHistory* getHistory() - { - return mp_history; - } - - //! @return The content filter associated to this reader. - FASTDDS_EXPORTED_API eprosima::fastdds::rtps::IReaderDataFilter* get_content_filter() const - { - std::lock_guard guard(mp_mutex); - return data_filter_; - } - - //! Set the content filter associated to this reader. - //! @param filter Pointer to the content filter to associate to this reader. - FASTDDS_EXPORTED_API void set_content_filter( - eprosima::fastdds::rtps::IReaderDataFilter* filter) - { - std::lock_guard guard(mp_mutex); - data_filter_ = filter; - } - - /*! - * @brief Returns there is a clean state with all Writers. - * It occurs when the Reader received all samples sent by Writers. In other words, - * its WriterProxies are up to date. - * @return There is a clean state with all Writers. + * @brief Read the next unread CacheChange_t from the history. + * + * @return A pointer to the first unread CacheChange_t from the history. */ - virtual bool isInCleanState() = 0; - - //! The liveliness changed status struct as defined in the DDS - fastdds::dds::LivelinessChangedStatus liveliness_changed_status_; - - inline void enableMessagesFromUnkownWriters( - bool enable) - { - m_acceptMessagesFromUnkownWriters = enable; - } - - void setTrustedWriter( - const EntityId_t& writer) - { - m_acceptMessagesFromUnkownWriters = false; - m_trustedWriterEntityId = writer; - } + FASTDDS_EXPORTED_API virtual CacheChange_t* next_unread_cache() = 0; /** - * Assert the liveliness of a matched writer. - * @param writer GUID of the writer to assert. + * @brief Get the next CacheChange_t from the history to take. + * + * @return A pointer to the first CacheChange_t in the history. */ - virtual void assert_writer_liveliness( - const GUID_t& writer) = 0; + FASTDDS_EXPORTED_API virtual CacheChange_t* next_untaken_cache() = 0; /** - * Called just before a change is going to be deserialized. - * @param [in] change Pointer to the change being accessed. - * @param [out] wp Writer proxy the @c change belongs to. - * @param [out] is_future_change Whether the change is in the future (i.e. there are - * earlier unreceived changes from the same writer). + * Wait until there is an unread CacheChange_t in the history. + * + * @param timeout Maximum time to wait. * - * @return Whether the change is still valid or not. + * @return true if there is an unread CacheChange_t in the history. */ - virtual bool begin_sample_access_nts( - CacheChange_t* change, - WriterProxy*& wp, - bool& is_future_change) = 0; + FASTDDS_EXPORTED_API virtual bool wait_for_unread_cache( + const eprosima::fastrtps::Duration_t& timeout) = 0; /** - * Called after the change has been deserialized. - * @param [in] change Pointer to the change being accessed. - * @param [in] wp Writer proxy the @c change belongs to. - * @param [in] mark_as_read Whether the @c change should be marked as read or not. + * Get the number of unread CacheChange_t in the history. + * + * @return The number of unread CacheChange_t in the history. */ - virtual void end_sample_access_nts( - CacheChange_t* change, - WriterProxy*& wp, - bool mark_as_read) = 0; + FASTDDS_EXPORTED_API virtual uint64_t get_unread_count() const = 0; /** - * Called when the user has retrieved a change from the history. - * @param change Pointer to the change to ACK - * @param writer Writer proxy of the \c change. - * @param mark_as_read Whether the \c change should be marked as read or not + * Get the number of unread CacheChange_t in the history and optionally mark them as read. + * + * @param mark_as_read Whether to mark the unread CacheChange_t as read. + * + * @return The number of previously unread CacheChange_t in the history. */ - virtual void change_read_by_user( - CacheChange_t* change, - WriterProxy* writer, - bool mark_as_read = true) = 0; + FASTDDS_EXPORTED_API virtual uint64_t get_unread_count( + bool mark_as_read) = 0; /** * Checks whether the sample is still valid or is corrupted. @@ -354,15 +192,10 @@ class RTPSReader * * @return true if the sample is valid */ - FASTDDS_EXPORTED_API bool is_sample_valid( + FASTDDS_EXPORTED_API virtual bool is_sample_valid( const void* data, const GUID_t& writer, - const SequenceNumber_t& sn) const; - - const std::unique_ptr& datasharing_listener() const - { - return datasharing_listener_; - } + const SequenceNumber_t& sn) const = 0; #ifdef FASTDDS_STATISTICS @@ -371,24 +204,24 @@ class RTPSReader * @param listener * @return true if successfully added */ - FASTDDS_EXPORTED_API bool add_statistics_listener( - std::shared_ptr listener); + FASTDDS_EXPORTED_API virtual bool add_statistics_listener( + std::shared_ptr listener) = 0; /** * Remove a listener from receiving statistics backend callbacks * @param listener * @return true if successfully removed */ - FASTDDS_EXPORTED_API bool remove_statistics_listener( - std::shared_ptr listener); + FASTDDS_EXPORTED_API virtual bool remove_statistics_listener( + std::shared_ptr listener) = 0; /** * @brief Set the enabled statistics writers mask * * @param enabled_writers The new mask to set */ - FASTDDS_EXPORTED_API void set_enabled_statistics_writers_mask( - uint32_t enabled_writers); + FASTDDS_EXPORTED_API virtual void set_enabled_statistics_writers_mask( + uint32_t enabled_writers) = 0; /** * @brief Get the connection list of this reader @@ -403,134 +236,26 @@ class RTPSReader protected: - virtual bool may_remove_history_record( - bool removed_by_lease); - - /*! - * @brief Add a remote writer to the persistence_guid map - * @param guid GUID of the remote writer - * @param persistence_guid Persistence GUID of the remote writer - */ - void add_persistence_guid( - const GUID_t& guid, - const GUID_t& persistence_guid); - - /*! - * @brief Remove a remote writer from the persistence_guid map - * @param guid GUID of the remote writer - * @param persistence_guid Persistence GUID of the remote writer - * @param removed_by_lease Whether the GUIDs are being removed due to a participant drop. - */ - void remove_persistence_guid( - const GUID_t& guid, - const GUID_t& persistence_guid, - bool removed_by_lease); - - /*! - * @brief Get the last notified sequence for a RTPS guid - * @param guid The RTPS guid to query - * @return Last notified sequence number for input guid - * @remarks Takes persistence_guid into consideration - */ - SequenceNumber_t get_last_notified( - const GUID_t& guid); - - /*! - * @brief Update the last notified sequence for a RTPS guid - * @param guid The RTPS guid of the writer - * @param seq Max sequence number available on writer - * @return Previous value of last notified sequence number for input guid - * @remarks Takes persistence_guid into consideration - */ - SequenceNumber_t update_last_notified( + RTPSReader( + RTPSParticipantImpl* pimpl, const GUID_t& guid, - const SequenceNumber_t& seq); - - /*! - * @brief Set the last notified sequence for a persistence guid - * @param persistence_guid The persistence guid to update - * @param seq Sequence number to set for input guid - * @remarks Persistent readers will write to DB - */ - virtual void set_last_notified( - const GUID_t& persistence_guid, - const SequenceNumber_t& seq); - - /*! - * @brief Search if there is a CacheChange_t, giving SequenceNumber_t and writer GUID_t, - * waiting to be completed because it is fragmented. - * @param sequence_number SequenceNumber_t of the searched CacheChange_t. - * @param writer_guid writer GUID_t of the searched CacheChange_t. - * @param change If a CacheChange_t was found, this argument will fill with its pointer. - * In other case nullptr is returned. - * @param hint Iterator since the search will start. - * Used to improve the search. - * @return Iterator pointing to the position were CacheChange_t was found. - * It can be used to improve next search. - */ - History::const_iterator findCacheInFragmentedProcess( - const SequenceNumber_t& sequence_number, - const GUID_t& writer_guid, - CacheChange_t** change, - History::const_iterator hint) const; - - /** - * Creates the listener for the datasharing notifications - * - * @param limits Resource limits for the number of matched datasharing writers - */ - void create_datasharing_listener( - ResourceLimitedContainerConfig limits); - - bool is_datasharing_compatible_with( - const WriterProxyData& wdata); - - //!ReaderHistory - ReaderHistory* mp_history; - //!Listener - ReaderListener* mp_listener; - //!Accept msg to unknwon readers (default=true) - bool m_acceptMessagesToUnknownReaders; - //!Accept msg from unknwon writers (BE-true,RE-false) - bool m_acceptMessagesFromUnkownWriters; - //!Trusted writer (for Builtin) - EntityId_t m_trustedWriterEntityId; - //!Expects Inline Qos. - bool m_expectsInlineQos; - - //!ReaderHistoryState - ReaderHistoryState* history_state_; - - uint64_t total_unread_ = 0; - - TimedConditionVariable new_notification_cv_; - - //! The liveliness kind of this reader - LivelinessQosPolicyKind liveliness_kind_; - //! The liveliness lease duration of this reader - Duration_t liveliness_lease_duration_; + const ReaderAttributes& att, + ReaderHistory* hist); - //! Whether the writer is datasharing compatible or not - bool is_datasharing_compatible_ = false; - //! The listener for the datasharing notifications - std::unique_ptr datasharing_listener_; + ~RTPSReader(); - eprosima::fastdds::rtps::IReaderDataFilter* data_filter_ = nullptr; + /// ReaderHistory + ReaderHistory* history_; private: RTPSReader& operator =( const RTPSReader&) = delete; - void init( - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - const ReaderAttributes& att); - }; -} /* namespace rtps */ -} /* namespace fastrtps */ -} /* namespace eprosima */ +} // namespace rtps +} // namespace fastrtps +} // namespace eprosima #endif /* _FASTDDS_RTPS_READER_RTPSREADER_H_ */ diff --git a/include/fastdds/rtps/reader/ReaderListener.h b/include/fastdds/rtps/reader/ReaderListener.h index d579f93f78f..1ae490e952b 100644 --- a/include/fastdds/rtps/reader/ReaderListener.h +++ b/include/fastdds/rtps/reader/ReaderListener.h @@ -53,22 +53,9 @@ class FASTDDS_EXPORTED_API ReaderListener * @param reader Matching reader * @param info Matching information of the reader */ - virtual void onReaderMatched( + virtual void on_reader_matched( RTPSReader* reader, - MatchingInfo& info) - { - static_cast(reader); - static_cast(info); - } - - /** - * This method is invoked when a new reader matches - * @param reader Matching reader - * @param info Subscription matching information - */ - virtual void onReaderMatched( - RTPSReader* reader, - const fastdds::dds::SubscriptionMatchedStatus& info) + const MatchingInfo& info) { static_cast(reader); static_cast(info); @@ -80,9 +67,9 @@ class FASTDDS_EXPORTED_API ReaderListener * @param change Pointer to the CacheChange_t. This is a const pointer to const data * to indicate that the user should not dispose of this data himself. * To remove the data call the remove_change method of the ReaderHistory. - * reader->getHistory()->remove_change((CacheChange_t*)change). + * reader->get_history()->remove_change((CacheChange_t*)change). */ - virtual void onNewCacheChangeAdded( + virtual void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { @@ -181,7 +168,7 @@ class FASTDDS_EXPORTED_API ReaderListener * @param [in] last_sequence Sequence number of the last change made available. * It will always be greater or equal than @c first_sequence. * @param [out] should_notify_individual_changes Whether the individual changes should be notified by means of - * @c onNewCacheChangeAdded. + * @c on_new_cache_change_added. */ virtual void on_data_available( RTPSReader* reader, diff --git a/resources/xsd/fastdds_profiles.xsd b/resources/xsd/fastdds_profiles.xsd index 88473439623..ee7593eba44 100644 --- a/resources/xsd/fastdds_profiles.xsd +++ b/resources/xsd/fastdds_profiles.xsd @@ -282,7 +282,7 @@ ├ multicastLocatorList [0~1], ├ external_unicast_locators [0~1], ├ ignore_non_matching_locators [bool], - ├ expectsInlineQos [bool], + ├ expects_inline_qos [bool], ├ historyMemoryPolicy [0~1], ├ propertiesPolicy [0~1], ├ userDefinedID [int16], @@ -297,7 +297,7 @@ - + @@ -317,7 +317,7 @@ ├ multicastLocatorList [0~1], ├ external_unicast_locators [0~1], ├ ignore_non_matching_locators [bool], - ├ expectsInlineQos [bool], + ├ expects_inline_qos [bool], ├ historyMemoryPolicy [0~1], ├ propertiesPolicy [0~1], ├ userDefinedID [int16], @@ -906,12 +906,12 @@ + ├ initial_acknack_delay [durationType], + └ heartbeat_response_delay [durationType] --> - - + + diff --git a/resources/xsd/fastdds_static_discovery.xsd b/resources/xsd/fastdds_static_discovery.xsd index 2e79288c12a..fb4ec2ab9db 100644 --- a/resources/xsd/fastdds_static_discovery.xsd +++ b/resources/xsd/fastdds_static_discovery.xsd @@ -106,7 +106,7 @@ - + diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index a93a1c7a4e8..e28ff1e0694 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -174,6 +174,7 @@ set(${PROJECT_NAME}_source_files rtps/participant/RTPSParticipant.cpp rtps/participant/RTPSParticipantImpl.cpp rtps/persistence/PersistenceFactory.cpp + rtps/reader/BaseReader.cpp rtps/reader/reader_utils.cpp rtps/reader/RTPSReader.cpp rtps/reader/StatefulPersistentReader.cpp diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp index a01fdf690d6..c2d3d6b8765 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp @@ -533,7 +533,7 @@ bool TypeLookupManager::create_endpoints() ratt.endpoint.ignore_non_matching_locators = pattr.ignore_non_matching_locators; ratt.endpoint.remoteLocatorList = builtin_protocols_->m_initialPeersList; ratt.matched_writers_allocation = pattr.allocation.participants; - ratt.expectsInlineQos = true; + ratt.expects_inline_qos = true; ratt.endpoint.topicKind = fastrtps::rtps::NO_KEY; ratt.endpoint.reliabilityKind = fastrtps::rtps::RELIABLE; ratt.endpoint.durabilityKind = fastrtps::rtps::VOLATILE; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp index 327fdc5cefa..8c28c8d4dbf 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp @@ -271,7 +271,7 @@ void TypeLookupReplyListener::check_get_type_dependencies_reply( typelookup_manager_->remove_async_get_type_request(request_id); } -void TypeLookupReplyListener::onNewCacheChangeAdded( +void TypeLookupReplyListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { @@ -282,7 +282,7 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( { // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REPLY_READER, "Received data from a bad endpoint."); - reader->getHistory()->remove_change(change); + reader->get_history()->remove_change(change); return; } @@ -310,7 +310,7 @@ void TypeLookupReplyListener::onNewCacheChangeAdded( } // Remove the processed cache change from the history - reader->getHistory()->remove_change(change); + reader->get_history()->remove_change(change); } void TypeLookupReplyListener::onWriterChangeReceivedByAll( diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp index 316eb675c83..8ce5813232d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.hpp @@ -124,7 +124,7 @@ class TypeLookupReplyListener : public fastrtps::rtps::ReaderListener, public fa * @param reader The reader receiving the cache change. * @param change The cache change. */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp index 80cf9001e64..dd7251f8f90 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp @@ -416,7 +416,7 @@ void TypeLookupRequestListener::answer_request( typelookup_manager_->reply_type_.deleteData(reply); } -void TypeLookupRequestListener::onNewCacheChangeAdded( +void TypeLookupRequestListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const changeIN) { @@ -427,7 +427,7 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( { // Log a warning and remove the change from the history EPROSIMA_LOG_WARNING(TL_REQUEST_READER, "Received data from a bad endpoint."); - reader->getHistory()->remove_change(change); + reader->get_history()->remove_change(change); return; } @@ -445,7 +445,7 @@ void TypeLookupRequestListener::onNewCacheChangeAdded( } // Remove the processed cache change from the history - reader->getHistory()->remove_change(change); + reader->get_history()->remove_change(change); } void TypeLookupRequestListener::onWriterChangeReceivedByAll( diff --git a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp index 4529b5e246e..ccc87753a7d 100644 --- a/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp +++ b/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.hpp @@ -162,7 +162,7 @@ class TypeLookupRequestListener : public fastrtps::rtps::ReaderListener, public * @param reader The reader receiving the cache change. * @param change The cache change. */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index ea3737837ed..4633a1a9e14 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -177,9 +177,9 @@ ReturnCode_t DataReaderImpl::enable() att.endpoint.setUserDefinedID(qos_.endpoint().user_defined_id); att.times = qos_.reliable_reader_qos().times; att.liveliness_lease_duration = qos_.liveliness().lease_duration; - att.liveliness_kind_ = qos_.liveliness().kind; + att.liveliness_kind = qos_.liveliness().kind; att.matched_writers_allocation = qos_.reader_resource_limits().matched_publisher_allocation; - att.expectsInlineQos = qos_.expects_inline_qos(); + att.expects_inline_qos = qos_.expects_inline_qos(); att.disable_positive_acks = qos_.reliable_reader_qos().disable_positive_ACKs.enabled; att.data_sharing_listener_thread = qos_.data_sharing().data_sharing_listener_thread(); @@ -299,7 +299,7 @@ ReturnCode_t DataReaderImpl::enable() { EPROSIMA_LOG_ERROR(DATA_READER, "Could not register reader on discovery protocols"); - reader_->setListener(nullptr); + reader_->set_listener(nullptr); stop(); return RETCODE_ERROR; @@ -313,7 +313,7 @@ void DataReaderImpl::disable() set_listener(nullptr); if (reader_ != nullptr) { - reader_->setListener(nullptr); + reader_->set_listener(nullptr); } } @@ -939,9 +939,9 @@ void DataReaderImpl::InnerDataReaderListener::on_data_available( } } -void DataReaderImpl::InnerDataReaderListener::onReaderMatched( +void DataReaderImpl::InnerDataReaderListener::on_reader_matched( RTPSReader* /*reader*/, - const SubscriptionMatchedStatus& info) + const MatchingInfo& info) { data_reader_->update_subscription_matched_status(info); @@ -1158,9 +1158,9 @@ bool DataReaderImpl::on_new_cache_change_added( } void DataReaderImpl::update_subscription_matched_status( - const SubscriptionMatchedStatus& status) + const MatchingInfo& status) { - auto count_change = status.current_count_change; + auto count_change = status.status == MATCHED_MATCHING ? 1 : -1; subscription_matched_status_.current_count += count_change; subscription_matched_status_.current_count_change += count_change; if (count_change > 0) @@ -1168,11 +1168,11 @@ void DataReaderImpl::update_subscription_matched_status( subscription_matched_status_.total_count += count_change; subscription_matched_status_.total_count_change += count_change; } - subscription_matched_status_.last_publication_handle = status.last_publication_handle; + subscription_matched_status_.last_publication_handle = status.remoteEndpointGuid; if (count_change < 0) { - history_.writer_not_alive(iHandle2GUID(status.last_publication_handle)); + history_.writer_not_alive(status.remoteEndpointGuid); try_notify_read_conditions(); } } diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp index f3a006160ba..82e218837fd 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.hpp @@ -415,9 +415,9 @@ class DataReaderImpl { } - void onReaderMatched( + void on_reader_matched( fastrtps::rtps::RTPSReader* reader, - const SubscriptionMatchedStatus& info) override; + const fastrtps::rtps::MatchingInfo& info) override; void on_data_available( fastrtps::rtps::RTPSReader* reader, @@ -450,9 +450,6 @@ class DataReaderImpl DataReaderImpl* data_reader_; - private: - - using fastrtps::rtps::ReaderListener::onReaderMatched; } reader_listener_; @@ -575,7 +572,7 @@ class DataReaderImpl bool trigger_value); void update_subscription_matched_status( - const SubscriptionMatchedStatus& status); + const fastrtps::rtps::MatchingInfo& status); bool on_data_available( const fastrtps::rtps::GUID_t& writer_guid, diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp index d13487c7754..51090fd2e88 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl/ReadTakeCommand.hpp @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -119,7 +120,7 @@ struct ReadTakeCommand WriterProxy* wp = nullptr; bool is_future_change = false; bool remove_change = false; - if (reader_->begin_sample_access_nts(change, wp, is_future_change)) + if (rtps::BaseReader::downcast(reader_)->begin_sample_access_nts(change, wp, is_future_change)) { //Check if the payload is dirty remove_change = !check_datasharing_validity(change, data_values_.has_ownership()); @@ -146,7 +147,7 @@ struct ReadTakeCommand ReturnCode_t previous_return_value = return_value_; bool added = add_sample(*it, remove_change); history_.change_was_processed_nts(change, added); - reader_->end_sample_access_nts(change, wp, added); + rtps::BaseReader::downcast(reader_)->end_sample_access_nts(change, wp, added); // Check if the payload is dirty if (added && !check_datasharing_validity(change, data_values_.has_ownership())) diff --git a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp index d8455e497ee..bf0ccf56037 100644 --- a/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp +++ b/src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -361,9 +362,10 @@ bool DataReaderHistory::get_first_untaken_info( WriterProxy* wp = nullptr; bool is_future_change = false; - if (mp_reader->begin_sample_access_nts(instance_change, wp, is_future_change)) + auto base_reader = rtps::BaseReader::downcast(mp_reader); + if (base_reader->begin_sample_access_nts(instance_change, wp, is_future_change)) { - mp_reader->end_sample_access_nts(instance_change, wp, false); + base_reader->end_sample_access_nts(instance_change, wp, false); if (is_future_change) { continue; diff --git a/src/cpp/fastdds/utils/QosConverters.cpp b/src/cpp/fastdds/utils/QosConverters.cpp index 02fa3e84f60..05da8e46b20 100644 --- a/src/cpp/fastdds/utils/QosConverters.cpp +++ b/src/cpp/fastdds/utils/QosConverters.cpp @@ -88,7 +88,7 @@ void set_qos_from_attributes( { qos.reader_resource_limits().matched_publisher_allocation = attr.matched_publisher_allocation; qos.properties() = attr.properties; - qos.expects_inline_qos(attr.expectsInlineQos); + qos.expects_inline_qos(attr.expects_inline_qos); qos.endpoint().unicast_locator_list = attr.unicastLocatorList; qos.endpoint().multicast_locator_list = attr.multicastLocatorList; qos.endpoint().remote_locator_list = attr.remoteLocatorList; diff --git a/src/cpp/rtps/DataSharing/DataSharingListener.cpp b/src/cpp/rtps/DataSharing/DataSharingListener.cpp index 66c9a3aafa5..349fdd7e4f7 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.cpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.cpp @@ -17,7 +17,8 @@ */ #include -#include + +#include #include #include @@ -28,13 +29,15 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; +using ThreadSettings = fastdds::rtps::ThreadSettings; DataSharingListener::DataSharingListener( std::shared_ptr notification, const std::string& datasharing_pools_directory, - const fastdds::rtps::ThreadSettings& thr_config, + const ThreadSettings& thr_config, ResourceLimitedContainerConfig limits, - RTPSReader* reader) + BaseReader* reader) : notification_(notification) , is_running_(false) , reader_(reader) @@ -173,7 +176,7 @@ void DataSharingListener::process_new_data () { EPROSIMA_LOG_WARNING(RTPS_READER, "GAP (" << last_sequence + 1 << " - " << ch.sequenceNumber - 1 << ")" << " detected on datasharing writer " << pool->writer()); - reader_->processGapMsg(pool->writer(), last_sequence + 1, + reader_->process_gap_msg(pool->writer(), last_sequence + 1, SequenceNumberSet_t(ch.sequenceNumber), c_VendorId_eProsima); } @@ -182,14 +185,14 @@ void DataSharingListener::process_new_data () EPROSIMA_LOG_INFO(RTPS_READER, "First change with SN " << ch.sequenceNumber << " detected on datasharing writer " << pool->writer()); - reader_->processGapMsg(pool->writer(), SequenceNumber_t(0, 1), + reader_->process_gap_msg(pool->writer(), SequenceNumber_t(0, 1), SequenceNumberSet_t(ch.sequenceNumber), c_VendorId_eProsima); } EPROSIMA_LOG_INFO(RTPS_READER, "New data found on writer " << pool->writer() << " with SN " << ch.sequenceNumber); - if (reader_->processDataMsg(&ch)) + if (reader_->process_data_msg(&ch)) { pool->release_payload(ch); pool->advance_to_next_payload(); diff --git a/src/cpp/rtps/DataSharing/DataSharingListener.hpp b/src/cpp/rtps/DataSharing/DataSharingListener.hpp index 1333e97dc61..34f291cc953 100644 --- a/src/cpp/rtps/DataSharing/DataSharingListener.hpp +++ b/src/cpp/rtps/DataSharing/DataSharingListener.hpp @@ -33,14 +33,25 @@ #include namespace eprosima { + +namespace fastdds { +namespace rtps { + +class BaseReader; + +} // namespace rtps +} // namespace fastdds + namespace fastrtps { namespace rtps { -class RTPSReader; class DataSharingListener : public IDataSharingListener { + using BaseReader = fastdds::rtps::BaseReader; + using ThreadSettings = fastdds::rtps::ThreadSettings; + public: typedef DataSharingNotification::Notification Notification; @@ -49,9 +60,9 @@ class DataSharingListener : public IDataSharingListener DataSharingListener( std::shared_ptr notification, const std::string& datasharing_pools_directory, - const fastdds::rtps::ThreadSettings& thr_config, + const ThreadSettings& thr_config, ResourceLimitedContainerConfig limits, - RTPSReader* reader); + BaseReader* reader); virtual ~DataSharingListener(); @@ -114,12 +125,12 @@ class DataSharingListener : public IDataSharingListener std::shared_ptr notification_; std::atomic is_running_; - RTPSReader* reader_; + BaseReader* reader_; eprosima::thread listening_thread_; ResourceLimitedVector writer_pools_; std::atomic writer_pools_changed_; std::string datasharing_pools_directory_; - fastdds::rtps::ThreadSettings thread_config_; + ThreadSettings thread_config_; mutable std::mutex mutex_; }; diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 3aba710ba76..4a1845d2a35 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -53,6 +53,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + static void guid_prefix_create( uint32_t ID, GuidPrefix_t& guidP) @@ -778,7 +780,7 @@ RTPSParticipantImpl* RTPSDomainImpl::find_local_participant( return nullptr; } -RTPSReader* RTPSDomainImpl::find_local_reader( +BaseReader* RTPSDomainImpl::find_local_reader( const GUID_t& reader_guid) { auto instance = get_instance(); diff --git a/src/cpp/rtps/RTPSDomainImpl.hpp b/src/cpp/rtps/RTPSDomainImpl.hpp index 629af0aeef7..480d9dc9065 100644 --- a/src/cpp/rtps/RTPSDomainImpl.hpp +++ b/src/cpp/rtps/RTPSDomainImpl.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -44,6 +45,9 @@ namespace rtps { */ class RTPSDomainImpl { + + using BaseReader = fastdds::rtps::BaseReader; + public: typedef std::pair t_p_RTPSParticipant; @@ -174,7 +178,7 @@ class RTPSDomainImpl * * @returns A pointer to a local reader given its endpoint guid, or nullptr if not found. */ - static RTPSReader* find_local_reader( + static BaseReader* find_local_reader( const GUID_t& reader_guid); /** diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp index 7c6e07cda88..e20f5d74afe 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #if HAVE_SECURITY #include @@ -54,6 +55,7 @@ using namespace eprosima::fastrtps; using eprosima::fastdds::dds::PublicationMatchedStatus; using eprosima::fastdds::dds::SubscriptionMatchedStatus; using ParameterList = eprosima::fastdds::dds::ParameterList; +using BaseReader = eprosima::fastdds::rtps::BaseReader; namespace eprosima { namespace fastrtps { @@ -73,15 +75,10 @@ EDP::EDP( RTPSParticipantImpl* part) : mp_PDP(p) , mp_RTPSParticipant(part) - , reader_status_allocator_( - reader_map_helper::node_size, - reader_map_helper::min_pool_size( - part->getRTPSParticipantAttributes().allocation.total_readers().initial)) , writer_status_allocator_( writer_map_helper::node_size, writer_map_helper::min_pool_size( part->getRTPSParticipantAttributes().allocation.total_writers().initial)) - , reader_status_(reader_status_allocator_) , writer_status_(writer_status_allocator_) { } @@ -116,7 +113,7 @@ bool EDP::newLocalReaderProxyData( const auto& ratt = reader->getAttributes(); rpd->isAlive(true); - rpd->m_expectsInlineQos = reader->expectsInlineQos(); + rpd->m_expectsInlineQos = reader->expects_inline_qos(); rpd->guid(reader->getGuid()); rpd->key() = rpd->guid(); if (ratt.multicastLocatorList.empty() && ratt.unicastLocatorList.empty()) @@ -366,7 +363,7 @@ bool EDP::updatedLocalReader( rdata->content_filter().filter_expression = ""; } rdata->isAlive(true); - rdata->m_expectsInlineQos = reader->expectsInlineQos(); + rdata->m_expectsInlineQos = reader->expects_inline_qos(); if (att.auto_fill_type_information) { @@ -486,7 +483,7 @@ bool EDP::unpairWriterProxy( EPROSIMA_LOG_INFO(RTPS_EDP, writer_guid); - mp_RTPSParticipant->forEachUserReader([&, removed_by_lease](RTPSReader& r) -> bool + mp_RTPSParticipant->forEachUserReader([&, removed_by_lease](BaseReader& r) -> bool { if (r.matched_writer_remove(writer_guid, removed_by_lease)) { @@ -498,16 +495,12 @@ bool EDP::unpairWriterProxy( //MATCHED AND ADDED CORRECTLY: ReaderListener* listener = nullptr; - if (nullptr != (listener = r.getListener())) + if (nullptr != (listener = r.get_listener())) { MatchingInfo info; info.status = REMOVED_MATCHING; info.remoteEndpointGuid = writer_guid; - listener->onReaderMatched(&r, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(reader_guid, writer_guid, -1); - listener->onReaderMatched(&r, sub_info); + listener->on_reader_matched(&r, info); } } @@ -853,7 +846,7 @@ bool EDP::pairingReader( if (valid) { #if HAVE_SECURITY - if (!mp_RTPSParticipant->security_manager().discovered_writer(R->m_guid, (*pit)->m_guid, + if (!mp_RTPSParticipant->security_manager().discovered_writer(reader_guid, (*pit)->m_guid, *wdatait, R->getAttributes().security_attributes())) { EPROSIMA_LOG_ERROR(RTPS_EDP, "Security manager returns an error for reader " << reader_guid); @@ -862,28 +855,24 @@ bool EDP::pairingReader( if (R->matched_writer_add(*wdatait)) { EPROSIMA_LOG_INFO(RTPS_EDP_MATCH, - "WP:" << wdatait->guid() << " match R:" << R->getGuid() << ". RLoc:" << + "WP:" << wdatait->guid() << " match R:" << reader_guid << ". RLoc:" << wdatait->remote_locators()); //MATCHED AND ADDED CORRECTLY: - if (R->getListener() != nullptr) + if (R->get_listener() != nullptr) { MatchingInfo info; info.status = MATCHED_MATCHING; info.remoteEndpointGuid = writer_guid; - R->getListener()->onReaderMatched(R, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(reader_guid, writer_guid, 1); - R->getListener()->onReaderMatched(R, sub_info); + R->get_listener()->on_reader_matched(R, info); } } #endif // if HAVE_SECURITY } else { - if (no_match_reason.test(MatchingFailureMask::incompatible_qos) && R->getListener() != nullptr) + if (no_match_reason.test(MatchingFailureMask::incompatible_qos) && R->get_listener() != nullptr) { - R->getListener()->on_requested_incompatible_qos(R, incompatible_qos); + R->get_listener()->on_requested_incompatible_qos(R, incompatible_qos); } //EPROSIMA_LOG_INFO(RTPS_EDP,RTPS_CYAN<<"Valid Matching to writerProxy: "<m_guid<getListener() != nullptr) + if (R->get_listener() != nullptr) { MatchingInfo info; info.status = REMOVED_MATCHING; info.remoteEndpointGuid = writer_guid; - R->getListener()->onReaderMatched(R, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(reader_guid, writer_guid, -1); - R->getListener()->onReaderMatched(R, sub_info); + R->get_listener()->on_reader_matched(R, info); } } } @@ -1225,7 +1210,7 @@ bool EDP::pairing_writer_proxy_with_any_local_reader( EPROSIMA_LOG_INFO(RTPS_EDP, wdata->guid() << " in topic: \"" << wdata->topicName() << "\""); - mp_RTPSParticipant->forEachUserReader([&, wdata](RTPSReader& r) -> bool + mp_RTPSParticipant->forEachUserReader([&, wdata](BaseReader& r) -> bool { auto temp_reader_proxy_data = get_temporary_reader_proxies_pool().get(); GUID_t readerGUID = r.getGuid(); @@ -1254,25 +1239,21 @@ bool EDP::pairing_writer_proxy_with_any_local_reader( "WP:" << wdata->guid() << " match R:" << r.getGuid() << ". WLoc:" << wdata->remote_locators()); //MATCHED AND ADDED CORRECTLY: - if (r.getListener() != nullptr) + if (r.get_listener() != nullptr) { MatchingInfo info; info.status = MATCHED_MATCHING; info.remoteEndpointGuid = writer_guid; - r.getListener()->onReaderMatched(&r, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(readerGUID, writer_guid, 1); - r.getListener()->onReaderMatched(&r, sub_info); + r.get_listener()->on_reader_matched(&r, info); } } #endif // if HAVE_SECURITY } else { - if (no_match_reason.test(MatchingFailureMask::incompatible_qos) && r.getListener() != nullptr) + if (no_match_reason.test(MatchingFailureMask::incompatible_qos) && r.get_listener() != nullptr) { - r.getListener()->on_requested_incompatible_qos(&r, incompatible_qos); + r.get_listener()->on_requested_incompatible_qos(&r, incompatible_qos); } if (r.matched_writer_is_matched(writer_guid) @@ -1283,16 +1264,12 @@ bool EDP::pairing_writer_proxy_with_any_local_reader( writer_guid); #endif // if HAVE_SECURITY //MATCHED AND ADDED CORRECTLY: - if (r.getListener() != nullptr) + if (r.get_listener() != nullptr) { MatchingInfo info; info.status = REMOVED_MATCHING; info.remoteEndpointGuid = writer_guid; - r.getListener()->onReaderMatched(&r, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(readerGUID, writer_guid, -1); - r.getListener()->onReaderMatched(&r, sub_info); + r.get_listener()->on_reader_matched(&r, info); } } } @@ -1312,7 +1289,7 @@ bool EDP::pairing_writer_proxy_with_local_reader( { EPROSIMA_LOG_INFO(RTPS_EDP, wdata.guid() << " in topic: \"" << wdata.topicName() << "\""); - mp_RTPSParticipant->forEachUserReader([&](RTPSReader& r) -> bool + mp_RTPSParticipant->forEachUserReader([&](BaseReader& r) -> bool { GUID_t readerGUID = r.getGuid(); @@ -1342,9 +1319,9 @@ bool EDP::pairing_writer_proxy_with_local_reader( else { if (no_match_reason.test(MatchingFailureMask::incompatible_qos) && - r.getListener() != nullptr) + r.get_listener() != nullptr) { - r.getListener()->on_requested_incompatible_qos(&r, incompatible_qos); + r.get_listener()->on_requested_incompatible_qos(&r, incompatible_qos); } if (r.matched_writer_is_matched(writer_guid) @@ -1353,16 +1330,12 @@ bool EDP::pairing_writer_proxy_with_local_reader( mp_RTPSParticipant->security_manager().remove_writer(readerGUID, remote_participant_guid, writer_guid); //MATCHED AND ADDED CORRECTLY: - if (r.getListener() != nullptr) + if (r.get_listener() != nullptr) { MatchingInfo info; info.status = REMOVED_MATCHING; info.remoteEndpointGuid = writer_guid; - r.getListener()->onReaderMatched(&r, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(readerGUID, writer_guid, -1); - r.getListener()->onReaderMatched(&r, sub_info); + r.get_listener()->on_reader_matched(&r, info); } } } @@ -1384,7 +1357,7 @@ bool EDP::pairing_remote_writer_with_local_reader_after_security( bool matched = false; bool found = false; - mp_RTPSParticipant->forEachUserReader([&](RTPSReader& r) -> bool + mp_RTPSParticipant->forEachUserReader([&](BaseReader& r) -> bool { GUID_t readerGUID = r.getGuid(); @@ -1401,16 +1374,12 @@ bool EDP::pairing_remote_writer_with_local_reader_after_security( matched = true; //MATCHED AND ADDED CORRECTLY: - if (r.getListener() != nullptr) + if (r.get_listener() != nullptr) { MatchingInfo info; info.status = MATCHED_MATCHING; info.remoteEndpointGuid = writer_guid; - r.getListener()->onReaderMatched(&r, info); - - const SubscriptionMatchedStatus& sub_info = - update_subscription_matched_status(readerGUID, writer_guid, 1); - r.getListener()->onReaderMatched(&r, sub_info); + r.get_listener()->on_reader_matched(&r, info); } } @@ -1427,34 +1396,6 @@ bool EDP::pairing_remote_writer_with_local_reader_after_security( #endif // if HAVE_SECURITY -const SubscriptionMatchedStatus& EDP::update_subscription_matched_status( - const GUID_t& reader_guid, - const GUID_t& writer_guid, - int change) -{ - std::lock_guard _(*mp_PDP->getMutex()); - - SubscriptionMatchedStatus* status; - auto it = reader_status_.find(reader_guid); - if (it == reader_status_.end()) - { - auto pair = reader_status_.emplace(reader_guid, SubscriptionMatchedStatus{}); - status = &pair.first->second; - } - else - { - status = &it->second; - } - - status->current_count = change; - status->current_count_change = change; - status->total_count += change; - status->total_count_change += change; - status->last_publication_handle = writer_guid; - - return *status; -} - const fastdds::dds::PublicationMatchedStatus& EDP::update_publication_matched_status( const GUID_t& reader_guid, const GUID_t& writer_guid, diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h index 04931a9c5e0..ffdfa06d871 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDP.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDP.h @@ -345,11 +345,6 @@ class EDP } #endif // if HAVE_SECURITY - const fastdds::dds::SubscriptionMatchedStatus& update_subscription_matched_status( - const GUID_t& reader_guid, - const GUID_t& writer_guid, - int change); - const fastdds::dds::PublicationMatchedStatus& update_publication_matched_status( const GUID_t& reader_guid, const GUID_t& writer_guid, @@ -404,10 +399,8 @@ class EDP using pool_allocator_t = foonathan::memory::memory_pool; - pool_allocator_t reader_status_allocator_; pool_allocator_t writer_status_allocator_; - foonathan::memory::map reader_status_; foonathan::memory::map writer_status_; }; diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp index 3dccbc4d1ce..f29bd810395 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp @@ -496,7 +496,7 @@ bool EDPServer::process_and_release_change( if (nullptr != builtin_to_release.first) { - builtin_to_release.first->releaseCache(change); + builtin_to_release.first->release_cache(change); ret_val = true; } } diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp index 5334b682a90..a944daaca5b 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace eprosima { @@ -44,7 +45,7 @@ EDPServerPUBListener::EDPServerPUBListener( { } -void EDPServerPUBListener::onNewCacheChangeAdded( +void EDPServerPUBListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { @@ -63,8 +64,10 @@ void EDPServerPUBListener::onNewCacheChangeAdded( EPROSIMA_LOG_WARNING(RTPS_EDP_LISTENER, "Received change with no Key"); } + // Get BaseReader + BaseReader* base_reader = BaseReader::downcast(reader); // Get EDP publications' reader history - ReaderHistory* reader_history = reader->getHistory(); + ReaderHistory* reader_history = base_reader->get_history(); // Related_sample_identity could be lost in message delivered, so we set as sample_identity // An empty related_sample_identity could lead into an empty sample_identity when resending this msg @@ -82,11 +85,11 @@ void EDPServerPUBListener::onNewCacheChangeAdded( if (change->kind == ALIVE) { EndpointAddedCallback writer_added_callback = - std::bind(&EDPServerPUBListener::continue_with_writer, this, reader, change); + std::bind(&EDPServerPUBListener::continue_with_writer, this, base_reader, change); // Note: add_writer_from_change() removes the change from the EDP publications' reader history, but it does not // return it to the pool - add_writer_from_change(reader, reader_history, change, sedp_, false, writer_added_callback); + add_writer_from_change(base_reader, reader_history, change, sedp_, false, writer_added_callback); // DATA(w) case: Retrieve the topic after creating the WriterProxyData (in add_writer_from_change()). This way, not matter // whether the DATA(w) is a new one or an update, the WriterProxyData exists, and so the topic can be retrieved @@ -109,7 +112,7 @@ void EDPServerPUBListener::onNewCacheChangeAdded( // Removing change from history, not returning the change to the pool, since the ownership will be yielded to the database reader_history->remove_change(reader_history->find_change(change), false); - notify_discoverydatabase(topic_name, reader, change); + notify_discoverydatabase(topic_name, base_reader, change); } } @@ -131,7 +134,7 @@ std::string EDPServerPUBListener::get_writer_proxy_topic_name( void EDPServerPUBListener::notify_discoverydatabase( std::string topic_name, - RTPSReader* reader, + BaseReader* reader, CacheChange_t* change) { // Notify the DiscoveryDataBase if it is enabled already @@ -150,7 +153,7 @@ void EDPServerPUBListener::notify_discoverydatabase( else { // If the database doesn't take the ownership, then return the CacheChante_t to the pool. - reader->releaseCache(change); + reader->release_cache(change); } } @@ -161,7 +164,7 @@ void EDPServerPUBListener::notify_discoverydatabase( } void EDPServerPUBListener::continue_with_writer( - RTPSReader* reader, + BaseReader* reader, CacheChange_t* change) { std::string topic_name = get_writer_proxy_topic_name(iHandle2GUID(change->instanceHandle)); @@ -179,7 +182,7 @@ EDPServerSUBListener::EDPServerSUBListener( { } -void EDPServerSUBListener::onNewCacheChangeAdded( +void EDPServerSUBListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { @@ -210,18 +213,20 @@ void EDPServerSUBListener::onNewCacheChangeAdded( change->writer_info.previous = nullptr; change->writer_info.num_sent_submessages = 0; + // Get BaseReader + BaseReader* base_reader = BaseReader::downcast(reader); // Get EDP subscriptions' reader history - ReaderHistory* reader_history = reader->getHistory(); + ReaderHistory* reader_history = base_reader->get_history(); // DATA(r) case: new reader or updated information about an existing reader if (change->kind == ALIVE) { EndpointAddedCallback reader_added_callback = - std::bind(&EDPServerSUBListener::continue_with_reader, this, reader, change); + std::bind(&EDPServerSUBListener::continue_with_reader, this, base_reader, change); // Note: add_reader_from_change() removes the change from the EDP subscriptions' reader history, but it does not // return it to the pool - add_reader_from_change(reader, reader_history, change, sedp_, false, reader_added_callback); + add_reader_from_change(base_reader, reader_history, change, sedp_, false, reader_added_callback); // DATA(w) case: Retrieve the topic after creating the ReaderProxyData (in add_reader_from_change()). This way, not matter // whether the DATA(r) is a new one or an update, the ReaderProxyData exists, and so the topic can be retrieved @@ -246,7 +251,7 @@ void EDPServerSUBListener::onNewCacheChangeAdded( // the database reader_history->remove_change(reader_history->find_change(change), false); - notify_discoverydatabase(topic_name, reader, change); + notify_discoverydatabase(topic_name, base_reader, change); } } @@ -268,7 +273,7 @@ std::string EDPServerSUBListener::get_reader_proxy_topic_name( void EDPServerSUBListener::notify_discoverydatabase( std::string topic_name, - RTPSReader* reader, + BaseReader* reader, CacheChange_t* change) { // Notify the DiscoveryDataBase if it is enabled already @@ -287,7 +292,7 @@ void EDPServerSUBListener::notify_discoverydatabase( else { // If the database doesn't take the ownership, then return the CacheChante_t to the pool. - reader->releaseCache(change); + reader->release_cache(change); } } @@ -298,7 +303,7 @@ void EDPServerSUBListener::notify_discoverydatabase( } void EDPServerSUBListener::continue_with_reader( - RTPSReader* reader, + BaseReader* reader, CacheChange_t* change) { std::string topic_name = get_reader_proxy_topic_name(iHandle2GUID(change->instanceHandle)); diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp index 5dd370ec426..dfc1add7095 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.hpp @@ -38,6 +38,7 @@ namespace eprosima { namespace fastdds { namespace rtps { +class BaseReader; class PDPServer; class EDPServer; @@ -68,7 +69,7 @@ class EDPServerPUBListener : public fastrtps::rtps::EDPBasePUBListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; @@ -79,11 +80,11 @@ class EDPServerPUBListener : public fastrtps::rtps::EDPBasePUBListener void notify_discoverydatabase( std::string topic_name, - fastrtps::rtps::RTPSReader* reader, + BaseReader* reader, fastrtps::rtps::CacheChange_t* change); void continue_with_writer( - fastrtps::rtps::RTPSReader* reader, + BaseReader* reader, fastrtps::rtps::CacheChange_t* change); //!Pointer to the EDPServer @@ -114,7 +115,7 @@ class EDPServerSUBListener : public fastrtps::rtps::EDPBaseSUBListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; @@ -125,11 +126,11 @@ class EDPServerSUBListener : public fastrtps::rtps::EDPBaseSUBListener void notify_discoverydatabase( std::string topic_name, - fastrtps::rtps::RTPSReader* reader, + BaseReader* reader, fastrtps::rtps::CacheChange_t* change); void continue_with_reader( - fastrtps::rtps::RTPSReader* reader, + BaseReader* reader, fastrtps::rtps::CacheChange_t* change); //!Pointer to the EDPServer diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp index 8e18d9e8578..e1ee51b87e2 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -266,7 +267,7 @@ void EDPSimple::processPersistentData( CacheChange_t* change_to_add = nullptr; - if (!reader.first->reserveCache(&change_to_add, change->serializedPayload.length)) //Reserve a new cache from the corresponding cache pool + if (!reader.first->reserve_cache(change->serializedPayload.length, change_to_add)) //Reserve a new cache from the corresponding cache pool { EPROSIMA_LOG_ERROR(RTPS_EDP, "Problem reserving CacheChange in EDPServer reader"); return; @@ -278,7 +279,7 @@ void EDPSimple::processPersistentData( << change->serializedPayload.length << " bytes and max size in EDPServer reader" << " is " << change_to_add->serializedPayload.max_size); - reader.first->releaseCache(change_to_add); + reader.first->release_cache(change_to_add); return; } @@ -286,7 +287,7 @@ void EDPSimple::processPersistentData( { EPROSIMA_LOG_INFO(RTPS_EDP, "EDPServer couldn't process database data not add change " << change_to_add->sequenceNumber); - reader.first->releaseCache(change_to_add); + reader.first->release_cache(change_to_add); } // change_to_add would be released within change_received @@ -388,7 +389,7 @@ void EDPSimple::set_builtin_reader_attributes( attributes = mp_PDP->create_builtin_reader_attributes(); // Timings are configured using EDP default values - attributes.times.heartbeatResponseDelay = edp_heartbeat_response_delay; + attributes.times.heartbeat_response_delay = edp_heartbeat_response_delay; } void EDPSimple::set_builtin_writer_attributes( diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp index 4e7e2953492..36f29f24b6d 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp @@ -156,7 +156,7 @@ void EDPBasePUBListener::add_writer_from_change( } } -void EDPSimplePUBListener::onNewCacheChangeAdded( +void EDPSimplePUBListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { @@ -296,7 +296,7 @@ void EDPBaseSUBListener::add_reader_from_change( } } -void EDPSimpleSUBListener::onNewCacheChangeAdded( +void EDPSimpleSUBListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { diff --git a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h index 9c9c34b54ac..c520794f548 100644 --- a/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h +++ b/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.h @@ -134,7 +134,7 @@ class EDPSimplePUBListener : public EDPBasePUBListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; @@ -179,7 +179,7 @@ class EDPSimpleSUBListener : public EDPBaseSUBListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 5e8bd017811..235fefc2d89 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -1534,7 +1534,7 @@ ReaderAttributes PDP::create_builtin_reader_attributes() const attributes.endpoint.topicKind = WITH_KEY; // Built-in readers never expect inline qos - attributes.expectsInlineQos = false; + attributes.expects_inline_qos = false; return attributes; } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp index fcacb9ac2df..6fc9437b075 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -268,7 +269,7 @@ bool PDPClient::create_ds_pdp_best_effort_reader( endpoints.stateless_reader.history_.reset(new ReaderHistory(hatt)); ReaderAttributes ratt; - ratt.expectsInlineQos = false; + ratt.expects_inline_qos = false; ratt.endpoint.endpointKind = READER; ratt.endpoint.multicastLocatorList = mp_builtin->m_metatrafficMulticastLocatorList; ratt.endpoint.unicastLocatorList = mp_builtin->m_metatrafficUnicastLocatorList; @@ -337,7 +338,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints( endpoints.reader.history_.reset(new ReaderHistory(hatt)); ReaderAttributes ratt; - ratt.expectsInlineQos = false; + ratt.expects_inline_qos = false; ratt.endpoint.endpointKind = READER; ratt.endpoint.multicastLocatorList = mp_builtin->m_metatrafficMulticastLocatorList; ratt.endpoint.unicastLocatorList = mp_builtin->m_metatrafficUnicastLocatorList; @@ -346,7 +347,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints( ratt.endpoint.topicKind = WITH_KEY; ratt.endpoint.durabilityKind = TRANSIENT_LOCAL; ratt.endpoint.reliabilityKind = RELIABLE; - ratt.times.heartbeatResponseDelay = pdp_heartbeat_response_delay; + ratt.times.heartbeat_response_delay = pdp_heartbeat_response_delay; #if HAVE_SECURITY if (is_discovery_protected) { @@ -461,7 +462,7 @@ bool PDPClient::create_ds_pdp_reliable_endpoints( } else if (!is_discovery_protected) { - endpoints.reader.reader_->enableMessagesFromUnkownWriters(true); + BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers(); } #else if (!is_discovery_protected) @@ -699,7 +700,7 @@ bool PDPClient::is_all_servers_PDPdata_updated() // Assess all server DATA has been received auto endpoints = static_cast(builtin_endpoints_.get()); assert(endpoints->reader.reader_); - return endpoints->reader.reader_->isInCleanState(); + return endpoints->reader.reader_->is_in_clean_state(); } void PDPClient::announceParticipantState( diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index 7cb29a8f696..9f0c422c243 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -51,7 +51,7 @@ PDPListener::PDPListener( { } -void PDPListener::onNewCacheChangeAdded( +void PDPListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.h b/src/cpp/rtps/builtin/discovery/participant/PDPListener.h index ae103f56fc2..329549a6ac9 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.h @@ -55,7 +55,7 @@ class PDPListener : public ReaderListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; @@ -63,7 +63,7 @@ class PDPListener : public ReaderListener /** * Process an incoming DATA(p). - * This method is called from PDPListener::onNewCacheChangeAdded() when an alive DATA(p) is received. + * This method is called from PDPListener::on_new_cache_change_added() when an alive DATA(p) is received. * Both the reader lock and the PDP lock are held when this method is called. * * @param old_data Pointer to the ParticipantProxyData currently stored in the database. May be nullptr, for a diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp index 550d3b6e237..0eaed35dc02 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -277,7 +278,7 @@ bool PDPServer::create_ds_pdp_best_effort_reader( endpoints.stateless_reader.history_.reset(new ReaderHistory(hatt)); ReaderAttributes ratt; - ratt.expectsInlineQos = false; + ratt.expects_inline_qos = false; ratt.endpoint.endpointKind = READER; ratt.endpoint.multicastLocatorList = mp_builtin->m_metatrafficMulticastLocatorList; ratt.endpoint.unicastLocatorList = mp_builtin->m_metatrafficUnicastLocatorList; @@ -365,7 +366,7 @@ bool PDPServer::create_ds_pdp_reliable_endpoints( // PDP Reader Attributes ReaderAttributes ratt; - ratt.expectsInlineQos = false; + ratt.expects_inline_qos = false; ratt.endpoint.endpointKind = READER; ratt.endpoint.multicastLocatorList = mp_builtin->m_metatrafficMulticastLocatorList; ratt.endpoint.unicastLocatorList = mp_builtin->m_metatrafficUnicastLocatorList; @@ -375,7 +376,7 @@ bool PDPServer::create_ds_pdp_reliable_endpoints( // change depending of backup mode ratt.endpoint.durabilityKind = durability_; ratt.endpoint.reliabilityKind = RELIABLE; - ratt.times.heartbeatResponseDelay = pdp_heartbeat_response_delay; + ratt.times.heartbeat_response_delay = pdp_heartbeat_response_delay; #if HAVE_SECURITY if (secure) { @@ -407,7 +408,7 @@ bool PDPServer::create_ds_pdp_reliable_endpoints( endpoints.reader.reader_ = dynamic_cast(reader); // Enable unknown clients to reach this reader - reader->enableMessagesFromUnkownWriters(true); + BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers(); #if HAVE_SECURITY mp_RTPSParticipant->set_endpoint_rtps_protection_supports(reader, false); @@ -1051,7 +1052,7 @@ bool PDPServer::remove_remote_participant( // TODO check in standard if DROP payload is always 0 // We create the drop from Reader to make release simplier - endpoints->reader.reader_->reserveCache(&pC, mp_builtin->m_att.writerPayloadSize); + endpoints->reader.reader_->reserve_cache(mp_builtin->m_att.writerPayloadSize, pC); // We must create the corresponding DATA(p[UD]) if (nullptr != pC) @@ -1084,7 +1085,7 @@ bool PDPServer::remove_remote_participant( else { // if the database doesn't take the ownership remove - endpoints->reader.reader_->releaseCache(pC); + endpoints->reader.reader_->release_cache(pC); } } } @@ -1431,7 +1432,7 @@ void PDPServer::process_changes_release_( endpoints->writer.history_.get(), ch, false); - endpoints->reader.reader_->releaseCache(ch); + endpoints->reader.reader_->release_cache(ch); } else { @@ -1761,7 +1762,7 @@ bool PDPServer::process_backup_discovery_database_restore( std::istringstream(it.value()["change"]["sample_identity"].get()) >> sample_identity_aux; // Reserve memory for new change. There will not be changes from own server - if (!endpoints->reader.reader_->reserveCache(&change_aux, length)) + if (!endpoints->reader.reader_->reserve_cache(length, change_aux)) { EPROSIMA_LOG_ERROR(RTPS_PDP_SERVER, "Error creating CacheChange"); // TODO release changes and exit @@ -1782,7 +1783,7 @@ bool PDPServer::process_backup_discovery_database_restore( { change_aux->writerGUID = change_aux->write_params.sample_identity().writer_guid(); change_aux->sequenceNumber = change_aux->write_params.sample_identity().sequence_number(); - builtin_endpoints_->main_listener()->onNewCacheChangeAdded(endpoints->reader.reader_, change_aux); + builtin_endpoints_->main_listener()->on_new_cache_change_added(endpoints->reader.reader_, change_aux); } } @@ -1800,7 +1801,7 @@ bool PDPServer::process_backup_discovery_database_restore( else { // Reserve memory for new change. There will not be changes from own server - if (!edp->publications_reader_.first->reserveCache(&change_aux, length)) + if (!edp->publications_reader_.first->reserve_cache(length, change_aux)) { EPROSIMA_LOG_ERROR(RTPS_PDP_SERVER, "Error creating CacheChange"); // TODO release changes and exit @@ -1822,7 +1823,7 @@ bool PDPServer::process_backup_discovery_database_restore( && change_aux->kind == fastrtps::rtps::ALIVE && it.value()["topic"] != discovery_db().virtual_topic()) { - edp_pub_listener->onNewCacheChangeAdded(edp->publications_reader_.first, change_aux); + edp_pub_listener->on_new_cache_change_added(edp->publications_reader_.first, change_aux); } } @@ -1839,7 +1840,7 @@ bool PDPServer::process_backup_discovery_database_restore( else { // Reserve memory for new change. There will not be changes from own server - if (!edp->subscriptions_reader_.first->reserveCache(&change_aux, length)) + if (!edp->subscriptions_reader_.first->reserve_cache(length, change_aux)) { EPROSIMA_LOG_ERROR(RTPS_PDP_SERVER, "Error creating CacheChange"); // TODO release changes and exit @@ -1858,7 +1859,7 @@ bool PDPServer::process_backup_discovery_database_restore( && change_aux->kind == fastrtps::rtps::ALIVE && it.value()["topic"] != discovery_db().virtual_topic()) { - edp_sub_listener->onNewCacheChangeAdded(edp->subscriptions_reader_.first, change_aux); + edp_sub_listener->on_new_cache_change_added(edp->subscriptions_reader_.first, change_aux); } } @@ -1919,7 +1920,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // mp_listener->onNewCacheChangeAdded(endpoints->reader.reader_, change_aux); + // listener_->on_new_cache_change_added(endpoints->reader.reader_, change_aux); // } // } @@ -1933,7 +1934,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // edp_pub_listener->onNewCacheChangeAdded(edp->publications_reader_.first, change_aux); + // edp_pub_listener->on_new_cache_change_added(edp->publications_reader_.first, change_aux); // } // } // else if (discovery_db_.is_reader(iHandle2GUID(instance_handle_aux))) @@ -1946,7 +1947,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // edp_sub_listener->onNewCacheChangeAdded(edp->subscriptions_reader_.first, change_aux); + // edp_sub_listener->on_new_cache_change_added(edp->subscriptions_reader_.first, change_aux); // } // } // } @@ -1963,7 +1964,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // mp_listener->onNewCacheChangeAdded(endpoints->reader.reader_, change_aux); + // listener_->on_new_cache_change_added(endpoints->reader.reader_, change_aux); // } // } @@ -1977,7 +1978,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // edp_pub_listener->onNewCacheChangeAdded(edp->publications_reader_.first, change_aux); + // edp_pub_listener->on_new_cache_change_added(edp->publications_reader_.first, change_aux); // } // } // else if (discovery_db_.is_reader(iHandle2GUID(instance_handle_aux))) @@ -1990,7 +1991,7 @@ bool PDPServer::process_backup_restore_queue( // else // { // ddb::from_json(json_change, *change_aux); - // edp_sub_listener->onNewCacheChangeAdded(edp->subscriptions_reader_.first, change_aux); + // edp_sub_listener->on_new_cache_change_added(edp->subscriptions_reader_.first, change_aux); // } // } // } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp index 2b9e7abbe93..44993dbc7e0 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp @@ -50,7 +50,7 @@ PDPServer* PDPServerListener::pdp_server() return static_cast(parent_pdp_); } -void PDPServerListener::onNewCacheChangeAdded( +void PDPServerListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change_in) { @@ -287,7 +287,7 @@ void PDPServerListener::onNewCacheChangeAdded( else { // If the database doesn't take the ownership, then return the CacheChante_t to the pool. - pdp_reader->releaseCache(change.release()); + pdp_reader->release_cache(change.release()); } } diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.hpp b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.hpp index b0f96268240..d3a83a181fa 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.hpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.hpp @@ -55,7 +55,7 @@ class PDPServerListener : public fastrtps::rtps::PDPListener * @param reader * @param change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( fastrtps::rtps::RTPSReader* reader, const fastrtps::rtps::CacheChange_t* const change) override; }; diff --git a/src/cpp/rtps/builtin/liveliness/WLP.cpp b/src/cpp/rtps/builtin/liveliness/WLP.cpp index 57a1bb7d708..39b9fa67090 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + static void set_builtin_reader_history_attributes( HistoryAttributes& hatt, const ResourceLimitedContainerConfig& allocation, @@ -294,7 +297,7 @@ bool WLP::createEndpoints() ratt.endpoint.topicKind = WITH_KEY; ratt.endpoint.durabilityKind = TRANSIENT_LOCAL; ratt.endpoint.reliabilityKind = RELIABLE; - ratt.expectsInlineQos = true; + ratt.expects_inline_qos = true; ratt.endpoint.unicastLocatorList = mp_builtinProtocols->m_metatrafficUnicastLocatorList; ratt.endpoint.multicastLocatorList = mp_builtinProtocols->m_metatrafficMulticastLocatorList; ratt.endpoint.external_unicast_locators = mp_builtinProtocols->m_att.metatraffic_external_unicast_locators; @@ -401,7 +404,7 @@ bool WLP::createSecureEndpoints() ratt.endpoint.topicKind = WITH_KEY; ratt.endpoint.durabilityKind = TRANSIENT_LOCAL; ratt.endpoint.reliabilityKind = RELIABLE; - ratt.expectsInlineQos = true; + ratt.expects_inline_qos = true; ratt.endpoint.unicastLocatorList = mp_builtinProtocols->m_metatrafficUnicastLocatorList; ratt.endpoint.multicastLocatorList = mp_builtinProtocols->m_metatrafficMulticastLocatorList; ratt.endpoint.external_unicast_locators = mp_builtinProtocols->m_att.metatraffic_external_unicast_locators; @@ -829,6 +832,8 @@ bool WLP::add_local_reader( RTPSReader* reader, const fastdds::dds::ReaderQos& rqos) { + auto base_reader = BaseReader::downcast(reader); + std::lock_guard guard(*mp_builtinProtocols->mp_PDP->getMutex()); if (rqos.m_liveliness.kind == AUTOMATIC_LIVELINESS_QOS) @@ -836,7 +841,7 @@ bool WLP::add_local_reader( automatic_readers_ = true; } - readers_.push_back(reader); + readers_.push_back(base_reader); return true; } @@ -844,12 +849,13 @@ bool WLP::add_local_reader( bool WLP::remove_local_reader( RTPSReader* reader) { + auto base_reader = BaseReader::downcast(reader); std::lock_guard guard(*mp_builtinProtocols->mp_PDP->getMutex()); auto it = std::find( readers_.begin(), readers_.end(), - reader); + base_reader); if (it != readers_.end()) { readers_.erase(it); @@ -1074,10 +1080,10 @@ void WLP::sub_liveliness_changed( { // Writer with given guid lost liveliness, check which readers were matched and inform them - for (RTPSReader* reader : readers_) + for (BaseReader* reader : readers_) { - if (reader->liveliness_kind_ == kind && - reader->liveliness_lease_duration_ == lease_duration) + if (reader->liveliness_kind() == kind && + reader->liveliness_lease_duration() == lease_duration) { if (reader->matched_writer_is_matched(writer)) { @@ -1093,25 +1099,11 @@ void WLP::sub_liveliness_changed( void WLP::update_liveliness_changed_status( GUID_t writer, - RTPSReader* reader, + BaseReader* reader, int32_t alive_change, int32_t not_alive_change) { - std::lock_guard lock(reader->getMutex()); - - reader->liveliness_changed_status_.alive_count += alive_change; - reader->liveliness_changed_status_.alive_count_change += alive_change; - reader->liveliness_changed_status_.not_alive_count += not_alive_change; - reader->liveliness_changed_status_.not_alive_count_change += not_alive_change; - reader->liveliness_changed_status_.last_publication_handle = writer; - - if (reader->getListener() != nullptr) - { - reader->getListener()->on_liveliness_changed(reader, reader->liveliness_changed_status_); - - reader->liveliness_changed_status_.alive_count_change = 0; - reader->liveliness_changed_status_.not_alive_count_change = 0; - } + reader->update_liveliness_changed_status(writer, alive_change, not_alive_change); } } /* namespace rtps */ diff --git a/src/cpp/rtps/builtin/liveliness/WLP.hpp b/src/cpp/rtps/builtin/liveliness/WLP.hpp index 718394b856f..d5ffd4a59f4 100644 --- a/src/cpp/rtps/builtin/liveliness/WLP.hpp +++ b/src/cpp/rtps/builtin/liveliness/WLP.hpp @@ -33,6 +33,15 @@ #include namespace eprosima { + +namespace fastdds { +namespace rtps { + +class BaseReader; + +} // namespace rtps +} // namespace fastdds + namespace fastrtps { namespace rtps { @@ -62,6 +71,8 @@ class WLP friend class StatefulReader; friend class StatelessReader; + using BaseReader = fastdds::rtps::BaseReader; + public: /** @@ -206,7 +217,7 @@ class WLP std::vector manual_by_topic_writers_; //! List of readers - std::vector readers_; + std::vector readers_; //! A boolean indicating that there is at least one reader requesting automatic liveliness bool automatic_readers_; @@ -257,7 +268,7 @@ class WLP */ void update_liveliness_changed_status( GUID_t writer, - RTPSReader* reader, + BaseReader* reader, int32_t alive_change, int32_t not_alive_change); diff --git a/src/cpp/rtps/builtin/liveliness/WLPListener.cpp b/src/cpp/rtps/builtin/liveliness/WLPListener.cpp index 15092fb9282..df6df7c69ec 100644 --- a/src/cpp/rtps/builtin/liveliness/WLPListener.cpp +++ b/src/cpp/rtps/builtin/liveliness/WLPListener.cpp @@ -54,7 +54,7 @@ WLPListener::~WLPListener() { } -void WLPListener::onNewCacheChangeAdded( +void WLPListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const changeIN) { @@ -69,7 +69,7 @@ void WLPListener::onNewCacheChangeAdded( return; } //Check the serializedPayload: - auto history = reader->getHistory(); + auto history = reader->get_history(); for (auto ch = history->changesBegin(); ch != history->changesEnd(); ++ch) { if ((*ch)->instanceHandle == change->instanceHandle && (*ch)->sequenceNumber < change->sequenceNumber) diff --git a/src/cpp/rtps/builtin/liveliness/WLPListener.h b/src/cpp/rtps/builtin/liveliness/WLPListener.h index b21e1170316..bc25d32fb7f 100644 --- a/src/cpp/rtps/builtin/liveliness/WLPListener.h +++ b/src/cpp/rtps/builtin/liveliness/WLPListener.h @@ -60,7 +60,7 @@ class WLPListener : public ReaderListener * @param reader The reader receiving the cache change * @param change The cache change */ - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; diff --git a/src/cpp/rtps/history/ReaderHistory.cpp b/src/cpp/rtps/history/ReaderHistory.cpp index e39a7483c28..4650b35965e 100644 --- a/src/cpp/rtps/history/ReaderHistory.cpp +++ b/src/cpp/rtps/history/ReaderHistory.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -33,6 +34,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + ReaderHistory::ReaderHistory( const HistoryAttributes& att) : History(att) @@ -148,10 +151,11 @@ History::iterator ReaderHistory::remove_change_nts( auto ret_val = m_changes.erase(removal); m_isHistoryFull = false; - mp_reader->change_removed_by_history(change); + auto base_reader = BaseReader::downcast(mp_reader); + base_reader->change_removed_by_history(change); if (release) { - mp_reader->releaseCache(change); + base_reader->release_cache(change); } return ret_val; @@ -256,13 +260,13 @@ bool ReaderHistory::do_reserve_cache( CacheChange_t** change, uint32_t size) { - return mp_reader->reserveCache(change, size); + return BaseReader::downcast(mp_reader)->reserve_cache(size, *change); } void ReaderHistory::do_release_cache( CacheChange_t* ch) { - mp_reader->releaseCache(ch); + BaseReader::downcast(mp_reader)->release_cache(ch); } } /* namespace rtps */ diff --git a/src/cpp/rtps/messages/MessageReceiver.cpp b/src/cpp/rtps/messages/MessageReceiver.cpp index aab960c7ac5..6de8d6a2a8e 100644 --- a/src/cpp/rtps/messages/MessageReceiver.cpp +++ b/src/cpp/rtps/messages/MessageReceiver.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -45,6 +46,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + MessageReceiver::MessageReceiver( RTPSParticipantImpl* participant, uint32_t rec_buffer_size) @@ -122,7 +125,7 @@ void MessageReceiver::process_data_message_with_security( CacheChange_t& change, bool was_decoded) { - auto process_message = [was_decoded, &change, this](RTPSReader* reader) + auto process_message = [was_decoded, &change, this](BaseReader* reader) { if (!was_decoded && reader->getAttributes().security_attributes().is_submessage_protected) { @@ -131,7 +134,7 @@ void MessageReceiver::process_data_message_with_security( if (!reader->getAttributes().security_attributes().is_payload_protected) { - reader->processDataMsg(&change); + reader->process_data_msg(&change); return; } @@ -150,7 +153,7 @@ void MessageReceiver::process_data_message_with_security( std::swap(change.serializedPayload.length, crypto_payload_.length); SerializedPayload_t original_payload = change.serializedPayload; - reader->processDataMsg(&change); + reader->process_data_msg(&change); IPayloadPool* payload_pool = change.payload_owner(); if (payload_pool) { @@ -174,7 +177,7 @@ void MessageReceiver::process_data_fragment_message_with_security( bool was_decoded) { auto process_message = [was_decoded, &change, sample_size, fragment_starting_num, fragments_in_submessage, this]( - RTPSReader* reader) + BaseReader* reader) { if (!was_decoded && reader->getAttributes().security_attributes().is_submessage_protected) { @@ -183,7 +186,7 @@ void MessageReceiver::process_data_fragment_message_with_security( if (!reader->getAttributes().security_attributes().is_payload_protected) { - reader->processDataFragMsg(&change, sample_size, fragment_starting_num, fragments_in_submessage); + reader->process_data_frag_msg(&change, sample_size, fragment_starting_num, fragments_in_submessage); return; } @@ -200,7 +203,7 @@ void MessageReceiver::process_data_fragment_message_with_security( std::swap(change.serializedPayload.data, crypto_payload_.data); std::swap(change.serializedPayload.length, crypto_payload_.length); - reader->processDataFragMsg(&change, sample_size, fragment_starting_num, fragments_in_submessage); + reader->process_data_frag_msg(&change, sample_size, fragment_starting_num, fragments_in_submessage); std::swap(change.serializedPayload.data, crypto_payload_.data); std::swap(change.serializedPayload.length, crypto_payload_.length); }; @@ -215,9 +218,9 @@ void MessageReceiver::process_data_message_without_security( CacheChange_t& change, bool /*was_decoded*/) { - auto process_message = [&change](RTPSReader* reader) + auto process_message = [&change](BaseReader* reader) { - reader->processDataMsg(&change); + reader->process_data_msg(&change); }; findAllReaders(reader_id, process_message); @@ -231,9 +234,10 @@ void MessageReceiver::process_data_fragment_message_without_security( uint16_t fragments_in_submessage, bool /*was_decoded*/) { - auto process_message = [&change, sample_size, fragment_starting_num, fragments_in_submessage](RTPSReader* reader) + auto process_message = [&change, sample_size, fragment_starting_num, fragments_in_submessage]( + BaseReader* reader) { - reader->processDataFragMsg(&change, sample_size, fragment_starting_num, fragments_in_submessage); + reader->process_data_frag_msg(&change, sample_size, fragment_starting_num, fragments_in_submessage); }; findAllReaders(reader_id, process_message); @@ -258,13 +262,13 @@ void MessageReceiver::associateEndpoint( } else { - const auto reader = dynamic_cast(to_add); + const auto reader = BaseReader::downcast(to_add); const auto entityId = reader->getGuid().entityId; // search for set of readers by entity ID const auto readers = associated_readers_.find(entityId); if (readers == associated_readers_.end()) { - auto vec = std::vector(); + auto vec = std::vector(); vec.push_back(reader); associated_readers_.emplace(entityId, vec); } @@ -305,7 +309,7 @@ void MessageReceiver::removeEndpoint( auto readers = associated_readers_.find(to_remove->getGuid().entityId); if (readers != associated_readers_.end()) { - auto* var = dynamic_cast(to_remove); + auto* var = BaseReader::downcast(to_remove); for (auto it = readers->second.begin(); it != readers->second.end(); ++it) { if (*it == var) @@ -668,7 +672,7 @@ bool MessageReceiver::readSubmessageHeader( bool MessageReceiver::willAReaderAcceptMsgDirectedTo( const EntityId_t& readerID, - RTPSReader*& first_reader) const + BaseReader*& first_reader) const { first_reader = nullptr; if (associated_readers_.empty()) @@ -692,11 +696,8 @@ bool MessageReceiver::willAReaderAcceptMsgDirectedTo( { for (const auto& it : readers.second) { - if (it->m_acceptMessagesToUnknownReaders) - { - first_reader = it; - return true; - } + first_reader = it; + return true; } } } @@ -727,10 +728,7 @@ void MessageReceiver::findAllReaders( { for (const auto& it : readers.second) { - if (it->m_acceptMessagesToUnknownReaders) - { - callback(it); - } + callback(it); } } } @@ -779,7 +777,7 @@ bool MessageReceiver::proc_Submsg_Data( valid &= CDRMessage::readInt16(msg, &octetsToInlineQos); //it should be 16 in this implementation //reader and writer ID - RTPSReader* first_reader = nullptr; + BaseReader* first_reader = nullptr; EntityId_t readerID; valid &= CDRMessage::readEntityId(msg, &readerID); @@ -906,7 +904,7 @@ bool MessageReceiver::proc_Submsg_Data( ch.sourceTimestamp = timestamp_; } - EPROSIMA_LOG_INFO(RTPS_MSG_IN, IDSTRING "from Writer " << ch.writerGUID << "; possible RTPSReader entities: " << + EPROSIMA_LOG_INFO(RTPS_MSG_IN, IDSTRING "from Writer " << ch.writerGUID << "; possible Reader entities: " << associated_readers_.size()); //Look for the correct reader to add the change @@ -963,7 +961,7 @@ bool MessageReceiver::proc_Submsg_DataFrag( valid &= CDRMessage::readInt16(msg, &octetsToInlineQos); //it should be 16 in this implementation //reader and writer ID - RTPSReader* first_reader = nullptr; + BaseReader* first_reader = nullptr; EntityId_t readerID; valid &= CDRMessage::readEntityId(msg, &readerID); @@ -1093,7 +1091,7 @@ bool MessageReceiver::proc_Submsg_DataFrag( ch.sourceTimestamp = timestamp_; } - EPROSIMA_LOG_INFO(RTPS_MSG_IN, IDSTRING "from Writer " << ch.writerGUID << "; possible RTPSReader entities: " << + EPROSIMA_LOG_INFO(RTPS_MSG_IN, IDSTRING "from Writer " << ch.writerGUID << "; possible Reader entities: " << associated_readers_.size()); process_data_fragment_message_function_(readerID, ch, sampleSize, fragmentStartingNum, fragmentsInSubmessage, was_decoded); @@ -1157,7 +1155,8 @@ bool MessageReceiver::proc_Submsg_Heartbeat( //Look for the correct reader and writers: findAllReaders(readerGUID.entityId, - [was_decoded, &writerGUID, &HBCount, &firstSN, &lastSN, finalFlag, livelinessFlag, this](RTPSReader* reader) + [was_decoded, &writerGUID, &HBCount, &firstSN, &lastSN, finalFlag, livelinessFlag, this]( + BaseReader* reader) { // Only used when HAVE_SECURITY is defined static_cast(was_decoded); @@ -1165,7 +1164,7 @@ bool MessageReceiver::proc_Submsg_Heartbeat( if (was_decoded || !reader->getAttributes().security_attributes().is_submessage_protected) #endif // HAVE_SECURITY { - reader->processHeartbeatMsg(writerGUID, HBCount, firstSN, lastSN, finalFlag, livelinessFlag, + reader->process_heartbeat_msg(writerGUID, HBCount, firstSN, lastSN, finalFlag, livelinessFlag, source_vendor_id_); } }); @@ -1265,7 +1264,7 @@ bool MessageReceiver::proc_Submsg_Gap( } findAllReaders(readerGUID.entityId, - [was_decoded, &writerGUID, &gapStart, &gapList, this](RTPSReader* reader) + [was_decoded, &writerGUID, &gapStart, &gapList, this](BaseReader* reader) { // Only used when HAVE_SECURITY is defined static_cast(was_decoded); @@ -1273,7 +1272,7 @@ bool MessageReceiver::proc_Submsg_Gap( if (was_decoded || !reader->getAttributes().security_attributes().is_submessage_protected) #endif // HAVE_SECURITY { - reader->processGapMsg(writerGUID, gapStart, gapList, source_vendor_id_); + reader->process_gap_msg(writerGUID, gapStart, gapList, source_vendor_id_); } }); @@ -1435,51 +1434,13 @@ bool MessageReceiver::proc_Submsg_NackFrag( bool MessageReceiver::proc_Submsg_HeartbeatFrag( CDRMessage_t* msg, SubmessageHeader_t* smh, - bool /*was_decoded*/) const + bool was_decoded) const { - eprosima::shared_lock guard(mtx_); - - bool endiannessFlag = (smh->flags & BIT(0)) != 0; - //Assign message endianness - if (endiannessFlag) - { - msg->msg_endian = LITTLEEND; - } - else - { - msg->msg_endian = BIGEND; - } - - GUID_t readerGUID; - GUID_t writerGUID; - readerGUID.guidPrefix = dest_guid_prefix_; - CDRMessage::readEntityId(msg, &readerGUID.entityId); - writerGUID.guidPrefix = source_guid_prefix_; - CDRMessage::readEntityId(msg, &writerGUID.entityId); - - SequenceNumber_t writerSN; - CDRMessage::readSequenceNumber(msg, &writerSN); - - FragmentNumber_t lastFN; - CDRMessage::readUInt32(msg, static_cast(&lastFN)); - - uint32_t HBCount; - CDRMessage::readUInt32(msg, &HBCount); - - // XXX TODO VALIDATE DATA? + // TODO: Add support for HEARTBEAT_FRAG submessage + static_cast(msg); + static_cast(smh); + static_cast(was_decoded); - //Look for the correct reader and writers: - /* XXX TODO - std::lock_guard guard(mtx_); - for (std::vector::iterator it = associated_readers_.begin(); - it != associated_readers_.end(); ++it) - { - if ((*it)->acceptMsgDirectedTo(readerGUID.entityId)) - { - (*it)->processHeartbeatMsg(writerGUID, HBCount, firstSN, lastSN, finalFlag, livelinessFlag); - } - } - */ return true; } diff --git a/src/cpp/rtps/messages/MessageReceiver.h b/src/cpp/rtps/messages/MessageReceiver.h index e2d94e10228..86f34a31cfa 100644 --- a/src/cpp/rtps/messages/MessageReceiver.h +++ b/src/cpp/rtps/messages/MessageReceiver.h @@ -34,13 +34,21 @@ #include namespace eprosima { + +namespace fastdds { +namespace rtps { + +class BaseReader; + +} // namespace rtps +} // namespace fastdds + namespace fastrtps { namespace rtps { class RTPSParticipantImpl; class Endpoint; class RTPSWriter; -class RTPSReader; struct SubmessageHeader_t; /** @@ -49,6 +57,9 @@ struct SubmessageHeader_t; */ class MessageReceiver { + + using BaseReader = fastdds::rtps::BaseReader; + public: /** @@ -82,7 +93,7 @@ class MessageReceiver mutable eprosima::shared_mutex mtx_; std::vector associated_writers_; - std::unordered_map> associated_readers_; + std::unordered_map> associated_readers_; RTPSParticipantImpl* participant_; //!Protocol version of the message @@ -147,7 +158,7 @@ class MessageReceiver */ bool willAReaderAcceptMsgDirectedTo( const EntityId_t& readerID, - RTPSReader*& first_reader) const; + BaseReader*& first_reader) const; /** * Find all readers (in associated_readers_), with the given entity ID, and call the diff --git a/src/cpp/rtps/messages/RTPSMessageGroup.cpp b/src/cpp/rtps/messages/RTPSMessageGroup.cpp index aed3c2485e4..ec683aeb865 100644 --- a/src/cpp/rtps/messages/RTPSMessageGroup.cpp +++ b/src/cpp/rtps/messages/RTPSMessageGroup.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -36,6 +37,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + /** * An InlineQosWriter that puts the inline_qos of a CacheChange_t into a CDRMessage_t. */ @@ -866,8 +869,7 @@ bool RTPSMessageGroup::add_acknack( #endif // if HAVE_SECURITY // Notify the statistics module, note that only readers add acknacks - assert(nullptr != dynamic_cast(endpoint_)); - static_cast(static_cast(endpoint_))->on_acknack(count); + BaseReader::downcast(endpoint_)->on_acknack(count); return insert_submessage(false); } @@ -922,8 +924,7 @@ bool RTPSMessageGroup::add_nackfrag( #endif // if HAVE_SECURITY // Notify the statistics module, note that only readers add NACKFRAGs - assert(nullptr != dynamic_cast(endpoint_)); - static_cast(endpoint_)->on_nackfrag(count); + BaseReader::downcast(endpoint_)->on_nackfrag(count); return insert_submessage(false); } diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp index fafc4765233..7a3336fbf7b 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.cpp +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.cpp @@ -86,6 +86,7 @@ using UDPv4TransportDescriptor = fastdds::rtps::UDPv4TransportDescriptor; using TCPTransportDescriptor = fastdds::rtps::TCPTransportDescriptor; using SharedMemTransportDescriptor = fastdds::rtps::SharedMemTransportDescriptor; using BuiltinTransports = fastdds::rtps::BuiltinTransports; +using BaseReader = fastdds::rtps::BaseReader; /** * Parse the environment variable specifying the transports to instantiate and optional configuration options @@ -740,7 +741,7 @@ const std::vector& RTPSParticipantImpl::getAllWriters() const return m_allWriterList; } -const std::vector& RTPSParticipantImpl::getAllReaders() const +const std::vector& RTPSParticipantImpl::getAllReaders() const { return m_allReaderList; } @@ -1061,7 +1062,7 @@ bool RTPSParticipantImpl::create_reader( normalize_endpoint_locators(param.endpoint); - RTPSReader* SReader = nullptr; + BaseReader* SReader = nullptr; GUID_t guid(m_guid.guidPrefix, entId); SReader = callback(guid, param, persistence, param.endpoint.reliabilityKind == RELIABLE); @@ -1107,7 +1108,7 @@ bool RTPSParticipantImpl::create_reader( if (is_builtin) { - SReader->setTrustedWriter(TrustedWriter(SReader->getGuid().entityId)); + SReader->set_trusted_writer(TrustedWriter(SReader->getGuid().entityId)); } if (enable) @@ -1309,7 +1310,7 @@ bool RTPSParticipantImpl::createReader( { auto callback = [hist, listen, this] (const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence, - bool is_reliable) -> RTPSReader* + bool is_reliable) -> BaseReader* { if (is_reliable) { @@ -1355,7 +1356,7 @@ bool RTPSParticipantImpl::createReader( auto callback = [hist, listen, &payload_pool, this] (const GUID_t& guid, ReaderAttributes& param, IPersistenceService* persistence, - bool is_reliable) -> RTPSReader* + bool is_reliable) -> BaseReader* { if (is_reliable) { @@ -1384,7 +1385,7 @@ bool RTPSParticipantImpl::createReader( return create_reader(ReaderOut, param, entityId, isBuiltin, enable, callback); } -RTPSReader* RTPSParticipantImpl::find_local_reader( +BaseReader* RTPSParticipantImpl::find_local_reader( const GUID_t& reader_guid) { shared_lock _(endpoints_list_mutex); @@ -2166,7 +2167,7 @@ void RTPSParticipantImpl::deleteAllUserEndpoints() back_inserter(writers)); swap(writers, m_allWriterList); - vector readers; + vector readers; set_difference(m_allReaderList.begin(), m_allReaderList.end(), m_userReaderList.begin(), m_userReaderList.end(), back_inserter(readers)); @@ -2920,7 +2921,7 @@ bool RTPSParticipantImpl::register_in_reader( } else if (!fastdds::statistics::is_statistics_builtin(reader_guid.entityId)) { - RTPSReader* reader = find_local_reader(reader_guid); + BaseReader* reader = find_local_reader(reader_guid); res = reader->add_statistics_listener(listener); } diff --git a/src/cpp/rtps/participant/RTPSParticipantImpl.h b/src/cpp/rtps/participant/RTPSParticipantImpl.h index c9e4cc5fbc5..bf617bc3ba0 100644 --- a/src/cpp/rtps/participant/RTPSParticipantImpl.h +++ b/src/cpp/rtps/participant/RTPSParticipantImpl.h @@ -87,6 +87,12 @@ class MonitorService; #endif //FASTDDS_STATISTICS +namespace rtps { + +class BaseReader; + +} // namespace rtps + namespace dds { namespace builtin { @@ -134,6 +140,9 @@ class RTPSParticipantImpl , private security::SecurityPluginFactory #endif // if HAVE_SECURITY { + + using BaseReader = fastdds::rtps::BaseReader; + /* Receiver Control block is a struct we use to encapsulate the resources that take part in message reception. It contains: @@ -373,7 +382,7 @@ class RTPSParticipantImpl /*! * @remarks Non thread-safe. */ - const std::vector& getAllReaders() const; + const std::vector& getAllReaders() const; uint32_t getMaxMessageSize() const; @@ -479,7 +488,7 @@ class RTPSParticipantImpl /*** * @returns A pointer to a local reader given its endpoint guid, or nullptr if not found. */ - RTPSReader* find_local_reader( + BaseReader* find_local_reader( const GUID_t& reader_guid); /*** @@ -571,12 +580,12 @@ class RTPSParticipantImpl //!Writer List. std::vector m_allWriterList; //!Reader List - std::vector m_allReaderList; + std::vector m_allReaderList; //!Listen thread list. //!Writer List. std::vector m_userWriterList; //!Reader List - std::vector m_userReaderList; + std::vector m_userReaderList; //!Network Factory NetworkFactory m_network_Factory; //! Type cheking function @@ -1019,7 +1028,7 @@ class RTPSParticipantImpl // check if we are reentrying shared_lock _(endpoints_list_mutex); - for ( RTPSReader* pr : m_userReaderList) + for (BaseReader* pr : m_userReaderList) { if (!f(*pr)) { diff --git a/src/cpp/rtps/reader/BaseReader.cpp b/src/cpp/rtps/reader/BaseReader.cpp new file mode 100644 index 00000000000..91b9d9fc212 --- /dev/null +++ b/src/cpp/rtps/reader/BaseReader.cpp @@ -0,0 +1,517 @@ +// 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. + +/* + * BaseReader.cpp + */ + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace eprosima { +namespace fastdds { +namespace rtps { + +using namespace fastrtps::rtps; + +BaseReader::BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen) + : fastrtps::rtps::RTPSReader(pimpl, guid, att, hist) + , listener_(listen) + , accept_messages_from_unkown_writers_(att.accept_messages_from_unkown_writers) + , expects_inline_qos_(att.expects_inline_qos) + , history_state_(new fastrtps::rtps::ReaderHistoryState(att.matched_writers_allocation.initial)) + , liveliness_kind_(att.liveliness_kind) + , liveliness_lease_duration_(att.liveliness_lease_duration) +{ + PoolConfig cfg = PoolConfig::from_history_attributes(hist->m_att); + std::shared_ptr change_pool; + std::shared_ptr payload_pool; + payload_pool = BasicPayloadPool::get(cfg, change_pool); + + init(payload_pool, change_pool); + setup_datasharing(att); +} + +BaseReader::BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + const std::shared_ptr& payload_pool, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen) + : BaseReader( + pimpl, guid, att, payload_pool, + std::make_shared(PoolConfig::from_history_attributes(hist->m_att)), + hist, listen) +{ +} + +BaseReader::BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen) + : fastrtps::rtps::RTPSReader(pimpl, guid, att, hist) + , listener_(listen) + , accept_messages_from_unkown_writers_(att.accept_messages_from_unkown_writers) + , expects_inline_qos_(att.expects_inline_qos) + , history_state_(new fastrtps::rtps::ReaderHistoryState(att.matched_writers_allocation.initial)) + , liveliness_kind_(att.liveliness_kind) + , liveliness_lease_duration_(att.liveliness_lease_duration) +{ + init(payload_pool, change_pool); + setup_datasharing(att); +} + +BaseReader::~BaseReader() +{ + EPROSIMA_LOG_INFO(RTPS_READER, "Removing reader " << this->getGuid().entityId); + + for (auto it = history_->changesBegin(); it != history_->changesEnd(); ++it) + { + release_cache(*it); + } + + delete history_state_; +} + +ReaderListener* BaseReader::get_listener() const +{ + std::lock_guard lock(mp_mutex); + return listener_; +} + +void BaseReader::set_listener( + ReaderListener* target) +{ + std::lock_guard lock(mp_mutex); + listener_ = target; +} + +bool BaseReader::expects_inline_qos() const +{ + return expects_inline_qos_; +} + +ReaderHistory* BaseReader::get_history() const +{ + return history_; +} + +//! @return The content filter associated to this reader. +IReaderDataFilter* BaseReader::get_content_filter() const +{ + std::lock_guard lock(mp_mutex); + return data_filter_; +} + +//! Set the content filter associated to this reader. +//! @param filter Pointer to the content filter to associate to this reader. +void BaseReader::set_content_filter( + IReaderDataFilter* filter) +{ + std::lock_guard lock(mp_mutex); + data_filter_ = filter; +} + +uint64_t BaseReader::get_unread_count() const +{ + std::lock_guard lock(mp_mutex); + return total_unread_; +} + +uint64_t BaseReader::get_unread_count( + bool mark_as_read) +{ + std::lock_guard lock(mp_mutex); + uint64_t ret_val = total_unread_; + + if (mark_as_read) + { + for (auto it = history_->changesBegin(); 0 < total_unread_ && it != history_->changesEnd(); ++it) + { + fastrtps::rtps::CacheChange_t* change = *it; + if (!change->isRead && get_last_notified(change->writerGUID) >= change->sequenceNumber) + { + change->isRead = true; + assert(0 < total_unread_); + --total_unread_; + } + } + assert(0 == total_unread_); + } + return ret_val; +} + +bool BaseReader::wait_for_unread_cache( + const eprosima::fastrtps::Duration_t& timeout) +{ + auto time_out = std::chrono::steady_clock::now() + std::chrono::seconds(timeout.seconds) + + std::chrono::nanoseconds(timeout.nanosec); + +#if HAVE_STRICT_REALTIME + std::unique_lock lock(mp_mutex, std::defer_lock); + if (lock.try_lock_until(time_out)) +#else + std::unique_lock lock(mp_mutex); +#endif // HAVE_STRICT_REALTIME + { + if (new_notification_cv_.wait_until( + lock, time_out, + [&]() + { + return total_unread_ > 0; + })) + { + return true; + } + } + + return false; +} + +bool BaseReader::is_sample_valid( + const void* data, + const fastrtps::rtps::GUID_t& writer, + const fastrtps::rtps::SequenceNumber_t& sn) const +{ + if (is_datasharing_compatible_ && datasharing_listener_->writer_is_matched(writer)) + { + // Check if the payload is dirty + // Note the Payloads used in loans include a mandatory RTPS 2.3 extra header + auto payload = static_cast(data); + payload -= fastrtps::rtps::SerializedPayload_t::representation_header_size; + if (!fastrtps::rtps::DataSharingPayloadPool::check_sequence_number(payload, sn)) + { + return false; + } + } + return true; +} + +BaseReader* BaseReader::downcast( + fastrtps::rtps::RTPSReader* reader) +{ + assert(nullptr != dynamic_cast(reader)); + return static_cast(reader); +} + +BaseReader* BaseReader::downcast( + fastrtps::rtps::Endpoint* endpoint) +{ + assert(nullptr != dynamic_cast(endpoint)); + return static_cast(endpoint); +} + +void BaseReader::allow_unknown_writers() +{ + assert(fastrtps::rtps::EntityId_t::unknown() != trusted_writer_entity_id_); + accept_messages_from_unkown_writers_ = true; +} + +bool BaseReader::reserve_cache( + uint32_t cdr_payload_size, + fastrtps::rtps::CacheChange_t*& change) +{ + std::lock_guard guard(mp_mutex); + + change = nullptr; + + fastrtps::rtps::CacheChange_t* reserved_change = nullptr; + if (!change_pool_->reserve_cache(reserved_change)) + { + EPROSIMA_LOG_WARNING(RTPS_READER, "Problem reserving cache from pool"); + return false; + } + + uint32_t payload_size = fixed_payload_size_ ? fixed_payload_size_ : cdr_payload_size; + if (!payload_pool_->get_payload(payload_size, *reserved_change)) + { + change_pool_->release_cache(reserved_change); + EPROSIMA_LOG_WARNING(RTPS_READER, "Problem reserving payload from pool"); + return false; + } + + change = reserved_change; + return true; +} + +void BaseReader::release_cache( + fastrtps::rtps::CacheChange_t* change) +{ + std::lock_guard guard(mp_mutex); + + fastrtps::rtps::IPayloadPool* pool = change->payload_owner(); + if (pool) + { + pool->release_payload(*change); + } + change_pool_->release_cache(change); +} + +void BaseReader::update_liveliness_changed_status( + const fastrtps::rtps::GUID_t& writer, + int32_t alive_change, + int32_t not_alive_change) +{ + std::lock_guard lock(mp_mutex); + + liveliness_changed_status_.alive_count += alive_change; + liveliness_changed_status_.alive_count_change += alive_change; + liveliness_changed_status_.not_alive_count += not_alive_change; + liveliness_changed_status_.not_alive_count_change += not_alive_change; + liveliness_changed_status_.last_publication_handle = writer; + + if (nullptr != listener_) + { + listener_->on_liveliness_changed(this, liveliness_changed_status_); + + liveliness_changed_status_.alive_count_change = 0; + liveliness_changed_status_.not_alive_count_change = 0; + } +} + +#ifdef FASTDDS_STATISTICS + +bool BaseReader::add_statistics_listener( + std::shared_ptr listener) +{ + return add_statistics_listener_impl(listener); +} + +bool BaseReader::remove_statistics_listener( + std::shared_ptr listener) +{ + return remove_statistics_listener_impl(listener); +} + +void BaseReader::set_enabled_statistics_writers_mask( + uint32_t enabled_writers) +{ + set_enabled_statistics_writers_mask_impl(enabled_writers); +} + +#endif // FASTDDS_STATISTICS + +bool BaseReader::may_remove_history_record( + bool removed_by_lease) +{ + return !removed_by_lease; +} + +void BaseReader::add_persistence_guid( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::GUID_t& persistence_guid) +{ + if (fastrtps::rtps::c_Guid_Unknown == persistence_guid || persistence_guid == guid) + { + std::lock_guard guard(mp_mutex); + history_state_->persistence_guid_map[guid] = guid; + history_state_->persistence_guid_count[guid]++; + } + else + { + std::lock_guard guard(mp_mutex); + history_state_->persistence_guid_map[guid] = persistence_guid; + history_state_->persistence_guid_count[persistence_guid]++; + + // Could happen that a value has already been stored in the record with the guid and not the persistence guid + // This is because received_change is called before Proxy is created + // In this case, we substitute the guid for the persistence (in case they are not equal) + auto spourious_record = history_state_->history_record.find(guid); + if (spourious_record != history_state_->history_record.end()) + { + EPROSIMA_LOG_INFO(RTPS_READER, "Sporious record found, changing guid " + << guid << " for persistence guid " << persistence_guid); + update_last_notified(guid, spourious_record->second); + history_state_->history_record.erase(spourious_record); + } + } +} + +void BaseReader::remove_persistence_guid( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::GUID_t& persistence_guid, + bool removed_by_lease) +{ + std::lock_guard guard(mp_mutex); + auto persistence_guid_stored = (fastrtps::rtps::c_Guid_Unknown == persistence_guid) ? guid : persistence_guid; + history_state_->persistence_guid_map.erase(guid); + auto count = --history_state_->persistence_guid_count[persistence_guid_stored]; + if (count <= 0 && may_remove_history_record(removed_by_lease)) + { + history_state_->history_record.erase(persistence_guid_stored); + history_state_->persistence_guid_count.erase(persistence_guid_stored); + } +} + +fastrtps::rtps::SequenceNumber_t BaseReader::get_last_notified( + const fastrtps::rtps::GUID_t& guid) +{ + fastrtps::rtps::SequenceNumber_t ret_val; + std::lock_guard guard(mp_mutex); + fastrtps::rtps::GUID_t guid_to_look = guid; + auto p_guid = history_state_->persistence_guid_map.find(guid); + if (p_guid != history_state_->persistence_guid_map.end()) + { + guid_to_look = p_guid->second; + } + + auto p_seq = history_state_->history_record.find(guid_to_look); + if (p_seq != history_state_->history_record.end()) + { + ret_val = p_seq->second; + } + + return ret_val; +} + +fastrtps::rtps::SequenceNumber_t BaseReader::update_last_notified( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::SequenceNumber_t& seq) +{ + fastrtps::rtps::SequenceNumber_t ret_val; + std::lock_guard guard(mp_mutex); + fastrtps::rtps::GUID_t guid_to_look = guid; + auto p_guid = history_state_->persistence_guid_map.find(guid); + if (p_guid != history_state_->persistence_guid_map.end()) + { + guid_to_look = p_guid->second; + } + + auto p_seq = history_state_->history_record.find(guid_to_look); + if (p_seq != history_state_->history_record.end()) + { + ret_val = p_seq->second; + } + + if (ret_val < seq) + { + history_state_->history_record[guid_to_look] = seq; + persist_last_notified_nts(guid_to_look, seq); + new_notification_cv_.notify_all(); + } + + return ret_val; +} + +void BaseReader::persist_last_notified_nts( + const fastrtps::rtps::GUID_t& peristence_guid, + const fastrtps::rtps::SequenceNumber_t& seq) +{ + // Empty base implementation since base behavior is to not persist data + static_cast(peristence_guid); + static_cast(seq); +} + +bool BaseReader::is_datasharing_compatible_with( + const fastrtps::rtps::WriterProxyData& wdata) +{ + if (!is_datasharing_compatible_ || + wdata.m_qos.data_sharing.kind() == fastdds::dds::DataSharingKind::OFF) + { + return false; + } + + for (auto id : wdata.m_qos.data_sharing.domain_ids()) + { + if (std::find(m_att.data_sharing_configuration().domain_ids().begin(), + m_att.data_sharing_configuration().domain_ids().end(), id) + != m_att.data_sharing_configuration().domain_ids().end()) + { + return true; + } + } + + return false; +} + +void BaseReader::init( + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool) +{ + payload_pool_ = payload_pool; + change_pool_ = change_pool; + fixed_payload_size_ = 0; + if (history_->m_att.memoryPolicy == PREALLOCATED_MEMORY_MODE) + { + fixed_payload_size_ = history_->m_att.payloadMaxSize; + } + + EPROSIMA_LOG_INFO(RTPS_READER, "RTPSReader created correctly"); +} + +void BaseReader::setup_datasharing( + const fastrtps::rtps::ReaderAttributes& att) +{ + using namespace fastrtps::rtps; + + if (att.endpoint.data_sharing_configuration().kind() != fastdds::dds::DataSharingKind::OFF) + { + using std::placeholders::_1; + std::shared_ptr notification = DataSharingNotification::create_notification( + getGuid(), att.endpoint.data_sharing_configuration().shm_directory()); + if (notification) + { + is_datasharing_compatible_ = true; + datasharing_listener_.reset(new DataSharingListener( + notification, + att.endpoint.data_sharing_configuration().shm_directory(), + att.data_sharing_listener_thread, + att.matched_writers_allocation, + this)); + + // We can start the listener here, as no writer can be matched already, + // so no notification will occur until the non-virtual instance is constructed. + // But we need to stop the listener in the non-virtual instance destructor. + datasharing_listener_->start(); + } + } +} + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima diff --git a/src/cpp/rtps/reader/BaseReader.hpp b/src/cpp/rtps/reader/BaseReader.hpp new file mode 100644 index 00000000000..98df820b900 --- /dev/null +++ b/src/cpp/rtps/reader/BaseReader.hpp @@ -0,0 +1,474 @@ +// 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 BaseReader.hpp + */ + +#ifndef RTPS_READER__BASEREADER_HPP +#define RTPS_READER__BASEREADER_HPP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eprosima { + +namespace fastrtps { +namespace rtps { + +struct CacheChange_t; +class IDataSharingListener; +struct ReaderHistoryState; +class ReaderListener; +class RTPSParticipantImpl; +class WriterProxy; +class WriterProxyData; + +} // namespace rtps +} // namespace fastrtps + +namespace fastdds { +namespace rtps { + +class BaseReader + : public fastrtps::rtps::RTPSReader + , public fastdds::statistics::StatisticsReaderImpl +{ + +public: + + fastrtps::rtps::ReaderListener* get_listener() const override; + + void set_listener( + fastrtps::rtps::ReaderListener* listener) override; + + bool expects_inline_qos() const override; + + fastrtps::rtps::ReaderHistory* get_history() const override; + + IReaderDataFilter* get_content_filter() const override; + + void set_content_filter( + IReaderDataFilter* filter) override; + + uint64_t get_unread_count() const override; + + uint64_t get_unread_count( + bool mark_as_read) override; + + bool wait_for_unread_cache( + const fastrtps::Duration_t& timeout) override; + + bool is_sample_valid( + const void* data, + const fastrtps::rtps::GUID_t& writer, + const fastrtps::rtps::SequenceNumber_t& sn) const override; + + /** + * @brief Get a pointer to a BaseReader object from a RTPSReader pointer. + * + * @param reader Pointer to the RTPSReader object. + * + * @return Pointer to the BaseReader object. + */ + static BaseReader* downcast( + fastrtps::rtps::RTPSReader* reader); + + /** + * @brief Get a pointer to a BaseReader object from a Endpoint pointer. + * + * @param endpoint Pointer to the Endpoint object. + * + * @return Pointer to the BaseReader object. + */ + static BaseReader* downcast( + fastrtps::rtps::Endpoint* endpoint); + + /** + * @brief Set the entity ID of the trusted writer. + * + * @param writer Entity ID of the trusted writer. + */ + void set_trusted_writer( + const fastrtps::rtps::EntityId_t& writer) + { + accept_messages_from_unkown_writers_ = false; + trusted_writer_entity_id_ = writer; + } + + /** + * @brief Allow reception ALIVE changes from non-matched writers. + */ + void allow_unknown_writers(); + + /** + * @return The liveliness kind of this reader + */ + fastdds::dds::LivelinessQosPolicyKind liveliness_kind() const + { + return liveliness_kind_; + } + + /** + * @return The liveliness lease duration of this reader + */ + fastrtps::Duration_t liveliness_lease_duration() const + { + return liveliness_lease_duration_; + } + + /** + * @return the datasharing listener associated with this reader. + */ + const std::unique_ptr& datasharing_listener() const + { + return datasharing_listener_; + } + + /** + * @brief Reserve a CacheChange_t. + * + * @param [in] cdr_payload_size Size of the received payload. + * @param [out] change Pointer to the reserved change. + * + * @return True if correctly reserved. + */ + bool reserve_cache( + uint32_t cdr_payload_size, + fastrtps::rtps::CacheChange_t*& change); + + /** + * @brief Release a CacheChange_t. + * + * @param change Pointer to the change to release. + */ + void release_cache( + fastrtps::rtps::CacheChange_t* change); + + /** + * @brief Method to notify the reader that a change has been removed from its history. + * + * @param change Pointer to the CacheChange_t that was removed from the history. + * + * @return True if correctly removed. + */ + virtual bool change_removed_by_history( + fastrtps::rtps::CacheChange_t* change) = 0; + + /** + * @brief Called just before a change is going to be deserialized. + * + * @param [in] change Pointer to the change being accessed. + * @param [out] writer Writer proxy the @c change belongs to. + * @param [out] is_future_change Whether the change is in the future (i.e. there are + * earlier unreceived changes from the same writer). + * + * @return Whether the change is still valid or not. + */ + virtual bool begin_sample_access_nts( + fastrtps::rtps::CacheChange_t* change, + fastrtps::rtps::WriterProxy*& writer, + bool& is_future_change) = 0; + + /** + * @brief Called after the change has been deserialized. + * + * @param [in] change Pointer to the change being accessed. + * @param [in] writer Writer proxy the @c change belongs to. + * @param [in] mark_as_read Whether the @c change should be marked as read or not. + */ + virtual void end_sample_access_nts( + fastrtps::rtps::CacheChange_t* change, + fastrtps::rtps::WriterProxy*& writer, + bool mark_as_read) = 0; + + /** + * @brief A method to update the liveliness changed status of the reader + * + * @param writer The writer changing liveliness, specified by its guid + * @param alive_change The change requested for alive count. Should be -1, 0 or +1 + * @param not_alive_change The change requested for not alive count. Should be -1, 0 or +1 + */ + void update_liveliness_changed_status( + const fastrtps::rtps::GUID_t& writer, + int32_t alive_change, + int32_t not_alive_change); + + /** + * @brief Process an incoming DATA message. + * + * @param change Pointer to the incoming CacheChange_t. + * + * @return true if the reader accepts message. + */ + virtual bool process_data_msg( + fastrtps::rtps::CacheChange_t* change) = 0; + + /** + * @brief Process an incoming DATA_FRAG message. + * + * @param change Pointer to the incoming CacheChange_t. + * @param sampleSize Size of the complete, assembled message. + * @param fragmentStartingNum Starting number of this particular message. + * @param fragmentsInSubmessage Number of fragments on this particular message. + * + * @return true if the reader accepts message. + */ + virtual bool process_data_frag_msg( + fastrtps::rtps::CacheChange_t* change, + uint32_t sampleSize, + uint32_t fragmentStartingNum, + uint16_t fragmentsInSubmessage) = 0; + + /** + * @brief Process an incoming HEARTBEAT message. + * + * @param writerGUID + * @param hbCount + * @param firstSN + * @param lastSN + * @param finalFlag + * @param livelinessFlag + * @param origin_vendor_id + * + * @return true if the reader accepts message. + */ + virtual bool process_heartbeat_msg( + const fastrtps::rtps::GUID_t& writerGUID, + uint32_t hbCount, + const fastrtps::rtps::SequenceNumber_t& firstSN, + const fastrtps::rtps::SequenceNumber_t& lastSN, + bool finalFlag, + bool livelinessFlag, + VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0; + + /** + * @brief Process an incoming GAP message. + * + * @param writerGUID + * @param gapStart + * @param gapList + * @param origin_vendor_id + * + * @return true if the reader accepts message. + */ + virtual bool process_gap_msg( + const fastrtps::rtps::GUID_t& writerGUID, + const fastrtps::rtps::SequenceNumber_t& gapStart, + const fastrtps::rtps::SequenceNumberSet_t& gapList, + VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0; + +#ifdef FASTDDS_STATISTICS + + bool add_statistics_listener( + std::shared_ptr listener) override; + + bool remove_statistics_listener( + std::shared_ptr listener) override; + + void set_enabled_statistics_writers_mask( + uint32_t enabled_writers) override; + +#endif // FASTDDS_STATISTICS + + virtual ~BaseReader(); + +protected: + + BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen); + + BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + const std::shared_ptr& payload_pool, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen); + + BaseReader( + fastrtps::rtps::RTPSParticipantImpl* pimpl, + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::ReaderAttributes& att, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + fastrtps::rtps::ReaderHistory* hist, + fastrtps::rtps::ReaderListener* listen); + + /** + * @brief Whether a history record may be removed. + * + * @param removed_by_lease Whether the history record is to be removed due to a participant drop. + * + * @return Whether the history record may be removed. + */ + virtual bool may_remove_history_record( + bool removed_by_lease); + + /** + * @brief Add a remote writer to the persistence_guid map. + * + * @param guid GUID of the remote writer. + * @param persistence_guid Persistence GUID of the remote writer. + */ + void add_persistence_guid( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::GUID_t& persistence_guid); + + /** + * @brief Remove a remote writer from the persistence_guid map. + * + * @param guid GUID of the remote writer. + * @param persistence_guid Persistence GUID of the remote writer. + * @param removed_by_lease Whether the GUIDs are being removed due to a participant drop. + */ + void remove_persistence_guid( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::GUID_t& persistence_guid, + bool removed_by_lease); + + /** + * @brief Get the last notified sequence for a writer's GUID. + * + * @param guid The writer GUID to query. + * + * @return Last notified sequence number for input guid. + * @remarks Takes persistence_guid into consideration. + */ + fastrtps::rtps::SequenceNumber_t get_last_notified( + const fastrtps::rtps::GUID_t& guid); + + /** + * @brief Update the last notified sequence for a writer's GUID. + * + * @param guid The GUID of the writer. + * @param seq Max sequence number available on writer. + * + * @return Previous value of last notified sequence number for input GUID. + * @remarks Takes persistence_guid into consideration. + */ + fastrtps::rtps::SequenceNumber_t update_last_notified( + const fastrtps::rtps::GUID_t& guid, + const fastrtps::rtps::SequenceNumber_t& seq); + + /** + * @brief Persist the last notified sequence for a persistence guid. + * This method is called inside update_last_notified just after updating the last notified sequence for a writer + * and gives persistent readers the opportunity to write the new sequence number to the database. + * + * @param persistence_guid The persistence guid to update. + * @param seq Sequence number to set for input guid. + */ + virtual void persist_last_notified_nts( + const fastrtps::rtps::GUID_t& persistence_guid, + const fastrtps::rtps::SequenceNumber_t& seq); + + /** + * @brief Check if a writer can communicate with this reader using data-sharing. + * + * @param wdata Discovery information of the writer to check. + * + * @return Whether the writer is datasharing compatible with this reader or not. + */ + bool is_datasharing_compatible_with( + const fastrtps::rtps::WriterProxyData& wdata); + + /// Pointer to the listener associated with this reader. + fastrtps::rtps::ReaderListener* listener_; + /// Whether the reader accepts messages from unmatched writers. + bool accept_messages_from_unkown_writers_; + /// Whether the reader expects inline QoS. + bool expects_inline_qos_; + + /// The data filter associated with this reader. + IReaderDataFilter* data_filter_ = nullptr; + + /// The history record associated with this reader. + fastrtps::rtps::ReaderHistoryState* history_state_; + + /// Total number of unread samples in the history. + uint64_t total_unread_ = 0; + /// Condition variable to wait for unread samples. + fastrtps::TimedConditionVariable new_notification_cv_; + + /// The liveliness kind of this reader. + fastdds::dds::LivelinessQosPolicyKind liveliness_kind_; + /// The liveliness lease duration of this reader. + fastrtps::Duration_t liveliness_lease_duration_; + + /// Whether the reader is datasharing compatible. + bool is_datasharing_compatible_ = false; + /// The listener for the datasharing notifications. + std::unique_ptr datasharing_listener_; + + /// The liveliness changed status struct as defined in the DDS standard. + fastdds::dds::LivelinessChangedStatus liveliness_changed_status_; + + /// Trusted writer (for Builtin) + fastrtps::rtps::EntityId_t trusted_writer_entity_id_; + +private: + + /** + * @brief Perform pools related setup. + * This method is called from the constructor to perform the necessary setup for the payload and change pools. + * + * @param payload_pool Payload pool to use. + * @param change_pool Change pool to use. + */ + void init( + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool); + + /** + * @brief Perform datasharing related setup. + * This method is called from the constructor to perform the necessary setup for datasharing. + * If datasharing is enabled in the reader attributes, the method will create the necessary notification + * segment, along with the corresponding listener. + * + * @param att Attributes of the reader. + */ + void setup_datasharing( + const fastrtps::rtps::ReaderAttributes& att); + +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif /* RTPS_READER__BASEREADER_HPP */ diff --git a/src/cpp/rtps/reader/RTPSReader.cpp b/src/cpp/rtps/reader/RTPSReader.cpp index deb713a4a8f..d502f85eaf8 100644 --- a/src/cpp/rtps/reader/RTPSReader.cpp +++ b/src/cpp/rtps/reader/RTPSReader.cpp @@ -18,21 +18,12 @@ */ #include -#include -#include -#include - -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include + #include -#include -#include namespace eprosima { @@ -43,413 +34,20 @@ RTPSReader::RTPSReader( RTPSParticipantImpl* pimpl, const GUID_t& guid, const ReaderAttributes& att, - ReaderHistory* hist, - ReaderListener* rlisten) + ReaderHistory* hist) : Endpoint(pimpl, guid, att.endpoint) - , mp_history(hist) - , mp_listener(rlisten) - , m_acceptMessagesToUnknownReaders(true) - , m_acceptMessagesFromUnkownWriters(false) - , m_expectsInlineQos(att.expectsInlineQos) - , history_state_(new ReaderHistoryState(att.matched_writers_allocation.initial)) - , liveliness_kind_(att.liveliness_kind_) - , liveliness_lease_duration_(att.liveliness_lease_duration) -{ - PoolConfig cfg = PoolConfig::from_history_attributes(hist->m_att); - std::shared_ptr change_pool; - std::shared_ptr payload_pool; - payload_pool = BasicPayloadPool::get(cfg, change_pool); - - init(payload_pool, change_pool, att); -} - -RTPSReader::RTPSReader( - RTPSParticipantImpl* pimpl, - const GUID_t& guid, - const ReaderAttributes& att, - const std::shared_ptr& payload_pool, - ReaderHistory* hist, - ReaderListener* rlisten) - : RTPSReader( - pimpl, guid, att, payload_pool, - std::make_shared(PoolConfig::from_history_attributes(hist->m_att)), - hist, rlisten) + , history_(hist) { -} - -RTPSReader::RTPSReader( - RTPSParticipantImpl* pimpl, - const GUID_t& guid, - const ReaderAttributes& att, - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - ReaderHistory* hist, - ReaderListener* rlisten) - : Endpoint(pimpl, guid, att.endpoint) - , mp_history(hist) - , mp_listener(rlisten) - , m_acceptMessagesToUnknownReaders(true) - , m_acceptMessagesFromUnkownWriters(false) - , m_expectsInlineQos(att.expectsInlineQos) - , history_state_(new ReaderHistoryState(att.matched_writers_allocation.initial)) - , liveliness_kind_(att.liveliness_kind_) - , liveliness_lease_duration_(att.liveliness_lease_duration) -{ - init(payload_pool, change_pool, att); -} - -void RTPSReader::init( - const std::shared_ptr& payload_pool, - const std::shared_ptr& change_pool, - const ReaderAttributes& att) -{ - payload_pool_ = payload_pool; - change_pool_ = change_pool; - fixed_payload_size_ = 0; - if (mp_history->m_att.memoryPolicy == PREALLOCATED_MEMORY_MODE) - { - fixed_payload_size_ = mp_history->m_att.payloadMaxSize; - } - - if (att.endpoint.data_sharing_configuration().kind() != OFF) - { - using std::placeholders::_1; - std::shared_ptr notification = - DataSharingNotification::create_notification( - getGuid(), att.endpoint.data_sharing_configuration().shm_directory()); - if (notification) - { - is_datasharing_compatible_ = true; - datasharing_listener_.reset(new DataSharingListener( - notification, - att.endpoint.data_sharing_configuration().shm_directory(), - att.data_sharing_listener_thread, - att.matched_writers_allocation, - this)); - - // We can start the listener here, as no writer can be matched already, - // so no notification will occur until the non-virtual instance is constructed. - // But we need to stop the listener in the non-virtual instance destructor. - datasharing_listener_->start(); - } - } - - mp_history->mp_reader = this; - mp_history->mp_mutex = &mp_mutex; - - EPROSIMA_LOG_INFO(RTPS_READER, "RTPSReader created correctly"); + history_->mp_reader = this; + history_->mp_mutex = &mp_mutex; } RTPSReader::~RTPSReader() { - EPROSIMA_LOG_INFO(RTPS_READER, "Removing reader " << this->getGuid().entityId; ); - - for (auto it = mp_history->changesBegin(); it != mp_history->changesEnd(); ++it) - { - releaseCache(*it); - } - - delete history_state_; - mp_history->mp_reader = nullptr; - mp_history->mp_mutex = nullptr; -} - -bool RTPSReader::reserveCache( - CacheChange_t** change, - uint32_t dataCdrSerializedSize) -{ - std::lock_guard guard(mp_mutex); - - *change = nullptr; - - CacheChange_t* reserved_change = nullptr; - if (!change_pool_->reserve_cache(reserved_change)) - { - EPROSIMA_LOG_WARNING(RTPS_READER, "Problem reserving cache from pool"); - return false; - } - - uint32_t payload_size = fixed_payload_size_ ? fixed_payload_size_ : dataCdrSerializedSize; - if (!payload_pool_->get_payload(payload_size, *reserved_change)) - { - change_pool_->release_cache(reserved_change); - EPROSIMA_LOG_WARNING(RTPS_READER, "Problem reserving payload from pool"); - return false; - } - - *change = reserved_change; - return true; -} - -void RTPSReader::releaseCache( - CacheChange_t* change) -{ - std::lock_guard guard(mp_mutex); - - IPayloadPool* pool = change->payload_owner(); - if (pool) - { - pool->release_payload(*change); - } - change_pool_->release_cache(change); -} - -ReaderListener* RTPSReader::getListener() const -{ - return mp_listener; -} - -bool RTPSReader::setListener( - ReaderListener* target) -{ - std::lock_guard guard(mp_mutex); - mp_listener = target; - return true; -} - -History::const_iterator RTPSReader::findCacheInFragmentedProcess( - const SequenceNumber_t& sequence_number, - const GUID_t& writer_guid, - CacheChange_t** change, - History::const_iterator hint) const -{ - History::const_iterator ret_val = mp_history->get_change_nts(sequence_number, writer_guid, change, hint); - - if (nullptr != *change && (*change)->is_fully_assembled()) - { - *change = nullptr; - } - - return ret_val; -} - -void RTPSReader::add_persistence_guid( - const GUID_t& guid, - const GUID_t& persistence_guid) -{ - if (c_Guid_Unknown == persistence_guid || persistence_guid == guid) - { - std::lock_guard guard(mp_mutex); - history_state_->persistence_guid_map[guid] = guid; - history_state_->persistence_guid_count[guid]++; - } - else - { - std::lock_guard guard(mp_mutex); - history_state_->persistence_guid_map[guid] = persistence_guid; - history_state_->persistence_guid_count[persistence_guid]++; - - // Could happen that a value has already been stored in the record with the guid and not the persistence guid - // This is because received_change is called before Proxy is created - // In this case, we substitute the guid for the persistence (in case they are not equal) - auto spourious_record = history_state_->history_record.find(guid); - if (spourious_record != history_state_->history_record.end()) - { - EPROSIMA_LOG_INFO(RTPS_READER, "Sporious record found, changing guid " - << guid << " for persistence guid " << persistence_guid); - update_last_notified(guid, spourious_record->second); - history_state_->history_record.erase(spourious_record); - } - } + history_->mp_reader = nullptr; + history_->mp_mutex = nullptr; } -bool RTPSReader::may_remove_history_record( - bool removed_by_lease) -{ - return !removed_by_lease; -} - -void RTPSReader::remove_persistence_guid( - const GUID_t& guid, - const GUID_t& persistence_guid, - bool removed_by_lease) -{ - std::lock_guard guard(mp_mutex); - GUID_t persistence_guid_stored = (c_Guid_Unknown == persistence_guid) ? guid : persistence_guid; - history_state_->persistence_guid_map.erase(guid); - auto count = --history_state_->persistence_guid_count[persistence_guid_stored]; - if (count <= 0 && may_remove_history_record(removed_by_lease)) - { - history_state_->history_record.erase(persistence_guid_stored); - history_state_->persistence_guid_count.erase(persistence_guid_stored); - } -} - -SequenceNumber_t RTPSReader::update_last_notified( - const GUID_t& guid, - const SequenceNumber_t& seq) -{ - SequenceNumber_t ret_val; - std::lock_guard guard(mp_mutex); - GUID_t guid_to_look = guid; - auto p_guid = history_state_->persistence_guid_map.find(guid); - if (p_guid != history_state_->persistence_guid_map.end()) - { - guid_to_look = p_guid->second; - } - - auto p_seq = history_state_->history_record.find(guid_to_look); - if (p_seq != history_state_->history_record.end()) - { - ret_val = p_seq->second; - } - - if (ret_val < seq) - { - set_last_notified(guid_to_look, seq); - new_notification_cv_.notify_all(); - } - - return ret_val; -} - -SequenceNumber_t RTPSReader::get_last_notified( - const GUID_t& guid) -{ - SequenceNumber_t ret_val; - std::lock_guard guard(mp_mutex); - GUID_t guid_to_look = guid; - auto p_guid = history_state_->persistence_guid_map.find(guid); - if (p_guid != history_state_->persistence_guid_map.end()) - { - guid_to_look = p_guid->second; - } - - auto p_seq = history_state_->history_record.find(guid_to_look); - if (p_seq != history_state_->history_record.end()) - { - ret_val = p_seq->second; - } - - return ret_val; -} - -void RTPSReader::set_last_notified( - const GUID_t& peristence_guid, - const SequenceNumber_t& seq) -{ - history_state_->history_record[peristence_guid] = seq; -} - -bool RTPSReader::wait_for_unread_cache( - const eprosima::fastrtps::Duration_t& timeout) -{ - auto time_out = std::chrono::steady_clock::now() + std::chrono::seconds(timeout.seconds) + - std::chrono::nanoseconds(timeout.nanosec); - -#if HAVE_STRICT_REALTIME - std::unique_lock lock(mp_mutex, std::defer_lock); - if (lock.try_lock_until(time_out)) -#else - std::unique_lock lock(mp_mutex); -#endif // HAVE_STRICT_REALTIME - { - if (new_notification_cv_.wait_until( - lock, time_out, - [&]() - { - return total_unread_ > 0; - })) - { - return true; - } - } - - return false; -} - -uint64_t RTPSReader::get_unread_count() const -{ - std::unique_lock lock(mp_mutex); - return total_unread_; -} - -uint64_t RTPSReader::get_unread_count( - bool mark_as_read) -{ - std::unique_lock lock(mp_mutex); - uint64_t ret_val = total_unread_; - - if (mark_as_read) - { - for (auto it = mp_history->changesBegin(); 0 < total_unread_ && it != mp_history->changesEnd(); ++it) - { - CacheChange_t* change = *it; - if (!change->isRead && get_last_notified(change->writerGUID) >= change->sequenceNumber) - { - change->isRead = true; - assert(0 < total_unread_); - --total_unread_; - } - } - assert(0 == total_unread_); - } - return ret_val; -} - -bool RTPSReader::is_datasharing_compatible_with( - const WriterProxyData& wdata) -{ - if (!is_datasharing_compatible_ || - wdata.m_qos.data_sharing.kind() == fastdds::dds::OFF) - { - return false; - } - - for (auto id : wdata.m_qos.data_sharing.domain_ids()) - { - if (std::find(m_att.data_sharing_configuration().domain_ids().begin(), - m_att.data_sharing_configuration().domain_ids().end(), id) - != m_att.data_sharing_configuration().domain_ids().end()) - { - return true; - } - } - - return false; -} - -bool RTPSReader::is_sample_valid( - const void* data, - const GUID_t& writer, - const SequenceNumber_t& sn) const -{ - if (is_datasharing_compatible_ && datasharing_listener_->writer_is_matched(writer)) - { - // Check if the payload is dirty - // Note the Payloads used in loans include a mandatory RTPS 2.3 extra header - if (!DataSharingPayloadPool::check_sequence_number( - static_cast(data) - SerializedPayload_t::representation_header_size, - sn)) - { - return false; - } - } - return true; -} - -#ifdef FASTDDS_STATISTICS - -bool RTPSReader::add_statistics_listener( - std::shared_ptr listener) -{ - return add_statistics_listener_impl(listener); -} - -bool RTPSReader::remove_statistics_listener( - std::shared_ptr listener) -{ - return remove_statistics_listener_impl(listener); -} - -void RTPSReader::set_enabled_statistics_writers_mask( - uint32_t enabled_writers) -{ - set_enabled_statistics_writers_mask_impl(enabled_writers); -} - -#endif // FASTDDS_STATISTICS - } /* namespace rtps */ } /* namespace fastrtps */ } /* namespace eprosima */ diff --git a/src/cpp/rtps/reader/StatefulPersistentReader.cpp b/src/cpp/rtps/reader/StatefulPersistentReader.cpp index eff2ccb2e7d..943c41a7f82 100644 --- a/src/cpp/rtps/reader/StatefulPersistentReader.cpp +++ b/src/cpp/rtps/reader/StatefulPersistentReader.cpp @@ -90,7 +90,7 @@ StatefulPersistentReader::~StatefulPersistentReader() delete persistence_; } -void StatefulPersistentReader::set_last_notified( +void StatefulPersistentReader::persist_last_notified_nts( const GUID_t& writer_guid, const SequenceNumber_t& seq) { diff --git a/src/cpp/rtps/reader/StatefulPersistentReader.hpp b/src/cpp/rtps/reader/StatefulPersistentReader.hpp index 57d2aeba588..855352725af 100644 --- a/src/cpp/rtps/reader/StatefulPersistentReader.hpp +++ b/src/cpp/rtps/reader/StatefulPersistentReader.hpp @@ -70,7 +70,7 @@ class StatefulPersistentReader : public StatefulReader protected: - virtual void set_last_notified( + void persist_last_notified_nts( const GUID_t& persistence_guid, const SequenceNumber_t& seq) override; diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 5b0a18f61bb..28b8cd9aef6 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -46,6 +46,7 @@ #define IDSTRING "(ID:" << std::this_thread::get_id() << ") " << using namespace eprosima::fastrtps::rtps; +using BaseReader = eprosima::fastdds::rtps::BaseReader; static void send_datasharing_ack( StatefulReader* reader, @@ -126,7 +127,7 @@ StatefulReader::StatefulReader( const ReaderAttributes& att, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, hist, listen) + : BaseReader(pimpl, guid, att, hist, listen) , acknack_count_(0) , nackfrag_count_(0) , times_(att.times) @@ -146,7 +147,7 @@ StatefulReader::StatefulReader( const std::shared_ptr& payload_pool, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, payload_pool, hist, listen) + : BaseReader(pimpl, guid, att, payload_pool, hist, listen) , acknack_count_(0) , nackfrag_count_(0) , times_(att.times) @@ -167,7 +168,7 @@ StatefulReader::StatefulReader( const std::shared_ptr& change_pool, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, payload_pool, change_pool, hist, listen) + : BaseReader(pimpl, guid, att, payload_pool, change_pool, hist, listen) , acknack_count_(0) , nackfrag_count_(0) , times_(att.times) @@ -205,7 +206,7 @@ bool StatefulReader::matched_writer_add( return false; } - listener = mp_listener; + listener = listener_; bool is_same_process = RTPSDomainImpl::should_intraprocess_between(m_guid, wdata.guid()); bool is_datasharing = is_datasharing_compatible_with(wdata); @@ -218,7 +219,7 @@ bool StatefulReader::matched_writer_add( if (EXCLUSIVE_OWNERSHIP_QOS == m_att.ownershipKind && it->ownership_strength() != wdata.m_qos.m_ownershipStrength.value) { - mp_history->writer_update_its_ownership_strength_nts( + history_->writer_update_its_ownership_strength_nts( it->guid(), wdata.m_qos.m_ownershipStrength.value); } it->update(wdata); @@ -291,7 +292,7 @@ bool StatefulReader::matched_writer_add( { if (datasharing_listener_->add_datasharing_writer(wdata.guid(), m_att.durabilityKind == VOLATILE, - mp_history->m_att.maximumReservedCaches)) + history_->m_att.maximumReservedCaches)) { matched_writers_.push_back(wp); EPROSIMA_LOG_INFO(RTPS_READER, "Writer Proxy " << wdata.guid() << " added to " << this->m_guid.entityId @@ -390,11 +391,11 @@ bool StatefulReader::matched_writer_remove( if (writer_liveliness_status == LivelinessData::WriterStatus::ALIVE) { - wlp->update_liveliness_changed_status(writer_guid, this, -1, 0); + update_liveliness_changed_status(writer_guid, -1, 0); } else if (writer_liveliness_status == LivelinessData::WriterStatus::NOT_ALIVE) { - wlp->update_liveliness_changed_status(writer_guid, this, 0, -1); + update_liveliness_changed_status(writer_guid, 0, -1); } } @@ -410,7 +411,7 @@ bool StatefulReader::matched_writer_remove( if (is_alive_) { //Remove cachechanges belonging to the unmatched writer - mp_history->writer_unmatched(writer_guid, get_last_notified(writer_guid)); + history_->writer_unmatched(writer_guid, get_last_notified(writer_guid)); for (ResourceLimitedVector::iterator it = matched_writers_.begin(); it != matched_writers_.end(); @@ -445,10 +446,10 @@ bool StatefulReader::matched_writer_remove( lock.lock(); } matched_writers_pool_.push_back(wproxy); - if (nullptr != mp_listener) + if (nullptr != listener_) { // call the listener without the lock taken - ReaderListener* listener = mp_listener; + ReaderListener* listener = listener_; lock.unlock(); listener->on_writer_discovery(this, WriterDiscoveryInfo::REMOVED_WRITER, writer_guid, nullptr); } @@ -556,7 +557,7 @@ void StatefulReader::assert_writer_liveliness( } } -bool StatefulReader::processDataMsg( +bool StatefulReader::process_data_msg( CacheChange_t* change) { WriterProxy* pWP = nullptr; @@ -587,14 +588,14 @@ bool StatefulReader::processDataMsg( size_t unknown_missing_changes_up_to = pWP ? pWP->unknown_missing_changes_up_to(change->sequenceNumber) : 0; bool will_never_be_accepted = false; - if (!mp_history->can_change_be_added_nts(change->writerGUID, change->serializedPayload.length, + if (!history_->can_change_be_added_nts(change->writerGUID, change->serializedPayload.length, unknown_missing_changes_up_to, will_never_be_accepted)) { if (will_never_be_accepted && pWP) { pWP->irrelevant_change_set(change->sequenceNumber); NotifyChanges(pWP); - send_ack_if_datasharing(this, mp_history, pWP, change->sequenceNumber); + send_ack_if_datasharing(this, history_, pWP, change->sequenceNumber); } return false; } @@ -605,7 +606,7 @@ bool StatefulReader::processDataMsg( { pWP->irrelevant_change_set(change->sequenceNumber); NotifyChanges(pWP); - send_ack_if_datasharing(this, mp_history, pWP, change->sequenceNumber); + send_ack_if_datasharing(this, history_, pWP, change->sequenceNumber); } // Change was filtered out, so there isn't anything else to do return true; @@ -675,7 +676,7 @@ bool StatefulReader::processDataMsg( return false; } -bool StatefulReader::processDataFragMsg( +bool StatefulReader::process_data_frag_msg( CacheChange_t* incomingChange, uint32_t sampleSize, uint32_t fragmentStartingNum, @@ -711,14 +712,14 @@ bool StatefulReader::processDataFragMsg( size_t changes_up_to = pWP->unknown_missing_changes_up_to(incomingChange->sequenceNumber); bool will_never_be_accepted = false; - if (!mp_history->can_change_be_added_nts(incomingChange->writerGUID, sampleSize, changes_up_to, + if (!history_->can_change_be_added_nts(incomingChange->writerGUID, sampleSize, changes_up_to, will_never_be_accepted)) { if (will_never_be_accepted) { pWP->irrelevant_change_set(incomingChange->sequenceNumber); NotifyChanges(pWP); - send_ack_if_datasharing(this, mp_history, pWP, incomingChange->sequenceNumber); + send_ack_if_datasharing(this, history_, pWP, incomingChange->sequenceNumber); } return false; } @@ -727,14 +728,14 @@ bool StatefulReader::processDataFragMsg( CacheChange_t* change_created = nullptr; CacheChange_t* work_change = nullptr; - if (!mp_history->get_change(change_to_add->sequenceNumber, change_to_add->writerGUID, &work_change)) + if (!history_->get_change(change_to_add->sequenceNumber, change_to_add->writerGUID, &work_change)) { // A new change should be reserved - if (reserveCache(&work_change, sampleSize)) + if (reserve_cache(sampleSize, work_change)) { if (work_change->serializedPayload.max_size < sampleSize) { - releaseCache(work_change); + release_cache(work_change); work_change = nullptr; } else @@ -768,7 +769,7 @@ bool StatefulReader::processDataFragMsg( EPROSIMA_LOG_INFO(RTPS_MSG_IN, IDSTRING "MessageReceiver not add change " << change_created->sequenceNumber.to64long()); - releaseCache(change_created); + release_cache(change_created); work_change = nullptr; } } @@ -777,7 +778,7 @@ bool StatefulReader::processDataFragMsg( if (work_change != nullptr && work_change->is_fully_assembled()) { fastdds::dds::SampleRejectedStatusKind rejection_reason; - if (mp_history->completed_change(work_change, changes_up_to, rejection_reason)) + if (history_->completed_change(work_change, changes_up_to, rejection_reason)) { pWP->received_change_set(work_change->sequenceNumber); @@ -789,7 +790,7 @@ bool StatefulReader::processDataFragMsg( if (filtered_out) { - mp_history->remove_change(work_change); + history_->remove_change(work_change); } NotifyChanges(pWP); @@ -799,9 +800,9 @@ bool StatefulReader::processDataFragMsg( bool has_to_notify = false; if (fastdds::dds::NOT_REJECTED != rejection_reason) { - if (getListener()) + if (get_listener()) { - getListener()->on_sample_rejected((RTPSReader*)this, rejection_reason, work_change); + get_listener()->on_sample_rejected(this, rejection_reason, work_change); } /* Special case: rejected by REJECTED_BY_INSTANCES_LIMIT should never be received again. @@ -813,10 +814,10 @@ bool StatefulReader::processDataFragMsg( } } - History::const_iterator chit = mp_history->find_change_nts(work_change); - if (chit != mp_history->changesEnd()) + History::const_iterator chit = history_->find_change_nts(work_change); + if (chit != history_->changesEnd()) { - mp_history->remove_change_nts(chit); + history_->remove_change_nts(chit); } else { @@ -835,7 +836,7 @@ bool StatefulReader::processDataFragMsg( return true; } -bool StatefulReader::processHeartbeatMsg( +bool StatefulReader::process_heartbeat_msg( const GUID_t& writerGUID, uint32_t hbCount, const SequenceNumber_t& firstSN, @@ -860,13 +861,13 @@ bool StatefulReader::processHeartbeatMsg( hbCount, firstSN, lastSN, finalFlag, livelinessFlag, disable_positive_acks_, assert_liveliness, current_sample_lost)) { - mp_history->remove_fragmented_changes_until(firstSN, writerGUID); + history_->remove_fragmented_changes_until(firstSN, writerGUID); if (0 < current_sample_lost) { - if (getListener() != nullptr) + if (get_listener() != nullptr) { - getListener()->on_sample_lost((RTPSReader*)this, current_sample_lost); + get_listener()->on_sample_lost(this, current_sample_lost); } } @@ -905,7 +906,7 @@ bool StatefulReader::processHeartbeatMsg( return false; } -bool StatefulReader::processGapMsg( +bool StatefulReader::process_gap_msg( const GUID_t& writerGUID, const SequenceNumber_t& gapStart, const SequenceNumberSet_t& gapList, @@ -924,19 +925,19 @@ bool StatefulReader::processGapMsg( // TODO (Miguel C): Refactor this inside WriterProxy SequenceNumber_t auxSN; SequenceNumber_t finalSN = gapList.base(); - History::const_iterator history_iterator = mp_history->changesBegin(); + History::const_iterator history_iterator = history_->changesBegin(); for (auxSN = gapStart; auxSN < finalSN; auxSN++) { if (pWP->irrelevant_change_set(auxSN)) { CacheChange_t* to_remove = nullptr; - auto ret_iterator = findCacheInFragmentedProcess(auxSN, pWP->guid(), &to_remove, history_iterator); + auto ret_iterator = find_cache_in_fragmented_process(auxSN, pWP->guid(), to_remove, history_iterator); if (to_remove != nullptr) { // we called the History version to avoid callbacks - history_iterator = mp_history->History::remove_change_nts(ret_iterator); + history_iterator = history_->History::remove_change_nts(ret_iterator); } - else if (ret_iterator != mp_history->changesEnd()) + else if (ret_iterator != history_->changesEnd()) { history_iterator = ret_iterator; } @@ -950,13 +951,13 @@ bool StatefulReader::processGapMsg( { CacheChange_t* to_remove = nullptr; auto ret_iterator = - findCacheInFragmentedProcess(auxSN, pWP->guid(), &to_remove, history_iterator); + find_cache_in_fragmented_process(auxSN, pWP->guid(), to_remove, history_iterator); if (to_remove != nullptr) { // we called the History version to avoid callbacks - history_iterator = mp_history->History::remove_change_nts(ret_iterator); + history_iterator = history_->History::remove_change_nts(ret_iterator); } - else if (ret_iterator != mp_history->changesEnd()) + else if (ret_iterator != history_->changesEnd()) { history_iterator = ret_iterator; } @@ -987,10 +988,10 @@ bool StatefulReader::acceptMsgFrom( } } - // Check if it's a framework's one. In this case, m_acceptMessagesFromUnkownWriters + // Check if it's a framework's one. In this case, accept_messages_from_unkown_writers_ // is an enabler for the trusted entity comparison - if (m_acceptMessagesFromUnkownWriters - && (writerId.entityId == m_trustedWriterEntityId)) + if (accept_messages_from_unkown_writers_ + && (writerId.entityId == trusted_writer_entity_id_)) { *wp = nullptr; return true; @@ -999,9 +1000,24 @@ bool StatefulReader::acceptMsgFrom( return false; } +History::const_iterator StatefulReader::find_cache_in_fragmented_process( + const SequenceNumber_t& sequence_number, + const GUID_t& writer_guid, + CacheChange_t*& change, + History::const_iterator hint) const +{ + auto ret_val = history_->get_change_nts(sequence_number, writer_guid, &change, hint); + + if (nullptr != change && change->is_fully_assembled()) + { + change = nullptr; + } + + return ret_val; +} + bool StatefulReader::change_removed_by_history( - CacheChange_t* a_change, - WriterProxy* wp) + CacheChange_t* a_change) { std::lock_guard guard(mp_mutex); @@ -1018,19 +1034,15 @@ bool StatefulReader::change_removed_by_history( } } - WriterProxy* proxy = wp; - - if (nullptr == proxy) + WriterProxy* proxy = nullptr; + if (!findWriterProxy(a_change->writerGUID, &proxy)) { - if (!findWriterProxy(a_change->writerGUID, &proxy)) - { - return false; - } + return false; } if (nullptr != proxy) { - send_ack_if_datasharing(this, mp_history, proxy, a_change->sequenceNumber); + send_ack_if_datasharing(this, history_, proxy, a_change->sequenceNumber); } } else @@ -1038,19 +1050,14 @@ bool StatefulReader::change_removed_by_history( /* A not fully assembled fragmented sample may be removed when receiving a newer sample and KEEP_LAST * policy. The WriterProxy should consider it as irrelevant to avoid an infinite loop asking for it. */ - WriterProxy* proxy = wp; - - if (nullptr == proxy) + WriterProxy* proxy = nullptr; + if (!findWriterProxy(a_change->writerGUID, &proxy)) { - if (!findWriterProxy(a_change->writerGUID, &proxy)) - { - return false; - } - - proxy->irrelevant_change_set(a_change->sequenceNumber); - send_ack_if_datasharing(this, mp_history, proxy, a_change->sequenceNumber); + return false; } + proxy->irrelevant_change_set(a_change->sequenceNumber); + send_ack_if_datasharing(this, history_, proxy, a_change->sequenceNumber); } return true; @@ -1076,7 +1083,7 @@ bool StatefulReader::change_received( if (!findWriterProxy(a_change->writerGUID, &prox)) { // discard non framework messages from unknown writer - if (a_change->writerGUID.entityId != m_trustedWriterEntityId) + if (a_change->writerGUID.entityId != trusted_writer_entity_id_) { EPROSIMA_LOG_INFO(RTPS_READER, "Writer Proxy " << a_change->writerGUID << " not matched to this Reader " << m_guid.entityId); @@ -1093,7 +1100,7 @@ bool StatefulReader::change_received( // Only make visible the change if there is not other with bigger sequence number. if (get_last_notified(a_change->writerGUID) < a_change->sequenceNumber) { - if (mp_history->received_change(a_change, 0)) + if (history_->received_change(a_change, 0)) { Time_t::now(a_change->reader_info.receptionTimestamp); @@ -1102,7 +1109,7 @@ bool StatefulReader::change_received( // initialized using this SequenceNumber_t. Note that on a SERVER the own DATA(p) may be in any // position within the WriterHistory preventing effective data exchange. update_last_notified(a_change->writerGUID, SequenceNumber_t(0, 1)); - auto listener = getListener(); + auto listener = get_listener(); if (listener != nullptr) { bool notify_single = false; @@ -1111,7 +1118,7 @@ bool StatefulReader::change_received( listener->on_data_available(this, guid, seq, seq, notify_single); if (notify_single) { - listener->onNewCacheChangeAdded(this, a_change); + listener->on_new_cache_change_added(this, a_change); } } @@ -1142,9 +1149,9 @@ bool StatefulReader::change_received( } // NOTE: Depending on QoS settings, one change can be removed from history - // inside the call to mp_history->received_change + // inside the call to history_->received_change fastdds::dds::SampleRejectedStatusKind rejection_reason; - if (mp_history->received_change(a_change, unknown_missing_changes_up_to, rejection_reason)) + if (history_->received_change(a_change, unknown_missing_changes_up_to, rejection_reason)) { auto payload_length = a_change->serializedPayload.length; @@ -1159,10 +1166,10 @@ bool StatefulReader::change_received( /* Search if the first fragment was stored, because it may have been discarded due to being older and KEEP_LAST * policy. In this case this samples should be set as irrelevant. */ - if (mp_history->changesEnd() == mp_history->find_change(a_change)) + if (history_->changesEnd() == history_->find_change(a_change)) { prox->irrelevant_change_set(a_change->sequenceNumber); - send_ack_if_datasharing(this, mp_history, prox, a_change->sequenceNumber); + send_ack_if_datasharing(this, history_, prox, a_change->sequenceNumber); ret = false; } @@ -1182,9 +1189,9 @@ bool StatefulReader::change_received( { if (fastdds::dds::NOT_REJECTED != rejection_reason) { - if (getListener() && (a_change->is_fully_assembled() || (a_change->contains_first_fragment()))) + if (get_listener() && (a_change->is_fully_assembled() || (a_change->contains_first_fragment()))) { - getListener()->on_sample_rejected((RTPSReader*)this, rejection_reason, a_change); + get_listener()->on_sample_rejected(this, rejection_reason, a_change); } /* Special case: rejected by REJECTED_BY_INSTANCES_LIMIT should never be received again. @@ -1212,10 +1219,10 @@ void StatefulReader::NotifyChanges( // Update state before notifying update_last_notified(proxGUID, max_seq); - History::const_iterator it = mp_history->changesBegin(); + History::const_iterator it = history_->changesBegin(); SequenceNumber_t next_seq = first_seq; while (next_seq != c_SequenceNumber_Unknown && - mp_history->changesEnd() != (it = mp_history->get_change_nts(next_seq, proxGUID, &aux_ch, it)) && + history_->changesEnd() != (it = history_->get_change_nts(next_seq, proxGUID, &aux_ch, it)) && (*it)->sequenceNumber <= max_seq) { aux_ch = *it; @@ -1236,7 +1243,7 @@ void StatefulReader::NotifyChanges( } // Notify listener if new data is available - auto listener = getListener(); + auto listener = get_listener(); if (new_data_available && (nullptr != listener)) { bool notify_individual = false; @@ -1244,18 +1251,18 @@ void StatefulReader::NotifyChanges( if (notify_individual) { - it = mp_history->changesBegin(); + it = history_->changesBegin(); next_seq = first_seq; while (next_seq <= max_seq && - mp_history->changesEnd() != (it = mp_history->get_change_nts(next_seq, proxGUID, &aux_ch, it)) && + history_->changesEnd() != (it = history_->get_change_nts(next_seq, proxGUID, &aux_ch, it)) && (*it)->sequenceNumber <= max_seq) { aux_ch = *it; next_seq = aux_ch->sequenceNumber + 1; - listener->onNewCacheChangeAdded(this, aux_ch); + listener->on_new_cache_change_added(this, aux_ch); // Reset the iterator to the beginning, since it may be invalidated inside the callback - it = mp_history->changesBegin(); + it = history_->changesBegin(); } } } @@ -1273,8 +1280,8 @@ void StatefulReader::remove_changes_from( { std::lock_guard guard(mp_mutex); std::vector toremove; - for (std::vector::iterator it = mp_history->changesBegin(); - it != mp_history->changesEnd(); ++it) + for (std::vector::iterator it = history_->changesBegin(); + it != history_->changesEnd(); ++it) { if ((*it)->writerGUID == writerGUID) { @@ -1292,7 +1299,7 @@ void StatefulReader::remove_changes_from( (*it)->serializedPayload.data = nullptr; (*it)->payload_owner(nullptr); } - mp_history->remove_change(*it); + history_->remove_change(*it); } } @@ -1301,20 +1308,18 @@ ResourceEvent& StatefulReader::getEventResource() const return mp_RTPSParticipant->getEventResource(); } -bool StatefulReader::nextUntakenCache( - CacheChange_t** change, - WriterProxy** wpout) +CacheChange_t* StatefulReader::next_untaken_cache() { std::lock_guard guard(mp_mutex); if (!is_alive_) { - return false; + return nullptr; } bool takeok = false; WriterProxy* wp; - std::vector::iterator it = mp_history->changesBegin(); - while (it != mp_history->changesEnd()) + std::vector::iterator it = history_->changesBegin(); + while (it != history_->changesEnd()) { if (this->matched_writer_lookup((*it)->writerGUID, &wp)) { @@ -1333,42 +1338,32 @@ bool StatefulReader::nextUntakenCache( EPROSIMA_LOG_WARNING(RTPS_READER, "Removing change " << (*it)->sequenceNumber << " from " << (*it)->writerGUID << " because is no longer paired"); - it = mp_history->remove_change(it); + it = history_->remove_change(it); } if (takeok) { - - *change = *it; - - if (wpout != nullptr) - { - *wpout = wp; - } - - break; + return *it; } } - return takeok; + return nullptr; } // TODO Porque elimina aqui y no cuando hay unpairing -bool StatefulReader::nextUnreadCache( - CacheChange_t** change, - WriterProxy** wpout) +CacheChange_t* StatefulReader::next_unread_cache() { std::lock_guard guard(mp_mutex); if (!is_alive_) { - return false; + return nullptr; } std::vector toremove; bool readok = false; WriterProxy* wp = nullptr; - std::vector::iterator it = mp_history->changesBegin(); - while (it != mp_history->changesEnd()) + std::vector::iterator it = history_->changesBegin(); + while (it != history_->changesEnd()) { if ((*it)->isRead) { @@ -1392,25 +1387,17 @@ bool StatefulReader::nextUnreadCache( EPROSIMA_LOG_WARNING(RTPS_READER, "Removing change " << (*it)->sequenceNumber << " from " << (*it)->writerGUID << " because is no longer paired"); - it = mp_history->remove_change(it); + it = history_->remove_change(it); continue; } if (readok) { - - *change = *it; - - if (wpout != nullptr) - { - *wpout = wp; - } - - break; + return *it; } } - return readok; + return nullptr; } bool StatefulReader::updateTimes( @@ -1419,19 +1406,19 @@ bool StatefulReader::updateTimes( std::lock_guard guard(mp_mutex); if (is_alive_) { - if (times_.heartbeatResponseDelay != ti.heartbeatResponseDelay) + if (times_.heartbeat_response_delay != ti.heartbeat_response_delay) { times_ = ti; for (WriterProxy* writer : matched_writers_) { - writer->update_heartbeat_response_interval(times_.heartbeatResponseDelay); + writer->update_heartbeat_response_interval(times_.heartbeat_response_delay); } } } return true; } -bool StatefulReader::isInCleanState() +bool StatefulReader::is_in_clean_state() { std::unique_lock lock(mp_mutex); @@ -1451,16 +1438,16 @@ bool StatefulReader::isInCleanState() bool StatefulReader::begin_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, + WriterProxy*& writer, bool& is_future_change) { const GUID_t& writer_guid = change->writerGUID; is_future_change = false; - if (matched_writer_lookup(writer_guid, &wp)) + if (matched_writer_lookup(writer_guid, &writer)) { SequenceNumber_t seq; - seq = wp->available_changes_max(); + seq = writer->available_changes_max(); if (seq < change->sequenceNumber) { is_future_change = true; @@ -1472,15 +1459,7 @@ bool StatefulReader::begin_sample_access_nts( void StatefulReader::end_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, - bool mark_as_read) -{ - change_read_by_user(change, wp, mark_as_read); -} - -void StatefulReader::change_read_by_user( - CacheChange_t* change, - WriterProxy* writer, + WriterProxy*& writer, bool mark_as_read) { assert(!writer || change->writerGUID == writer->guid()); @@ -1497,7 +1476,7 @@ void StatefulReader::change_read_by_user( if (mark_as_read) { - send_ack_if_datasharing(this, mp_history, writer, change->sequenceNumber); + send_ack_if_datasharing(this, history_, writer, change->sequenceNumber); } } @@ -1592,7 +1571,7 @@ void StatefulReader::send_acknack( } // ACKNACK for datasharing writers is done for changes with status READ, not on reception - // This is handled in change_read_by_user + // This is handled in end_sample_access_nts if (writer->is_datasharing_writer()) { return; @@ -1607,19 +1586,20 @@ void StatefulReader::send_acknack( { GUID_t guid = sender->remote_guids().at(0); SequenceNumberSet_t sns(writer->available_changes_max() + 1); - History::const_iterator history_iterator = mp_history->changesBegin(); + History::const_iterator history_iterator = history_->changesBegin(); missing_changes.for_each( [&](const SequenceNumber_t& seq) { // Check if the CacheChange_t is uncompleted. - CacheChange_t* uncomplete_change = nullptr; - auto ret_iterator = findCacheInFragmentedProcess(seq, guid, &uncomplete_change, history_iterator); - if (ret_iterator != mp_history->changesEnd()) + CacheChange_t* incomplete_change = nullptr; + auto ret_iterator = find_cache_in_fragmented_process( + seq, guid, incomplete_change, history_iterator); + if (ret_iterator != history_->changesEnd()) { history_iterator = ret_iterator; } - if (uncomplete_change == nullptr) + if (incomplete_change == nullptr) { if (!sns.add(seq)) { @@ -1632,7 +1612,7 @@ void StatefulReader::send_acknack( else { FragmentNumberSet_t frag_sns; - uncomplete_change->get_missing_fragments(frag_sns); + incomplete_change->get_missing_fragments(frag_sns); ++nackfrag_count_; EPROSIMA_LOG_INFO(RTPS_READER, "Sending NACKFRAG for sample" << seq << ": " << frag_sns; ); diff --git a/src/cpp/rtps/reader/StatefulReader.hpp b/src/cpp/rtps/reader/StatefulReader.hpp index 1b4d5df1e44..861b36a4038 100644 --- a/src/cpp/rtps/reader/StatefulReader.hpp +++ b/src/cpp/rtps/reader/StatefulReader.hpp @@ -28,6 +28,8 @@ #include #include +#include + namespace eprosima { namespace fastrtps { namespace rtps { @@ -36,10 +38,10 @@ class WriterProxy; class RTPSMessageSenderInterface; /** - * Class StatefulReader, specialization of RTPSReader than stores the state of the matched writers. + * Class StatefulReader, specialization of BaseReader that stores the state of the matched writers. * @ingroup READER_MODULE */ -class StatefulReader : public RTPSReader +class StatefulReader : public fastdds::rtps::BaseReader { public: @@ -116,7 +118,7 @@ class StatefulReader : public RTPSReader * @param change Pointer to the CacheChange_t. * @return true if the reader accepts messages. */ - bool processDataMsg( + bool process_data_msg( CacheChange_t* change) override; /** @@ -128,7 +130,7 @@ class StatefulReader : public RTPSReader * @param fragmentsInSubmessage Number of fragments on this particular message. * @return true if the reader accepts message. */ - bool processDataFragMsg( + bool process_data_frag_msg( CacheChange_t* change, uint32_t sampleSize, uint32_t fragmentStartingNum, @@ -139,7 +141,7 @@ class StatefulReader : public RTPSReader * * @return true if the reader accepts messages. */ - bool processHeartbeatMsg( + bool process_heartbeat_msg( const GUID_t& writerGUID, uint32_t hbCount, const SequenceNumber_t& firstSN, @@ -148,7 +150,7 @@ class StatefulReader : public RTPSReader bool livelinessFlag, fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) override; - bool processGapMsg( + bool process_gap_msg( const GUID_t& writerGUID, const SequenceNumber_t& gapStart, const SequenceNumberSet_t& gapList, @@ -161,8 +163,7 @@ class StatefulReader : public RTPSReader * @return True if correctly removed. */ bool change_removed_by_history( - CacheChange_t* change, - WriterProxy* prox = nullptr) override; + CacheChange_t* change) override; /** * This method is called when a new change is received. This method calls the received_change of the History @@ -193,25 +194,9 @@ class StatefulReader : public RTPSReader */ ResourceEvent& getEventResource() const; - /** - * Read the next unread CacheChange_t from the history - * @param change Pointer to pointer of CacheChange_t - * @param wpout Pointer to pointer the matched writer proxy - * @return True if read. - */ - bool nextUnreadCache( - CacheChange_t** change, - WriterProxy** wpout = nullptr) override; + CacheChange_t* next_unread_cache() override; - /** - * Take the next CacheChange_t from the history; - * @param change Pointer to pointer of CacheChange_t - * @param wpout Pointer to pointer the matched writer proxy - * @return True if read. - */ - bool nextUntakenCache( - CacheChange_t** change, - WriterProxy** wpout = nullptr) override; + CacheChange_t* next_untaken_cache() override; /** * Update the times parameters of the Reader. @@ -245,7 +230,7 @@ class StatefulReader : public RTPSReader * its WriterProxies are up to date. * @return There is a clean state with all Writers. */ - bool isInCleanState() override; + bool is_in_clean_state() override; /** * Sends an acknack message from this reader. @@ -294,7 +279,7 @@ class StatefulReader : public RTPSReader /** * Called just before a change is going to be deserialized. * @param [in] change Pointer to the change being accessed. - * @param [out] wp Writer proxy the @c change belongs to. + * @param [out] writer Writer proxy the @c change belongs to. * @param [out] is_future_change Whether the change is in the future (i.e. there are * earlier unreceived changes from the same writer). * @@ -302,31 +287,20 @@ class StatefulReader : public RTPSReader */ bool begin_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, + WriterProxy*& writer, bool& is_future_change) override; /** * Called after the change has been deserialized. * @param [in] change Pointer to the change being accessed. - * @param [in] wp Writer proxy the @c change belongs to. + * @param [in] writer Writer proxy the @c change belongs to. * @param [in] mark_as_read Whether the @c change should be marked as read or not. */ void end_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, + WriterProxy*& writer, bool mark_as_read) override; - /** - * Called when the user has retrieved a change from the history. - * @param change Pointer to the change to ACK - * @param writer Writer proxy of the \c change. - * @param mark_as_read Whether the \c change should be marked as read or not - */ - void change_read_by_user( - CacheChange_t* change, - WriterProxy* writer, - bool mark_as_read = true) override; - #ifdef FASTDDS_STATISTICS bool get_connections( fastdds::statistics::rtps::ConnectionList& connection_list) override; @@ -342,6 +316,23 @@ class StatefulReader : public RTPSReader const GUID_t& entityGUID, WriterProxy** wp) const; + /*! + * @brief Search for an incomplete (i.e. fragments pending) change, given its sequence number and writer's GUID. + * + * @param sequence_number [in] Sequence number of the change to search. + * @param writer_guid [in] Writer's GUID of the change to search. + * @param change [out] Pointer to the incomplete change if found, nullptr otherwise. + * @param hint [in] Iterator to start searching from. Used to improve the search. + * + * @return Iterator pointing to the position were the change was found. + * It can be used to improve the following call to this same method. + */ + fastrtps::rtps::History::const_iterator find_cache_in_fragmented_process( + const fastrtps::rtps::SequenceNumber_t& sequence_number, + const fastrtps::rtps::GUID_t& writer_guid, + fastrtps::rtps::CacheChange_t*& change, + fastrtps::rtps::History::const_iterator hint) const; + /*! * @remarks Non thread-safe. */ diff --git a/src/cpp/rtps/reader/StatelessPersistentReader.cpp b/src/cpp/rtps/reader/StatelessPersistentReader.cpp index d82a2b4c179..ced2fb31f3f 100644 --- a/src/cpp/rtps/reader/StatelessPersistentReader.cpp +++ b/src/cpp/rtps/reader/StatelessPersistentReader.cpp @@ -90,7 +90,7 @@ StatelessPersistentReader::~StatelessPersistentReader() delete persistence_; } -void StatelessPersistentReader::set_last_notified( +void StatelessPersistentReader::persist_last_notified_nts( const GUID_t& writer_guid, const SequenceNumber_t& seq) { diff --git a/src/cpp/rtps/reader/StatelessPersistentReader.hpp b/src/cpp/rtps/reader/StatelessPersistentReader.hpp index b8f90f35109..3e05868f632 100644 --- a/src/cpp/rtps/reader/StatelessPersistentReader.hpp +++ b/src/cpp/rtps/reader/StatelessPersistentReader.hpp @@ -70,7 +70,7 @@ class StatelessPersistentReader : public StatelessReader protected: - virtual void set_last_notified( + void persist_last_notified_nts( const GUID_t& persistence_guid, const SequenceNumber_t& seq) override; diff --git a/src/cpp/rtps/reader/StatelessReader.cpp b/src/cpp/rtps/reader/StatelessReader.cpp index b9d55382392..49df5b137da 100644 --- a/src/cpp/rtps/reader/StatelessReader.cpp +++ b/src/cpp/rtps/reader/StatelessReader.cpp @@ -43,6 +43,7 @@ #define IDSTRING "(ID:" << std::this_thread::get_id() << ") " << using namespace eprosima::fastrtps::rtps; +using BaseReader = eprosima::fastdds::rtps::BaseReader; StatelessReader::~StatelessReader() { @@ -62,7 +63,7 @@ StatelessReader::StatelessReader( const ReaderAttributes& att, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, hist, listen) + : BaseReader(pimpl, guid, att, hist, listen) , matched_writers_(att.matched_writers_allocation) { } @@ -74,7 +75,7 @@ StatelessReader::StatelessReader( const std::shared_ptr& payload_pool, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, payload_pool, hist, listen) + : BaseReader(pimpl, guid, att, payload_pool, hist, listen) , matched_writers_(att.matched_writers_allocation) { } @@ -87,7 +88,7 @@ StatelessReader::StatelessReader( const std::shared_ptr& change_pool, ReaderHistory* hist, ReaderListener* listen) - : RTPSReader(pimpl, guid, att, payload_pool, change_pool, hist, listen) + : BaseReader(pimpl, guid, att, payload_pool, change_pool, hist, listen) , matched_writers_(att.matched_writers_allocation) { } @@ -99,7 +100,7 @@ bool StatelessReader::matched_writer_add( { std::unique_lock guard(mp_mutex); - listener = mp_listener; + listener = listener_; for (RemoteWriterInfo_t& writer : matched_writers_) { @@ -110,7 +111,7 @@ bool StatelessReader::matched_writer_add( if (EXCLUSIVE_OWNERSHIP_QOS == m_att.ownershipKind && writer.ownership_strength != wdata.m_qos.m_ownershipStrength.value) { - mp_history->writer_update_its_ownership_strength_nts( + history_->writer_update_its_ownership_strength_nts( writer.guid, wdata.m_qos.m_ownershipStrength.value); } writer.ownership_strength = wdata.m_qos.m_ownershipStrength.value; @@ -150,7 +151,7 @@ bool StatelessReader::matched_writer_add( { if (datasharing_listener_->add_datasharing_writer(wdata.guid(), m_att.durabilityKind == VOLATILE, - mp_history->m_att.maximumReservedCaches)) + history_->m_att.maximumReservedCaches)) { EPROSIMA_LOG_INFO(RTPS_READER, "Writer Proxy " << wdata.guid() << " added to " << this->m_guid.entityId << " with data sharing"); @@ -178,7 +179,7 @@ bool StatelessReader::matched_writer_add( add_persistence_guid(info.guid, info.persistence_guid); - m_acceptMessagesFromUnkownWriters = false; + accept_messages_from_unkown_writers_ = false; // Intraprocess manages durability itself if (is_datasharing && !is_same_process && m_att.durabilityKind != VOLATILE) @@ -240,11 +241,11 @@ bool StatelessReader::matched_writer_remove( if (writer_liveliness_status == LivelinessData::WriterStatus::ALIVE) { - wlp->update_liveliness_changed_status(writer_guid, this, -1, 0); + update_liveliness_changed_status(writer_guid, -1, 0); } else if (writer_liveliness_status == LivelinessData::WriterStatus::NOT_ALIVE) { - wlp->update_liveliness_changed_status(writer_guid, this, 0, -1); + update_liveliness_changed_status(writer_guid, 0, -1); } } else @@ -257,7 +258,7 @@ bool StatelessReader::matched_writer_remove( std::unique_lock guard(mp_mutex); //Remove cachechanges belonging to the unmatched writer - mp_history->writer_unmatched(writer_guid, get_last_notified(writer_guid)); + history_->writer_unmatched(writer_guid, get_last_notified(writer_guid)); ResourceLimitedVector::iterator it; for (it = matched_writers_.begin(); it != matched_writers_.end(); ++it) @@ -275,10 +276,10 @@ bool StatelessReader::matched_writer_remove( remove_persistence_guid(it->guid, it->persistence_guid, removed_by_lease); matched_writers_.erase(it); - if (nullptr != mp_listener) + if (nullptr != listener_) { // call the listener without lock - ReaderListener* listener = mp_listener; + ReaderListener* listener = listener_; guard.unlock(); listener->on_writer_discovery(this, WriterDiscoveryInfo::REMOVED_WRITER, writer_guid, nullptr); } @@ -326,7 +327,7 @@ bool StatelessReader::change_received( decltype(matched_writers_)::iterator writer = matched_writers_.end(); if ((EXCLUSIVE_OWNERSHIP_QOS == m_att.ownershipKind) || - (m_trustedWriterEntityId == change->writerGUID.entityId)) + (trusted_writer_entity_id_ == change->writerGUID.entityId)) { writer = std::find_if(matched_writers_.begin(), matched_writers_.end(), [change](const RemoteWriterInfo_t& item) @@ -348,7 +349,7 @@ bool StatelessReader::change_received( change->reader_info.writer_ownership_strength = (std::numeric_limits::max)(); } - if (mp_history->received_change(change, 0)) + if (history_->received_change(change, 0)) { auto payload_length = change->serializedPayload.length; auto guid = change->writerGUID; @@ -364,7 +365,7 @@ bool StatelessReader::change_received( on_data_notify(guid, change->sourceTimestamp); - auto listener = getListener(); + auto listener = get_listener(); if (listener != nullptr) { if (SequenceNumber_t{0, 0} != previous_seq) @@ -384,7 +385,7 @@ bool StatelessReader::change_received( listener->on_data_available(this, guid, seq, seq, notify_single); if (notify_single) { - listener->onNewCacheChangeAdded(this, change); + listener->on_new_cache_change_added(this, change); } } @@ -406,8 +407,8 @@ void StatelessReader::remove_changes_from( { std::lock_guard guard(mp_mutex); std::vector toremove; - for (std::vector::iterator it = mp_history->changesBegin(); - it != mp_history->changesEnd(); ++it) + for (std::vector::iterator it = history_->changesBegin(); + it != history_->changesEnd(); ++it) { if ((*it)->writerGUID == writerGUID) { @@ -425,26 +426,28 @@ void StatelessReader::remove_changes_from( (*it)->serializedPayload.data = nullptr; (*it)->payload_owner(nullptr); } - mp_history->remove_change(*it); + history_->remove_change(*it); } } -bool StatelessReader::nextUntakenCache( - CacheChange_t** change, - WriterProxy** /*wpout*/) +CacheChange_t* StatelessReader::next_untaken_cache() { std::lock_guard guard(mp_mutex); - return mp_history->get_min_change(change); + CacheChange_t* change = nullptr; + if (history_->get_min_change(&change)) + { + return change; + } + + return nullptr; } -bool StatelessReader::nextUnreadCache( - CacheChange_t** change, - WriterProxy** /*wpout*/) +CacheChange_t* StatelessReader::next_unread_cache() { std::lock_guard guard(mp_mutex); bool found = false; - std::vector::iterator it = mp_history->changesBegin(); - while (it != mp_history->changesEnd()) + std::vector::iterator it = history_->changesBegin(); + while (it != history_->changesEnd()) { if ((*it)->isRead) { @@ -458,19 +461,15 @@ bool StatelessReader::nextUnreadCache( if (found) { - *change = *it; - } - else - { - EPROSIMA_LOG_INFO(RTPS_READER, "No Unread elements left"); + return *it; } - return found; + EPROSIMA_LOG_INFO(RTPS_READER, "No Unread elements left"); + return nullptr; } bool StatelessReader::change_removed_by_history( - CacheChange_t* ch, - WriterProxy* /*prox*/) + CacheChange_t* ch) { if (!ch->isRead) { @@ -485,7 +484,7 @@ bool StatelessReader::change_removed_by_history( bool StatelessReader::begin_sample_access_nts( CacheChange_t* /*change*/, - WriterProxy*& /*wp*/, + WriterProxy*& /*writer*/, bool& is_future_change) { is_future_change = false; @@ -494,15 +493,7 @@ bool StatelessReader::begin_sample_access_nts( void StatelessReader::end_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, - bool mark_as_read) -{ - change_read_by_user(change, wp, mark_as_read); -} - -void StatelessReader::change_read_by_user( - CacheChange_t* change, - WriterProxy* /*writer*/, + WriterProxy*& /*writer*/, bool mark_as_read) { // Mark change as read @@ -514,7 +505,6 @@ void StatelessReader::change_read_by_user( --total_unread_; } } - } #ifdef FASTDDS_STATISTICS @@ -558,7 +548,7 @@ bool StatelessReader::get_connections( #endif // ifdef FASTDDS_STATISTICS -bool StatelessReader::processDataMsg( +bool StatelessReader::process_data_msg( CacheChange_t* change) { assert(change); @@ -582,7 +572,7 @@ bool StatelessReader::processDataMsg( if (!thereIsUpperRecordOf(change->writerGUID, change->sequenceNumber)) { bool will_never_be_accepted = false; - if (!mp_history->can_change_be_added_nts(change->writerGUID, change->serializedPayload.length, 0, + if (!history_->can_change_be_added_nts(change->writerGUID, change->serializedPayload.length, 0, will_never_be_accepted)) { if (will_never_be_accepted) @@ -668,7 +658,7 @@ bool StatelessReader::processDataMsg( return true; } -bool StatelessReader::processDataFragMsg( +bool StatelessReader::process_data_frag_msg( CacheChange_t* incomingChange, uint32_t sampleSize, uint32_t fragmentStartingNum, @@ -709,7 +699,7 @@ bool StatelessReader::processDataFragMsg( } bool will_never_be_accepted = false; - if (!mp_history->can_change_be_added_nts(writer_guid, sampleSize, 0, will_never_be_accepted)) + if (!history_->can_change_be_added_nts(writer_guid, sampleSize, 0, will_never_be_accepted)) { if (will_never_be_accepted) { @@ -730,7 +720,7 @@ bool StatelessReader::processDataFragMsg( previous_seq = update_last_notified(writer_guid, updated_seq); // Notify lost samples - auto listener = getListener(); + auto listener = get_listener(); if (listener != nullptr) { if (SequenceNumber_t{ 0, 0 } != previous_seq) @@ -757,7 +747,7 @@ bool StatelessReader::processDataFragMsg( else { // Release change, and let it be reserved later - releaseCache(work_change); + release_cache(work_change); work_change = nullptr; } } @@ -766,11 +756,11 @@ bool StatelessReader::processDataFragMsg( // Check if a new change should be reserved if (work_change == nullptr) { - if (reserveCache(&work_change, sampleSize)) + if (reserve_cache(sampleSize, work_change)) { if (work_change->serializedPayload.max_size < sampleSize) { - releaseCache(work_change); + release_cache(work_change); work_change = nullptr; } else @@ -815,7 +805,7 @@ bool StatelessReader::processDataFragMsg( if (filtered_out) { update_last_notified(change_completed->writerGUID, change_completed->sequenceNumber); - releaseCache(change_completed); + release_cache(change_completed); } else if (!change_received(change_completed)) { @@ -824,7 +814,7 @@ bool StatelessReader::processDataFragMsg( change_completed->sequenceNumber.to64long()); // Release CacheChange_t. - releaseCache(change_completed); + release_cache(change_completed); } } } @@ -838,7 +828,7 @@ bool StatelessReader::processDataFragMsg( return true; } -bool StatelessReader::processHeartbeatMsg( +bool StatelessReader::process_heartbeat_msg( const GUID_t& /*writerGUID*/, uint32_t /*hbCount*/, const SequenceNumber_t& /*firstSN*/, @@ -850,7 +840,7 @@ bool StatelessReader::processHeartbeatMsg( return true; } -bool StatelessReader::processGapMsg( +bool StatelessReader::process_gap_msg( const GUID_t& /*writerGUID*/, const SequenceNumber_t& /*gapStart*/, const SequenceNumberSet_t& /*gapList*/, @@ -865,11 +855,11 @@ bool StatelessReader::acceptMsgFrom( { if (change_kind == ChangeKind_t::ALIVE) { - if (m_acceptMessagesFromUnkownWriters) + if (accept_messages_from_unkown_writers_) { return true; } - else if (writerId.entityId == m_trustedWriterEntityId) + else if (writerId.entityId == trusted_writer_entity_id_) { return true; } diff --git a/src/cpp/rtps/reader/StatelessReader.hpp b/src/cpp/rtps/reader/StatelessReader.hpp index 7ee0d1ad753..ebfb77e7549 100644 --- a/src/cpp/rtps/reader/StatelessReader.hpp +++ b/src/cpp/rtps/reader/StatelessReader.hpp @@ -29,6 +29,8 @@ #include #include +#include + namespace eprosima { namespace fastrtps { namespace rtps { @@ -37,7 +39,7 @@ namespace rtps { * Class StatelessReader, specialization of the RTPSReader for Best Effort Readers. * @ingroup READER_MODULE */ -class StatelessReader : public RTPSReader +class StatelessReader : public fastdds::rtps::BaseReader { friend class RTPSParticipantImpl; @@ -106,8 +108,7 @@ class StatelessReader : public RTPSReader * @return True if correctly removed. */ bool change_removed_by_history( - CacheChange_t* change, - WriterProxy* prox = nullptr) override; + CacheChange_t* change) override; /** * Processes a new DATA message. @@ -115,7 +116,7 @@ class StatelessReader : public RTPSReader * @param change Pointer to the CacheChange_t. * @return true if the reader accepts messages from the. */ - bool processDataMsg( + bool process_data_msg( CacheChange_t* change) override; /** @@ -127,7 +128,7 @@ class StatelessReader : public RTPSReader * @param fragmentsInSubmessage Number of fragments on this particular message. * @return true if the reader accepts message. */ - bool processDataFragMsg( + bool process_data_frag_msg( CacheChange_t* change, uint32_t sampleSize, uint32_t fragmentStartingNum, @@ -138,7 +139,7 @@ class StatelessReader : public RTPSReader * * @return true if the reader accepts messages from the. */ - bool processHeartbeatMsg( + bool process_heartbeat_msg( const GUID_t& writerGUID, uint32_t hbCount, const SequenceNumber_t& firstSN, @@ -147,7 +148,7 @@ class StatelessReader : public RTPSReader bool livelinessFlag, fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) override; - bool processGapMsg( + bool process_gap_msg( const GUID_t& writerGUID, const SequenceNumber_t& gapStart, const SequenceNumberSet_t& gapList, @@ -162,25 +163,9 @@ class StatelessReader : public RTPSReader bool change_received( CacheChange_t* a_change); - /** - * Read the next unread CacheChange_t from the history - * @param change Pointer to pointer of CacheChange_t - * @param wpout Pointer to pointer of the matched writer proxy - * @return True if read. - */ - bool nextUnreadCache( - CacheChange_t** change, - WriterProxy** wpout = nullptr) override; + CacheChange_t* next_unread_cache() override; - /** - * Take the next CacheChange_t from the history; - * @param change Pointer to pointer of CacheChange_t - * @param wpout Pointer to pointer of the matched writer proxy - * @return True if read. - */ - bool nextUntakenCache( - CacheChange_t** change, - WriterProxy** wpout = nullptr) override; + CacheChange_t* next_untaken_cache() override; /** * Get the number of matched writers @@ -196,7 +181,7 @@ class StatelessReader : public RTPSReader * StatelessReader allways return true; * @return true */ - bool isInCleanState() override + bool is_in_clean_state() override { return true; } @@ -220,7 +205,7 @@ class StatelessReader : public RTPSReader /** * Called just before a change is going to be deserialized. * @param [in] change Pointer to the change being accessed. - * @param [out] wp Writer proxy the @c change belongs to. + * @param [out] writer Writer proxy the @c change belongs to. * @param [out] is_future_change Whether the change is in the future (i.e. there are * earlier unreceived changes from the same writer). * @@ -228,31 +213,20 @@ class StatelessReader : public RTPSReader */ bool begin_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, + WriterProxy*& writer, bool& is_future_change) override; /** * Called after the change has been deserialized. * @param [in] change Pointer to the change being accessed. - * @param [in] wp Writer proxy the @c change belongs to. + * @param [in] writer Writer proxy the @c change belongs to. * @param [in] mark_as_read Whether the @c change should be marked as read or not. */ void end_sample_access_nts( CacheChange_t* change, - WriterProxy*& wp, + WriterProxy*& writer, bool mark_as_read) override; - /** - * Called when the user has retrieved a change from the history. - * @param change Pointer to the change to ACK - * @param writer Writer proxy of the \c change. - * @param mark_as_read Whether the \c change should be marked as read or not - */ - void change_read_by_user( - CacheChange_t* change, - WriterProxy* writer, - bool mark_as_read = true) override; - #ifdef FASTDDS_STATISTICS bool get_connections( fastdds::statistics::rtps::ConnectionList& connection_list) override; diff --git a/src/cpp/rtps/reader/WriterProxy.cpp b/src/cpp/rtps/reader/WriterProxy.cpp index e631ad09215..0a5a4d25054 100644 --- a/src/cpp/rtps/reader/WriterProxy.cpp +++ b/src/cpp/rtps/reader/WriterProxy.cpp @@ -127,8 +127,8 @@ void WriterProxy::start( assert(get_mutex_owner() == get_thread_id()); #endif // SHOULD_DEBUG_LINUX - heartbeat_response_->update_interval(reader_->getTimes().heartbeatResponseDelay); - initial_acknack_->update_interval(reader_->getTimes().initialAcknackDelay); + heartbeat_response_->update_interval(reader_->getTimes().heartbeat_response_delay); + initial_acknack_->update_interval(reader_->getTimes().initial_acknack_delay); locators_entry_.remote_guid = attributes.guid(); guid_as_vector_.push_back(attributes.guid()); diff --git a/src/cpp/rtps/security/SecurityManager.cpp b/src/cpp/rtps/security/SecurityManager.cpp index 7469e4bfa4d..b07b93c74cf 100644 --- a/src/cpp/rtps/security/SecurityManager.cpp +++ b/src/cpp/rtps/security/SecurityManager.cpp @@ -1920,24 +1920,24 @@ void SecurityManager::process_participant_volatile_message_secure( } } -void SecurityManager::ParticipantStatelessMessageListener::onNewCacheChangeAdded( +void SecurityManager::ParticipantStatelessMessageListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { manager_.process_participant_stateless_message(change); - ReaderHistory* history = reader->getHistory(); + ReaderHistory* history = reader->get_history(); assert(history); history->remove_change(const_cast(change)); } -void SecurityManager::ParticipantVolatileMessageListener::onNewCacheChangeAdded( +void SecurityManager::ParticipantVolatileMessageListener::on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) { manager_.process_participant_volatile_message_secure(change); - ReaderHistory* history = reader->getHistory(); + ReaderHistory* history = reader->get_history(); assert(history); history->remove_change(const_cast(change)); } diff --git a/src/cpp/rtps/security/SecurityManager.h b/src/cpp/rtps/security/SecurityManager.h index e0178ecc660..b47f79a540d 100644 --- a/src/cpp/rtps/security/SecurityManager.h +++ b/src/cpp/rtps/security/SecurityManager.h @@ -573,7 +573,7 @@ class SecurityManager : private WriterListener { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; @@ -600,7 +600,7 @@ class SecurityManager : private WriterListener { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( RTPSReader* reader, const CacheChange_t* const change) override; diff --git a/src/cpp/rtps/writer/ReaderLocator.cpp b/src/cpp/rtps/writer/ReaderLocator.cpp index 24a1ecb7023..b46b783d213 100644 --- a/src/cpp/rtps/writer/ReaderLocator.cpp +++ b/src/cpp/rtps/writer/ReaderLocator.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include "rtps/RTPSDomainImpl.hpp" @@ -33,6 +34,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + ReaderLocator::ReaderLocator( RTPSWriter* owner, size_t max_unicast_locators, @@ -227,7 +230,7 @@ void ReaderLocator::datasharing_notify() if (reader) { - reader->datasharing_listener()->notify(true); + BaseReader::downcast(reader)->datasharing_listener()->notify(true); } else { diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index be1332419af..847693e8021 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,8 @@ namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; + /** * Loops over all the readers in the vector, applying the given routine. * The loop continues until the result of the routine is true for any reader @@ -477,7 +480,7 @@ bool StatefulWriter::intraprocess_delivery( { change->write_params.sample_identity(change->write_params.related_sample_identity()); } - return reader->processDataMsg(change); + return BaseReader::downcast(reader)->process_data_msg(change); } return false; } @@ -490,7 +493,8 @@ bool StatefulWriter::intraprocess_gap( RTPSReader* reader = reader_proxy->local_reader(); if (reader) { - return reader->processGapMsg(m_guid, first_seq, SequenceNumberSet_t(last_seq), c_VendorId_eProsima); + return BaseReader::downcast(reader)->process_gap_msg( + m_guid, first_seq, SequenceNumberSet_t(last_seq), c_VendorId_eProsima); } return false; @@ -523,9 +527,8 @@ bool StatefulWriter::intraprocess_heartbeat( (liveliness || reader_proxy->has_changes())) { incrementHBCount(); - returned_value = - reader->processHeartbeatMsg(m_guid, m_heartbeatCount, first_seq, last_seq, true, liveliness, - c_VendorId_eProsima); + returned_value = BaseReader::downcast(reader)->process_heartbeat_msg( + m_guid, m_heartbeatCount, first_seq, last_seq, true, liveliness, c_VendorId_eProsima); } } diff --git a/src/cpp/rtps/writer/StatelessWriter.cpp b/src/cpp/rtps/writer/StatelessWriter.cpp index 7e787a5bb76..81e16a538e2 100644 --- a/src/cpp/rtps/writer/StatelessWriter.cpp +++ b/src/cpp/rtps/writer/StatelessWriter.cpp @@ -41,12 +41,14 @@ #include #include #include +#include #include namespace eprosima { namespace fastrtps { namespace rtps { +using BaseReader = fastdds::rtps::BaseReader; /** * Loops over all the readers in the vector, applying the given routine. @@ -355,7 +357,7 @@ bool StatelessWriter::intraprocess_delivery( { change->write_params.sample_identity(change->write_params.related_sample_identity()); } - return reader->processDataMsg(change); + return BaseReader::downcast(reader)->process_data_msg(change); } return false; diff --git a/src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp b/src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp index f27ed5da413..c0e115cb838 100644 --- a/src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp +++ b/src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp @@ -19,6 +19,8 @@ #include #include + +#include #include using eprosima::fastrtps::RecursiveTimedMutex; @@ -29,6 +31,8 @@ namespace eprosima { namespace fastdds { namespace statistics { +using BaseReader = fastdds::rtps::BaseReader; + StatisticsReaderImpl::StatisticsReaderImpl() { init_statistics(); @@ -46,19 +50,19 @@ StatisticsReaderAncillary* StatisticsReaderImpl::get_members() const RecursiveTimedMutex& StatisticsReaderImpl::get_statistics_mutex() { static_assert( - std::is_base_of::value, + std::is_base_of::value, "Must be call from a writer."); - return static_cast(this)->getMutex(); + return static_cast(this)->getMutex(); } const GUID_t& StatisticsReaderImpl::get_guid() const { static_assert( - std::is_base_of::value, + std::is_base_of::value, "This method should be called from an actual RTPSReader"); - return static_cast(this)->getGuid(); + return static_cast(this)->getGuid(); } void StatisticsReaderImpl::on_data_notify( diff --git a/src/cpp/xmlparser/XMLElementParser.cpp b/src/cpp/xmlparser/XMLElementParser.cpp index d89387ccfd7..bccbc06e047 100644 --- a/src/cpp/xmlparser/XMLElementParser.cpp +++ b/src/cpp/xmlparser/XMLElementParser.cpp @@ -2979,8 +2979,8 @@ XMLP_ret XMLParser::getXMLReaderTimes( /* - - + + */ @@ -2992,16 +2992,16 @@ XMLP_ret XMLParser::getXMLReaderTimes( name = p_aux0->Name(); if (strcmp(name, INIT_ACKNACK_DELAY) == 0) { - // initialAcknackDelay - if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.initialAcknackDelay, ident)) + // initial_acknack_delay + if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.initial_acknack_delay, ident)) { return XMLP_ret::XML_ERROR; } } else if (strcmp(name, HEARTB_RESP_DELAY) == 0) { - // heartbeatResponseDelay - if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.heartbeatResponseDelay, ident)) + // heartbeat_response_delay + if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.heartbeat_response_delay, ident)) { return XMLP_ret::XML_ERROR; } @@ -4400,7 +4400,7 @@ XMLP_ret XMLParser::getXMLSubscriberAttributes( - + @@ -4491,8 +4491,8 @@ XMLP_ret XMLParser::getXMLSubscriberAttributes( } else if (strcmp(name, EXP_INLINE_QOS) == 0) { - // expectsInlineQos - boolType - if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &subscriber.expectsInlineQos, ident)) + // expects_inline_qos - boolType + if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &subscriber.expects_inline_qos, ident)) { return XMLP_ret::XML_ERROR; } diff --git a/src/cpp/xmlparser/XMLEndpointParser.cpp b/src/cpp/xmlparser/XMLEndpointParser.cpp index 6521ca18979..645402d2802 100644 --- a/src/cpp/xmlparser/XMLEndpointParser.cpp +++ b/src/cpp/xmlparser/XMLEndpointParser.cpp @@ -275,7 +275,7 @@ XMLP_ret XMLEndpointParser::loadXMLReaderEndpoint( else { EPROSIMA_LOG_ERROR(RTPS_EDP, - "Bad XML file, endpoint of expectsInlineQos: " << auxString << " is not valid"); + "Bad XML file, endpoint of expects_inline_qos: " << auxString << " is not valid"); delete(rdata); return XMLP_ret::XML_ERROR; } diff --git a/src/cpp/xmlparser/XMLParserCommon.cpp b/src/cpp/xmlparser/XMLParserCommon.cpp index a1aa050712f..5a7444f4374 100644 --- a/src/cpp/xmlparser/XMLParserCommon.cpp +++ b/src/cpp/xmlparser/XMLParserCommon.cpp @@ -159,7 +159,7 @@ const char* EXT_UNI_LOC_LIST = "external_unicast_locators"; const char* UNI_LOC_LIST = "unicastLocatorList"; const char* MULTI_LOC_LIST = "multicastLocatorList"; const char* REM_LOC_LIST = "remoteLocatorList"; -const char* EXP_INLINE_QOS = "expectsInlineQos"; +const char* EXP_INLINE_QOS = "expects_inline_qos"; const char* HIST_MEM_POLICY = "historyMemoryPolicy"; //const char* PROPERTIES_POLICY = "propertiesPolicy"; const char* USER_DEF_ID = "userDefinedID"; @@ -198,8 +198,8 @@ const char* DEFAULT_C = "DEFAULT"; const char* DEFAULTv6 = "DEFAULTv6"; const char* LARGE_DATA = "LARGE_DATA"; const char* LARGE_DATAv6 = "LARGE_DATAv6"; -const char* INIT_ACKNACK_DELAY = "initialAcknackDelay"; -const char* HEARTB_RESP_DELAY = "heartbeatResponseDelay"; +const char* INIT_ACKNACK_DELAY = "initial_acknack_delay"; +const char* HEARTB_RESP_DELAY = "heartbeat_response_delay"; const char* INIT_HEARTB_DELAY = "initialHeartbeatDelay"; const char* HEARTB_PERIOD = "heartbeatPeriod"; const char* NACK_RESP_DELAY = "nackResponseDelay"; @@ -345,7 +345,7 @@ const char* STATICDISCOVERY = "staticdiscovery"; const char* READER = "reader"; const char* WRITER = "writer"; const char* USER_ID = "userId"; -const char* EXPECT_INLINE_QOS = "expectsInlineQos"; +const char* EXPECT_INLINE_QOS = "expects_inline_qos"; const char* TOPIC_NAME = "topicName"; const char* TOPIC_DATA_TYPE = "topicDataType"; const char* TOPIC_KIND = "topicKind"; diff --git a/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp b/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp index 7ff6976282c..5cd7702f16e 100644 --- a/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp +++ b/src/cpp/xmlparser/attributes/SubscriberAttributes.hpp @@ -64,7 +64,7 @@ class SubscriberAttributes bool ignore_non_matching_locators = false; //! Expects Inline QOS - bool expectsInlineQos = false; + bool expects_inline_qos = false; //! Underlying History memory policy fastrtps::rtps::MemoryManagementPolicy_t historyMemoryPolicy = diff --git a/test/blackbox/PubSubWriterPersistence_static_disc.xml.in b/test/blackbox/PubSubWriterPersistence_static_disc.xml.in index 1a5ef21f454..4926e0995cf 100644 --- a/test/blackbox/PubSubWriterPersistence_static_disc.xml.in +++ b/test/blackbox/PubSubWriterPersistence_static_disc.xml.in @@ -4,7 +4,7 @@ 3 4 - false + false BlackBox_StaticDiscovery_@TOPIC_RANDOM_NUMBER@ HelloWorld NO_KEY diff --git a/test/blackbox/PubSubWriter_static_disc.xml.in b/test/blackbox/PubSubWriter_static_disc.xml.in index bea02cb3617..4502a3c5018 100644 --- a/test/blackbox/PubSubWriter_static_disc.xml.in +++ b/test/blackbox/PubSubWriter_static_disc.xml.in @@ -4,7 +4,7 @@ 3 4 - false + false BlackBox_StaticDiscovery_@TOPIC_RANDOM_NUMBER@ HelloWorld NO_KEY diff --git a/test/blackbox/api/dds-pim/PubSubParticipant.hpp b/test/blackbox/api/dds-pim/PubSubParticipant.hpp index 6181e685e3f..d2333143f84 100644 --- a/test/blackbox/api/dds-pim/PubSubParticipant.hpp +++ b/test/blackbox/api/dds-pim/PubSubParticipant.hpp @@ -267,7 +267,7 @@ class PubSubParticipant datawriter_qos_.reliability().max_blocking_time.nanosec = 0; // By default, heartbeat period delay is 100 milliseconds. - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay = 0.1; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay = 0.1; } ~PubSubParticipant() diff --git a/test/blackbox/api/dds-pim/PubSubReader.hpp b/test/blackbox/api/dds-pim/PubSubReader.hpp index 289e4517857..906484ed2a2 100644 --- a/test/blackbox/api/dds-pim/PubSubReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubReader.hpp @@ -356,8 +356,8 @@ class PubSubReader eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; // By default, heartbeat period delay is 100 milliseconds. - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.seconds = 0; - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.nanosec = 100000000; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.seconds = 0; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.nanosec = 100000000; // By default don't check for overlapping loan_sample_validation(false); @@ -1169,12 +1169,12 @@ class PubSubReader return *this; } - PubSubReader& heartbeatResponseDelay( + PubSubReader& heartbeat_response_delay( const int32_t secs, const int32_t frac) { - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.seconds = secs; - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.fraction(frac); + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.seconds = secs; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.fraction(frac); return *this; } diff --git a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp index 8f9407dc8c4..8d525968a4b 100644 --- a/test/blackbox/api/dds-pim/PubSubWriterReader.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriterReader.hpp @@ -367,8 +367,8 @@ class PubSubWriterReader datawriter_qos_.reliability().max_blocking_time.nanosec = 0; // By default, heartbeat period delay is 100 milliseconds. - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.seconds = 0; - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.nanosec = 100000000; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.seconds = 0; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.nanosec = 100000000; } ~PubSubWriterReader() diff --git a/test/blackbox/common/BlackboxTestsVolatile.cpp b/test/blackbox/common/BlackboxTestsVolatile.cpp index a835041ba6e..0f0e9a79d79 100644 --- a/test/blackbox/common/BlackboxTestsVolatile.cpp +++ b/test/blackbox/common/BlackboxTestsVolatile.cpp @@ -442,7 +442,7 @@ TEST_P(Volatile, VolatileLateJoinerSubGapLost) reader1.history_kind(eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS). reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS). durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS). - //heartbeatResponseDelay(5,0). + //heartbeat_response_delay(5,0). init(); ASSERT_TRUE(reader1.isInitialized()); diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 8ac638d0809..f3c3b7f4500 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "BlackboxTests.hpp" @@ -777,7 +778,13 @@ void sample_lost_test_dr_init( PubSubReader& reader, std::function functor) { - reader.sample_lost_status_functor(functor) + auto udp_transport = std::make_shared(); + udp_transport->sendBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + udp_transport->receiveBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + + reader.disable_builtin_transport() + .add_user_transport_to_pparams(udp_transport) + .sample_lost_status_functor(functor) .init(); ASSERT_TRUE(reader.isInitialized()); diff --git a/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp b/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp index 090b9c840fe..707109f6e79 100644 --- a/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPersistenceGuid.cpp @@ -291,10 +291,10 @@ TEST_P(PersistenceGuid, SetPersistenceGuidByXML) \ PREALLOCATED \ \ - \ + \ 0 \ 100000000 \ - \ + \ \ \ \ diff --git a/test/blackbox/common/RTPSAsSocketReader.hpp b/test/blackbox/common/RTPSAsSocketReader.hpp index c562bc09d31..e08f655523b 100644 --- a/test/blackbox/common/RTPSAsSocketReader.hpp +++ b/test/blackbox/common/RTPSAsSocketReader.hpp @@ -79,7 +79,7 @@ class RTPSAsSocketReader { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override { @@ -120,8 +120,8 @@ class RTPSAsSocketReader hattr_.memoryPolicy = eprosima::fastrtps::rtps::PREALLOCATED_WITH_REALLOC_MEMORY_MODE; // By default, heartbeat period delay is 100 milliseconds. - reader_attr_.times.heartbeatResponseDelay.seconds = 0; - reader_attr_.times.heartbeatResponseDelay.nanosec = 100000000; + reader_attr_.times.heartbeat_response_delay.seconds = 0; + reader_attr_.times.heartbeat_response_delay.nanosec = 100000000; } virtual ~RTPSAsSocketReader() @@ -152,7 +152,10 @@ class RTPSAsSocketReader ASSERT_NE(history_, nullptr); //Create reader - reader_ = eprosima::fastrtps::rtps::RTPSDomain::createRTPSReader(participant_, reader_attr_, history_, + auto attr = reader_attr_; + attr.accept_messages_from_unkown_writers = + eprosima::fastrtps::rtps::RELIABLE != reader_attr_.endpoint.reliabilityKind; + reader_ = eprosima::fastrtps::rtps::RTPSDomain::createRTPSReader(participant_, attr, history_, &listener_); ASSERT_NE(reader_, nullptr); @@ -320,10 +323,6 @@ class RTPSAsSocketReader wattr.guid().entityId.value[3] = 3; reader_->matched_writer_add(wattr); } - else - { - reader_->enableMessagesFromUnkownWriters(true); - } } RTPSAsSocketReader& disable_positive_acks( @@ -367,7 +366,7 @@ class RTPSAsSocketReader cv_.notify_one(); } - eprosima::fastrtps::rtps::ReaderHistory* history = reader->getHistory(); + eprosima::fastrtps::rtps::ReaderHistory* history = reader->get_history(); ASSERT_NE(history, nullptr); history->remove_change((eprosima::fastrtps::rtps::CacheChange_t*)change); diff --git a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp index dea78ff3ebc..8dbf9bd2c44 100644 --- a/test/blackbox/common/RTPSBlackboxTestsBasic.cpp +++ b/test/blackbox/common/RTPSBlackboxTestsBasic.cpp @@ -867,34 +867,6 @@ TEST(RTPS, MultithreadedWriterCreation) RTPSDomain::stopAll(); } -/* Regression Test for improving gaps processing - * https://github.com/eProsima/Fast-DDS/pull/3343 - */ -TEST(RTPS, RTPSCorrectGAPProcessing) -{ - RTPSWithRegistrationReader reader(TEST_TOPIC_NAME); - RTPSWithRegistrationWriter writer(TEST_TOPIC_NAME); - - reader.durability(eprosima::fastrtps::rtps::DurabilityKind_t::TRANSIENT_LOCAL). - reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::RELIABLE).init(); - - ASSERT_TRUE(reader.isInitialized()); - - writer.durability(eprosima::fastrtps::rtps::DurabilityKind_t::TRANSIENT_LOCAL). - reliability(eprosima::fastrtps::rtps::ReliabilityKind_t::RELIABLE).init(); - - ASSERT_TRUE(writer.isInitialized()); - - reader.wait_discovery(); - writer.wait_discovery(); - - SequenceNumberSet_t seq_set(SequenceNumber_t(0, 0)); - - //! GAP Message check - RTPSReader& native_reader = reader.get_native_reader(); - ASSERT_NO_FATAL_FAILURE(native_reader.processGapMsg(writer.guid(), {0, 0}, seq_set)); -} - class CustomReaderDataFilter : public eprosima::fastdds::rtps::IReaderDataFilter { public: diff --git a/test/blackbox/common/RTPSWithRegistrationReader.hpp b/test/blackbox/common/RTPSWithRegistrationReader.hpp index ec35b5a5763..53493dff52f 100644 --- a/test/blackbox/common/RTPSWithRegistrationReader.hpp +++ b/test/blackbox/common/RTPSWithRegistrationReader.hpp @@ -78,7 +78,7 @@ class RTPSWithRegistrationReader { } - void onNewCacheChangeAdded( + void on_new_cache_change_added( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override { @@ -88,9 +88,9 @@ class RTPSWithRegistrationReader reader_.receive_one(reader, change); } - void onReaderMatched( + void on_reader_matched( eprosima::fastrtps::rtps::RTPSReader* /*reader*/, - eprosima::fastrtps::rtps::MatchingInfo& info) override + const eprosima::fastrtps::rtps::MatchingInfo& info) override { if (info.status == eprosima::fastrtps::rtps::MATCHED_MATCHING) { @@ -113,8 +113,6 @@ class RTPSWithRegistrationReader private: - using eprosima::fastrtps::rtps::ReaderListener::onReaderMatched; - Listener& operator =( const Listener&) = delete; @@ -149,9 +147,8 @@ class RTPSWithRegistrationReader topic_attr_.topicName = t.str(); // By default, heartbeat period delay is 100 milliseconds. - reader_attr_.times.heartbeatResponseDelay.seconds = 0; - //reader_attr_.times.heartbeatResponseDelay.nanosec = 100000000; - reader_attr_.times.heartbeatResponseDelay.nanosec = 100000000; + reader_attr_.times.heartbeat_response_delay.seconds = 0; + reader_attr_.times.heartbeat_response_delay.nanosec = 100000000; participant_attr_.builtin.discovery_config.discoveryProtocol = eprosima::fastrtps::rtps::DiscoveryProtocol::SIMPLE; @@ -601,7 +598,7 @@ class RTPSWithRegistrationReader cv_.notify_one(); } - eprosima::fastrtps::rtps::ReaderHistory* history = reader->getHistory(); + eprosima::fastrtps::rtps::ReaderHistory* history = reader->get_history(); EXPECT_EQ(history, history_); history->remove_change((eprosima::fastrtps::rtps::CacheChange_t*)change); diff --git a/test/mock/rtps/Endpoint/fastdds/rtps/Endpoint.h b/test/mock/rtps/Endpoint/fastdds/rtps/Endpoint.h index 457a0692d71..676218f4db0 100644 --- a/test/mock/rtps/Endpoint/fastdds/rtps/Endpoint.h +++ b/test/mock/rtps/Endpoint/fastdds/rtps/Endpoint.h @@ -34,6 +34,11 @@ class Endpoint virtual ~Endpoint() = default; + const GUID_t& getGuid() + { + return m_guid; + } + inline RecursiveTimedMutex& getMutex() { return mp_mutex; @@ -48,9 +53,10 @@ class Endpoint bool supports_rtps_protection_; #endif // HAVE_SECURITY - mutable RecursiveTimedMutex mp_mutex; - EndpointAttributes m_att; RTPSParticipantImpl* mp_RTPSParticipant; + GUID_t m_guid; + EndpointAttributes m_att; + mutable RecursiveTimedMutex mp_mutex; }; diff --git a/test/mock/rtps/RTPSDomain/fastdds/rtps/RTPSDomain.h b/test/mock/rtps/RTPSDomain/fastdds/rtps/RTPSDomain.h index 4c16829e480..9f79402289c 100644 --- a/test/mock/rtps/RTPSDomain/fastdds/rtps/RTPSDomain.h +++ b/test/mock/rtps/RTPSDomain/fastdds/rtps/RTPSDomain.h @@ -119,8 +119,8 @@ class RTPSDomain ReaderHistory* history, ReaderListener* listen = nullptr) { - reader_->setHistory(history); - reader_->setListener(listen); + reader_->set_history(history); + reader_->set_listener(listen); return reader_; } @@ -131,8 +131,8 @@ class RTPSDomain ReaderHistory* history, ReaderListener* listen = nullptr) { - reader_->setHistory(history); - reader_->setListener(listen); + reader_->set_history(history); + reader_->set_listener(listen); return reader_; } @@ -144,8 +144,8 @@ class RTPSDomain ReaderHistory* history, ReaderListener* listen = nullptr) { - reader_->setHistory(history); - reader_->setListener(listen); + reader_->set_history(history); + reader_->set_listener(listen); return reader_; } diff --git a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h index 958bf83fc24..1810ecc0f52 100644 --- a/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h +++ b/test/mock/rtps/RTPSParticipantImpl/rtps/participant/RTPSParticipantImpl.h @@ -34,6 +34,7 @@ #include #include +#include #include #if HAVE_SECURITY #include @@ -219,7 +220,7 @@ class RTPSParticipantImpl if (*reader != nullptr) { (*reader)->history_ = hist; - (*reader)->listener_ = listen; + fastdds::rtps::BaseReader::downcast(*reader)->listener_ = listen; auto guid = generate_endpoint_guid(); (*reader)->m_guid = guid; @@ -242,7 +243,7 @@ class RTPSParticipantImpl if (*reader != nullptr) { (*reader)->history_ = hist; - (*reader)->listener_ = listen; + fastdds::rtps::BaseReader::downcast(*reader)->listener_ = listen; auto guid = generate_endpoint_guid(); (*reader)->m_guid = guid; diff --git a/test/mock/rtps/RTPSReader/fastdds/rtps/reader/RTPSReader.h b/test/mock/rtps/RTPSReader/fastdds/rtps/reader/RTPSReader.h index 9b29ff7b2c7..01b7ba8cb67 100644 --- a/test/mock/rtps/RTPSReader/fastdds/rtps/reader/RTPSReader.h +++ b/test/mock/rtps/RTPSReader/fastdds/rtps/reader/RTPSReader.h @@ -64,20 +64,37 @@ class RTPSReader : public Endpoint virtual bool matched_writer_is_matched( const GUID_t& wguid) = 0; - const GUID_t& getGuid() + virtual void assert_writer_liveliness( + const GUID_t& wguid) = 0; + + virtual bool is_in_clean_state() = 0; + + virtual ReaderListener* get_listener() const = 0; + + virtual bool set_listener( + ReaderListener* listener) = 0; + + ReaderHistory* get_history() { - return m_guid; + get_history_mock(); + return history_; } - ReaderListener* getListener() const + virtual CacheChange_t* next_unread_cache() { - return listener_; + return nullptr; } - bool setListener( - ReaderListener* listener) + virtual CacheChange_t* next_untaken_cache() + { + return nullptr; + } + + virtual bool is_sample_valid( + const void* /*data*/, + const GUID_t& /*writer*/, + const SequenceNumber_t& /*sn*/) const { - listener_ = listener; return true; } @@ -97,91 +114,39 @@ class RTPSReader : public Endpoint return true; } + virtual void set_enabled_statistics_writers_mask( + uint32_t /*enabled_writers*/) + { + } + + template + bool get_connections( + T& /*connection_list*/) + { + return true; + } + #endif // FASTDDS_STATISTICS // *INDENT-OFF* Uncrustify makes a mess with MOCK_METHOD macros - MOCK_METHOD1(change_removed_by_history, bool(CacheChange_t* change)); + MOCK_METHOD0(expects_inline_qos, bool()); - MOCK_METHOD0(getHistory_mock, ReaderHistory* ()); + MOCK_METHOD0(get_history_mock, ReaderHistory* ()); - MOCK_METHOD2(reserveCache, bool (CacheChange_t** a_change, uint32_t dataCdrSerializedSize)); + MOCK_CONST_METHOD0(get_content_filter, eprosima::fastdds::rtps::IReaderDataFilter* ()); - MOCK_METHOD1(releaseCache, void (CacheChange_t* a_change)); - - MOCK_METHOD0(expectsInlineQos, bool()); + MOCK_METHOD1(set_content_filter, void (eprosima::fastdds::rtps::IReaderDataFilter* filter)); MOCK_METHOD1(wait_for_unread_cache, bool (const eprosima::fastrtps::Duration_t& timeout)); - MOCK_METHOD0(get_unread_count, uint64_t()); + MOCK_CONST_METHOD0(get_unread_count, uint64_t()); MOCK_METHOD1(get_unread_count, uint64_t(bool)); - MOCK_METHOD1(set_content_filter, void (eprosima::fastdds::rtps::IReaderDataFilter* filter)); - // *INDENT-ON* - virtual bool processDataMsg( - CacheChange_t*) - { - return true; - } - - virtual bool processDataFragMsg( - CacheChange_t*, - uint32_t, - uint32_t, - uint16_t) - { - return true; - } - - virtual bool processHeartbeatMsg( - const GUID_t&, - uint32_t, - const SequenceNumber_t&, - const SequenceNumber_t&, - bool, - bool) - { - return true; - } - - virtual bool processGapMsg( - const GUID_t&, - const SequenceNumber_t&, - const SequenceNumberSet_t&) - { - return true; - } - - virtual bool change_removed_by_history( - CacheChange_t*, - WriterProxy*) - { - return true; - } - - virtual bool nextUnreadCache( - CacheChange_t**, - WriterProxy**) - { - return true; - } - - virtual bool nextUntakenCache( - CacheChange_t**, - WriterProxy**) - { - return true; - } - - virtual bool isInCleanState() - { - return true; - } - - void setHistory( + void set_history( ReaderHistory* history) { history->mp_reader = this; @@ -189,48 +154,7 @@ class RTPSReader : public Endpoint history_ = history; } - ReaderHistory* getHistory() - { - getHistory_mock(); - return history_; - } - - bool is_sample_valid( - const void* /*data*/, - const GUID_t& /*writer*/, - const SequenceNumber_t& /*sn*/) const - { - return true; - } - - virtual bool begin_sample_access_nts( - CacheChange_t* /*change*/, - WriterProxy*& /*wp*/, - bool& /*is_future_change*/) - { - return true; - } - - virtual void end_sample_access_nts( - CacheChange_t* /*change*/, - WriterProxy*& /*wp*/, - bool /*mark_as_read*/) - { - } - - virtual void change_read_by_user( - CacheChange_t* /*change*/, - const WriterProxy* /*writer*/, - bool mark_as_read = true) - { - (void) mark_as_read; - } - ReaderHistory* history_; - - ReaderListener* listener_; - - GUID_t m_guid; }; } // namespace rtps diff --git a/test/mock/rtps/RTPSReader/rtps/reader/BaseReader.hpp b/test/mock/rtps/RTPSReader/rtps/reader/BaseReader.hpp new file mode 100644 index 00000000000..276f45fe890 --- /dev/null +++ b/test/mock/rtps/RTPSReader/rtps/reader/BaseReader.hpp @@ -0,0 +1,166 @@ +// 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 BaseReader.hpp + */ + +#ifndef RTPS_READER__BASEREADER_HPP +#define RTPS_READER__BASEREADER_HPP + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace eprosima { + +namespace fastrtps { +namespace rtps { + +struct CacheChange_t; +class IDataSharingListener; +struct ReaderHistoryState; +class ReaderListener; +class RTPSParticipantImpl; +class WriterProxy; +class WriterProxyData; + +} // namespace rtps +} // namespace fastrtps + +namespace fastdds { +namespace rtps { + +class BaseReader : public fastrtps::rtps::RTPSReader +{ +public: + + BaseReader() + : fastrtps::rtps::RTPSReader() + { + } + + BaseReader( + fastrtps::rtps::ReaderHistory* history, + fastrtps::RecursiveTimedMutex* mutex) + : fastrtps::rtps::RTPSReader(history, mutex) + { + } + + virtual ~BaseReader() = default; + + static BaseReader* downcast( + fastrtps::rtps::RTPSReader* reader) + { + return static_cast(reader); + } + + static BaseReader* downcast( + fastrtps::rtps::Endpoint* endpoint) + { + return static_cast(endpoint); + } + + fastrtps::rtps::ReaderListener* get_listener() const override + { + return listener_; + } + + virtual bool set_listener( + fastrtps::rtps::ReaderListener* listener) override + { + listener_ = listener; + return true; + } + + virtual bool process_data_msg( + fastrtps::rtps::CacheChange_t*) + { + return true; + } + + virtual bool process_data_frag_msg( + fastrtps::rtps::CacheChange_t*, + uint32_t, + uint32_t, + uint16_t) + { + return true; + } + + virtual bool process_heartbeat_msg( + const fastrtps::rtps::GUID_t&, + uint32_t, + const fastrtps::rtps::SequenceNumber_t&, + const fastrtps::rtps::SequenceNumber_t&, + bool, + bool) + { + return true; + } + + virtual bool process_gap_msg( + const fastrtps::rtps::GUID_t&, + const fastrtps::rtps::SequenceNumber_t&, + const fastrtps::rtps::SequenceNumberSet_t&) + { + return true; + } + + virtual bool change_removed_by_history( + fastrtps::rtps::CacheChange_t*, + fastrtps::rtps::WriterProxy*) + { + return true; + } + + virtual bool begin_sample_access_nts( + fastrtps::rtps::CacheChange_t* /*change*/, + fastrtps::rtps::WriterProxy*& /*wp*/, + bool& /*is_future_change*/) + { + return true; + } + + virtual void end_sample_access_nts( + fastrtps::rtps::CacheChange_t* /*change*/, + fastrtps::rtps::WriterProxy*& /*wp*/, + bool /*mark_as_read*/) + { + } + + // *INDENT-OFF* Uncrustify makes a mess with MOCK_METHOD macros + MOCK_METHOD1(change_removed_by_history, bool(fastrtps::rtps::CacheChange_t* change)); + + MOCK_METHOD2(reserve_cache, bool(uint32_t, fastrtps::rtps::CacheChange_t*&)); + + MOCK_METHOD1(release_cache, void(fastrtps::rtps::CacheChange_t* a_change)); + // *INDENT-ON* + + fastrtps::rtps::ReaderListener* listener_; + +}; + +} // namespace rtps +} // namespace fastdds +} // namespace eprosima + +#endif // RTPS_READER__BASEREADER_HPP diff --git a/test/mock/rtps/StatefulReader/rtps/reader/StatefulReader.hpp b/test/mock/rtps/StatefulReader/rtps/reader/StatefulReader.hpp index eb0f6181bb8..c05f48d269d 100644 --- a/test/mock/rtps/StatefulReader/rtps/reader/StatefulReader.hpp +++ b/test/mock/rtps/StatefulReader/rtps/reader/StatefulReader.hpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace eprosima { @@ -34,7 +34,7 @@ class RTPSMessageSenderInterface; class RTPSParticipantImpl; struct CDRMessage_t; -class StatefulReader : public RTPSReader +class StatefulReader : public fastdds::rtps::BaseReader { public: @@ -47,7 +47,7 @@ class StatefulReader : public RTPSReader StatefulReader( ReaderHistory* history, RecursiveTimedMutex* mutex) - : RTPSReader(history, mutex) + : fastdds::rtps::BaseReader(history, mutex) { } @@ -65,6 +65,10 @@ class StatefulReader : public RTPSReader MOCK_METHOD2(change_received, bool(CacheChange_t* a_change, WriterProxy* prox)); MOCK_METHOD1 (matched_writer_is_matched, bool(const GUID_t& writer_guid)); + + MOCK_METHOD1 (assert_writer_liveliness, void(const GUID_t& writer_guid)); + + MOCK_METHOD0 (is_in_clean_state, bool()); // *INDENT-ON* ReaderTimes& getTimes() diff --git a/test/mock/rtps/StatelessReader/rtps/reader/StatelessReader.hpp b/test/mock/rtps/StatelessReader/rtps/reader/StatelessReader.hpp index da3b4479011..e42e6e85157 100644 --- a/test/mock/rtps/StatelessReader/rtps/reader/StatelessReader.hpp +++ b/test/mock/rtps/StatelessReader/rtps/reader/StatelessReader.hpp @@ -19,13 +19,13 @@ #ifndef RTPS_READER__STATELESSREADER_HPP #define RTPS_READER__STATELESSREADER_HPP -#include +#include namespace eprosima { namespace fastrtps { namespace rtps { -class StatelessReader : public RTPSReader +class StatelessReader : public fastdds::rtps::BaseReader { public: @@ -34,7 +34,7 @@ class StatelessReader : public RTPSReader StatelessReader( ReaderHistory* history, RecursiveTimedMutex* mutex) - : RTPSReader(history, mutex) + : fastdds::rtps::BaseReader(history, mutex) { } @@ -46,6 +46,9 @@ class StatelessReader : public RTPSReader MOCK_METHOD1 (matched_writer_is_matched, bool(const GUID_t& writer_guid)); + MOCK_METHOD1(assert_writer_liveliness, void(const GUID_t& writer_guid)); + + MOCK_METHOD0(is_in_clean_state, bool()); }; } // namespace rtps diff --git a/test/realtime/UserThreadNonBlockedTest.cpp b/test/realtime/UserThreadNonBlockedTest.cpp index 2eb469288c8..fc72dd3d08b 100644 --- a/test/realtime/UserThreadNonBlockedTest.cpp +++ b/test/realtime/UserThreadNonBlockedTest.cpp @@ -139,8 +139,8 @@ class UserThreadNonBlockedTest : public ::testing::Test library_attributes.intraprocess_delivery = eprosima::fastdds::INTRAPROCESS_OFF; eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->set_library_settings(library_attributes); - datareader_qos_.reliable_reader_qos().times.initialAcknackDelay.seconds = 10; - datareader_qos_.reliable_reader_qos().times.heartbeatResponseDelay.seconds = 10; + datareader_qos_.reliable_reader_qos().times.initial_acknack_delay.seconds = 10; + datareader_qos_.reliable_reader_qos().times.heartbeat_response_delay.seconds = 10; // Slow flow-controller used in some test auto slow_flowcontroller = std::make_shared(); diff --git a/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml b/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml index 3fcbefee6d3..5188be534d5 100644 --- a/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml +++ b/test/system/tools/xmlvalidation/XMLTesterExample_profile.xml @@ -612,14 +612,14 @@ - + 1 856000 - - + + 1 856000 - + @@ -682,7 +682,7 @@ true - true + true DYNAMIC diff --git a/test/system/tools/xmlvalidation/all_profile.xml b/test/system/tools/xmlvalidation/all_profile.xml index ba9694c7fac..3b9941b6bb3 100644 --- a/test/system/tools/xmlvalidation/all_profile.xml +++ b/test/system/tools/xmlvalidation/all_profile.xml @@ -670,13 +670,13 @@ - + 12 - + - + 3 - + @@ -777,7 +777,7 @@ true - false + false DYNAMIC diff --git a/test/system/tools/xmlvalidation/dataReader_profile.xml b/test/system/tools/xmlvalidation/dataReader_profile.xml index 4cbfb3dd8dc..98c040fa057 100644 --- a/test/system/tools/xmlvalidation/dataReader_profile.xml +++ b/test/system/tools/xmlvalidation/dataReader_profile.xml @@ -112,13 +112,13 @@ - + 12 - + - + 3 - + @@ -219,7 +219,7 @@ true - false + false DYNAMIC diff --git a/test/system/tools/xmlvalidation/discovery_static_disc.xml b/test/system/tools/xmlvalidation/discovery_static_disc.xml index 021dc2a26e4..f83d378838b 100644 --- a/test/system/tools/xmlvalidation/discovery_static_disc.xml +++ b/test/system/tools/xmlvalidation/discovery_static_disc.xml @@ -4,7 +4,7 @@ 1 2 - true + true HelloWorldTopic HelloWorld NO_KEY @@ -20,7 +20,7 @@ 1 2 - false + false HelloWorldTopic HelloWorld WITH_KEY diff --git a/test/unittest/dds/profiles/test_xml_for_string_profile.xml b/test/unittest/dds/profiles/test_xml_for_string_profile.xml index 8a5c78e25d0..689b4c811d9 100644 --- a/test/unittest/dds/profiles/test_xml_for_string_profile.xml +++ b/test/unittest/dds/profiles/test_xml_for_string_profile.xml @@ -563,14 +563,14 @@ - + 5 0 - - + + 5 0 - + @@ -603,7 +603,7 @@ - false + false DYNAMIC 40 40 @@ -658,14 +658,14 @@ - + 0 0 - - + + 18 81 - + @@ -698,7 +698,7 @@ - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/test/unittest/dds/profiles/test_xml_profile.xml b/test/unittest/dds/profiles/test_xml_profile.xml index 54c5e52fa3f..c5a59d265a8 100644 --- a/test/unittest/dds/profiles/test_xml_profile.xml +++ b/test/unittest/dds/profiles/test_xml_profile.xml @@ -574,14 +574,14 @@ - + 5 0 - - + + 5 0 - + @@ -614,7 +614,7 @@ - false + false DYNAMIC 40 40 @@ -669,14 +669,14 @@ - + 0 0 - - + + 18 81 - + @@ -709,7 +709,7 @@ - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/test/unittest/dds/publisher/CMakeLists.txt b/test/unittest/dds/publisher/CMakeLists.txt index 167063034a3..f42c69831ca 100644 --- a/test/unittest/dds/publisher/CMakeLists.txt +++ b/test/unittest/dds/publisher/CMakeLists.txt @@ -135,6 +135,7 @@ set(DATAWRITERTESTS_SOURCE DataWriterTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipant.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipantImpl.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/BaseReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/reader_utils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/RTPSReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatefulPersistentReader.cpp diff --git a/test/unittest/dds/status/ListenerTests.cpp b/test/unittest/dds/status/ListenerTests.cpp index 8f6937fe9e0..428f24f1345 100644 --- a/test/unittest/dds/status/ListenerTests.cpp +++ b/test/unittest/dds/status/ListenerTests.cpp @@ -70,7 +70,7 @@ class RTPSParticipantMock : public eprosima::fastrtps::rtps::RTPSParticipant virtual ~RTPSParticipantMock() = default; }; -class RTPSReaderMock : public eprosima::fastrtps::rtps::RTPSReader +class RTPSReaderMock : public eprosima::fastdds::rtps::BaseReader { public: @@ -80,21 +80,31 @@ class RTPSReaderMock : public eprosima::fastrtps::rtps::RTPSReader virtual ~RTPSReaderMock() = default; - virtual bool matched_writer_add( - const eprosima::fastrtps::rtps::WriterProxyData&) + bool matched_writer_add( + const eprosima::fastrtps::rtps::WriterProxyData&) override { return true; } - virtual bool matched_writer_remove( + bool matched_writer_remove( const eprosima::fastrtps::rtps::GUID_t&, - bool) + bool) override { return true; } - virtual bool matched_writer_is_matched( - const eprosima::fastrtps::rtps::GUID_t&) + bool matched_writer_is_matched( + const eprosima::fastrtps::rtps::GUID_t&) override + { + return true; + } + + void assert_writer_liveliness( + const eprosima::fastrtps::rtps::GUID_t&) override + { + } + + bool is_in_clean_state() override { return true; } @@ -966,9 +976,9 @@ void verify_expectations_on_subscription_matched ( StrictMock& subscriber_listener_, StrictMock& datareader_listener_) { - SubscriptionMatchedStatus status; + fastrtps::rtps::MatchingInfo status; - RTPSDomain::reader_->listener_->onReaderMatched(nullptr, status); + RTPSDomain::reader_->get_listener()->on_reader_matched(nullptr, status); Mock::VerifyAndClearExpectations(&datareader_listener_); Mock::VerifyAndClearExpectations(&subscriber_listener_); Mock::VerifyAndClearExpectations(&participant_listener_); @@ -1088,7 +1098,7 @@ void verify_expectations_on_liveliness_changed ( { LivelinessChangedStatus status; - RTPSDomain::reader_->listener_->on_liveliness_changed(nullptr, status); + RTPSDomain::reader_->get_listener()->on_liveliness_changed(nullptr, status); Mock::VerifyAndClearExpectations(&datareader_listener_); Mock::VerifyAndClearExpectations(&subscriber_listener_); Mock::VerifyAndClearExpectations(&participant_listener_); @@ -1208,7 +1218,7 @@ void verify_expectations_on_requested_incompatible_qos ( { PolicyMask status; - RTPSDomain::reader_->listener_->on_requested_incompatible_qos(nullptr, status); + RTPSDomain::reader_->get_listener()->on_requested_incompatible_qos(nullptr, status); Mock::VerifyAndClearExpectations(&datareader_listener_); Mock::VerifyAndClearExpectations(&subscriber_listener_); Mock::VerifyAndClearExpectations(&participant_listener_); @@ -1335,7 +1345,7 @@ void verify_expectations_on_data_available ( EXPECT_CALL(*RTPSDomain::reader_->history_, get_change(_, _, _)) .WillRepeatedly(testing::DoAll(testing::SetArgPointee<2>(&change), testing::Return(true))); - RTPSDomain::reader_->listener_->on_data_available(nullptr, change.writerGUID, seq, seq, notify_individual); + RTPSDomain::reader_->get_listener()->on_data_available(nullptr, change.writerGUID, seq, seq, notify_individual); Mock::VerifyAndClearExpectations(&datareader_listener_); Mock::VerifyAndClearExpectations(&subscriber_listener_); diff --git a/test/unittest/dds/subscriber/SubscriberTests.cpp b/test/unittest/dds/subscriber/SubscriberTests.cpp index a69ddaf0400..98b01053bd3 100644 --- a/test/unittest/dds/subscriber/SubscriberTests.cpp +++ b/test/unittest/dds/subscriber/SubscriberTests.cpp @@ -302,10 +302,10 @@ TEST(SubscriberTests, ChangeDefaultDataReaderQos) qos.durability_service().max_instances = 20; qos.durability_service().max_samples_per_instance = 30; // .reliable_reader_qos - qos.reliable_reader_qos().times.initialAcknackDelay.seconds = 34; - qos.reliable_reader_qos().times.initialAcknackDelay.nanosec = 32u; - qos.reliable_reader_qos().times.heartbeatResponseDelay.seconds = 432; - qos.reliable_reader_qos().times.heartbeatResponseDelay.nanosec = 43u; + qos.reliable_reader_qos().times.initial_acknack_delay.seconds = 34; + qos.reliable_reader_qos().times.initial_acknack_delay.nanosec = 32u; + qos.reliable_reader_qos().times.heartbeat_response_delay.seconds = 432; + qos.reliable_reader_qos().times.heartbeat_response_delay.nanosec = 43u; qos.reliable_reader_qos().disable_positive_ACKs.enabled = true; qos.reliable_reader_qos().disable_positive_ACKs.duration.seconds = 13; qos.reliable_reader_qos().disable_positive_ACKs.duration.nanosec = 320u; @@ -424,10 +424,10 @@ TEST(SubscriberTests, ChangeDefaultDataReaderQos) EXPECT_EQ(20, rqos.durability_service().max_instances); EXPECT_EQ(30, rqos.durability_service().max_samples_per_instance); // .reliable_reader_qos - EXPECT_EQ(34, rqos.reliable_reader_qos().times.initialAcknackDelay.seconds); - EXPECT_EQ(32u, rqos.reliable_reader_qos().times.initialAcknackDelay.nanosec); - EXPECT_EQ(432, rqos.reliable_reader_qos().times.heartbeatResponseDelay.seconds); - EXPECT_EQ(43u, rqos.reliable_reader_qos().times.heartbeatResponseDelay.nanosec); + EXPECT_EQ(34, rqos.reliable_reader_qos().times.initial_acknack_delay.seconds); + EXPECT_EQ(32u, rqos.reliable_reader_qos().times.initial_acknack_delay.nanosec); + EXPECT_EQ(432, rqos.reliable_reader_qos().times.heartbeat_response_delay.seconds); + EXPECT_EQ(43u, rqos.reliable_reader_qos().times.heartbeat_response_delay.nanosec); EXPECT_TRUE(rqos.reliable_reader_qos().disable_positive_ACKs.enabled); EXPECT_EQ(13, rqos.reliable_reader_qos().disable_positive_ACKs.duration.seconds); EXPECT_EQ(320u, rqos.reliable_reader_qos().disable_positive_ACKs.duration.nanosec); diff --git a/test/unittest/rtps/history/ReaderHistoryTests.cpp b/test/unittest/rtps/history/ReaderHistoryTests.cpp index 048e7ca750c..be709c71f33 100644 --- a/test/unittest/rtps/history/ReaderHistoryTests.cpp +++ b/test/unittest/rtps/history/ReaderHistoryTests.cpp @@ -99,7 +99,7 @@ TEST_F(ReaderHistoryTests, add_and_remove_changes) { EXPECT_CALL(*readerMock, change_removed_by_history(_)).Times(num_changes). WillRepeatedly(Return(true)); - EXPECT_CALL(*readerMock, releaseCache(_)).Times(num_changes); + EXPECT_CALL(*readerMock, release_cache(_)).Times(num_changes); for (uint32_t i = 0; i < num_changes; i++) { @@ -117,7 +117,7 @@ TEST_F(ReaderHistoryTests, add_and_remove_changes) TEST_F(ReaderHistoryTests, remove_empty_history) { EXPECT_CALL(*readerMock, change_removed_by_history(_)).Times(0); - EXPECT_CALL(*readerMock, releaseCache(_)).Times(0); + EXPECT_CALL(*readerMock, release_cache(_)).Times(0); CacheChange_t* ch = new CacheChange_t(); ch->writerGUID = GUID_t(GuidPrefix_t::unknown(), 1U); @@ -130,7 +130,7 @@ TEST_F(ReaderHistoryTests, remove_empty_history) TEST_F(ReaderHistoryTests, remove_null_cache_change) { EXPECT_CALL(*readerMock, change_removed_by_history(_)).Times(0); - EXPECT_CALL(*readerMock, releaseCache(_)).Times(0); + EXPECT_CALL(*readerMock, release_cache(_)).Times(0); CacheChange_t* ch = nullptr; ASSERT_FALSE(history->remove_change(ch)); @@ -203,7 +203,7 @@ TEST_F(ReaderHistoryTests, change_order) ASSERT_EQ(total_changes, n_writers * changes_per_writer); int num_removes = static_cast(total_changes * total_changes); EXPECT_CALL(*readerMock, change_removed_by_history(_)).Times(num_removes).WillRepeatedly(Return(true)); - EXPECT_CALL(*readerMock, releaseCache(_)).Times(num_removes); + EXPECT_CALL(*readerMock, release_cache(_)).Times(num_removes); auto rng = std::default_random_engine{}; for (size_t n = 0; n < changes.size(); ++n) @@ -277,7 +277,7 @@ TEST_F(ReaderHistoryTests, remove_changes_with_guid) EXPECT_CALL(*readerMock, change_removed_by_history(_)).Times(2). WillRepeatedly(Return(true)); - EXPECT_CALL(*readerMock, releaseCache(_)).Times(2); + EXPECT_CALL(*readerMock, release_cache(_)).Times(2); ASSERT_EQ(history->getHistorySize(), num_changes); GUID_t w1 = GUID_t(GuidPrefix_t::unknown(), 1U); diff --git a/test/unittest/rtps/reader/CMakeLists.txt b/test/unittest/rtps/reader/CMakeLists.txt index 503782b447a..de71b7435a7 100644 --- a/test/unittest/rtps/reader/CMakeLists.txt +++ b/test/unittest/rtps/reader/CMakeLists.txt @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +if(WIN32) + add_definitions(-D_WIN32_WINNT=0x0601) + add_definitions(-DNOMINMAX) +endif() ########################################################################### # WriterProxyTests @@ -30,10 +34,6 @@ set(WRITERPROXYTESTS_SOURCE WriterProxyTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) -if(WIN32) - add_definitions(-D_WIN32_WINNT=0x0601) -endif() - add_executable(WriterProxyTests ${WRITERPROXYTESTS_SOURCE}) target_compile_definitions(WriterProxyTests PRIVATE BOOST_ASIO_STANDALONE @@ -87,10 +87,6 @@ set(WRITERPROXYSTOPTEST_SOURCE WriterProxyStopTest.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp ) -if(WIN32) - add_definitions(-D_WIN32_WINNT=0x0601) -endif() - add_executable(WriterProxyStopTest ${WRITERPROXYSTOPTEST_SOURCE}) target_compile_definitions(WriterProxyStopTest PRIVATE BOOST_ASIO_STANDALONE @@ -140,10 +136,6 @@ set(WRITERPROXYACKNACKTESTS_SOURCE WriterProxyAcknackTests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp ) -if(WIN32) - add_definitions(-D_WIN32_WINNT=0x0601) -endif() - add_executable(WriterProxyAcknackTests ${WRITERPROXYACKNACKTESTS_SOURCE}) target_compile_definitions(WriterProxyAcknackTests PRIVATE BOOST_ASIO_STANDALONE @@ -174,3 +166,254 @@ target_link_libraries(WriterProxyAcknackTests GTest::gmock ${CMAKE_DL_LIBS}) gtest_discover_tests(WriterProxyAcknackTests) + +########################################################################### +# StatefulReaderTests +########################################################################### +set(STATEFUL_READER_TESTS_SOURCE StatefulReaderTests.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/RTPSParticipantAttributes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/ThreadSettings.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/BuiltinProtocols.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/data/ParticipantProxyData.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/builtin/discovery/database/backup/SharedBackupFunctions.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/database/DiscoveryDataBase.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/database/DiscoveryParticipantInfo.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/database/DiscoveryParticipantsAckStatus.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/database/DiscoverySharedInfo.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPClient.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPServer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPServerListeners.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPSimple.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPSimpleListeners.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/endpoint/EDPStatic.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/DirectMessageSender.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDP.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPServerListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/ServerAttributes.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DSClientEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/timedevent/DServerEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLP.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/liveliness/WLPListener.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/Time_t.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/DataSharing/DataSharingListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/DataSharing/DataSharingNotification.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/DataSharing/DataSharingPayloadPool.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerConsts.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/flowcontrol/FlowControllerFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/CacheChangePool.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/History.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/ReaderHistory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPool.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/TopicPayloadPoolRegistry.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/history/WriterHistory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/CDRMessage.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/MessageReceiver.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSGapBuilder.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageCreator.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/RTPSMessageGroup.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/messages/SendBuffersManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/NetworkFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/ReceiverResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/external_locators.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/netmask_filter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/network/utils/network.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipant.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/participant/RTPSParticipantImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/sqlite3.c + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/SQLite3PersistenceService.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/BaseReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/reader_utils.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/RTPSReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatefulPersistentReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatefulReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatelessPersistentReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatelessReader.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/WriterProxy.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/ResourceEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEvent.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/resources/TimedEventImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/RTPSDomain.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/ChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetmaskFilterKind.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/network/NetworkInterfaceWithFilter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/PortBasedTransportDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransportDescriptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/RTCPMessageManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/tcp/TCPControlMessage.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPAcceptor.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPAcceptorBasic.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceBasic.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPChannelResource.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPTransportInterface.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv4Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/UDPv6Transport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LivelinessManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/LocatorSelectorSender.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/PersistentWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/ReaderLocator.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/ReaderProxy.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/RTPSWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatefulPersistentWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatefulWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatelessPersistentWriter.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/writer/StatelessWriter.cpp + + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/builtin/type_lookup_service/detail/rpc_typesPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/builtin/type_lookup_service/detail/TypeLookupTypesPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupManager.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupReplyListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/builtin/type_lookup_service/TypeLookupRequestListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/core/policy/ParameterList.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/topic/TopicDataType.cpp + + ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPFinder.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/IPLocator.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/md5.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/StringMatching.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/SystemInfo.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/TimedConditionVariable.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/utils/UnitsParser.cpp + + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLDynamicParser.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLElementParser.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLEndpointParser.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLParser.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLParserCommon.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/xmlparser/XMLProfileManager.cpp + + ) + +# Statistics support +if (FASTDDS_STATISTICS) + + set(statistics_sources + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/monitor-service/MonitorService.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/monitor-service/MonitorServiceListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/reader/StatisticsReaderImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/StatisticsBase.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/rtps/writer/StatisticsWriterImpl.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/monitorservice_typesPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/src/cpp/statistics/types/typesPubSubTypes.cxx + + # Monitor service is using a DataWriterHistory + ${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/DataWriterHistory.cpp + ) + + list(APPEND STATEFUL_READER_TESTS_SOURCE + ${statistics_sources} + ) + +endif() + +# SHM Transport +if(IS_THIRDPARTY_BOOST_OK) + list(APPEND STATEFUL_READER_TESTS_SOURCE + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/test_SharedMemTransport.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/shared_mem/SharedMemTransport.cpp + ) +endif() + +# TLS Support +if(TLS_FOUND) + list(APPEND STATEFUL_READER_TESTS_SOURCE + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPChannelResourceSecure.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/transport/TCPAcceptorSecure.cpp + ) +endif() + +# Security Support +if(SECURITY) + file(GLOB security_sources + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/exceptions/Exception.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/Token.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/exceptions/SecurityException.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/common/SharedSecretHandle.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/logging/Logging.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/logging/LoggingLevel.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/security/*.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/builtin/discovery/participant/DS/PDPSecurityInitiatorListener.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/security/accesscontrol/*.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/security/artifact_providers/*.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/security/authentication/*.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/security/cryptography/*.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/security/logging/*.cpp + ) + list(APPEND STATEFUL_READER_TESTS_SOURCE ${security_sources}) +endif() + +# External sources +if(TINYXML2_INCLUDE_DIR) + include_directories(${TINYXML2_INCLUDE_DIR}) +endif(TINYXML2_INCLUDE_DIR) +if(TINYXML2_SOURCE_DIR) + set(TINYXML2_SOURCES + ${TINYXML2_SOURCE_DIR}/tinyxml2.cpp + ) + list(APPEND STATEFUL_READER_TESTS_SOURCE + ${TINYXML2_SOURCES} + ) +endif() + +add_executable(StatefulReaderTests ${STATEFUL_READER_TESTS_SOURCE}) +target_compile_definitions(StatefulReaderTests PRIVATE + BOOST_ASIO_STANDALONE + ASIO_STANDALONE + ASIO_DISABLE_VISIBILITY + SQLITE_WIN32_GETVERSIONEX=0 + $<$>,$>:__DEBUG> + $<$:__INTERNALDEBUG> # Internal debug activated. + $<$,$>:_WIN32_WINNT=0x0603> + $<$,$>>:_WIN32_WINNT=0x0601> + $<$,$>:SQLITE_OS_WINRT> + $<$,$>,$>>:ASIO_DISABLE_STD_STRING_VIEW> + $<$:_ENABLE_ATOMIC_ALIGNMENT_FIX> + $<$>:FASTDDS_SHM_TRANSPORT_DISABLED> # Do not compile SHM Transport + $<$:SHM_TRANSPORT_BUILTIN> # Enable SHM as built-in transport + $<$:STDOUTERR_LOG_CONSUMER> # Enable StdoutErrConsumer as default LogConsumer + ) +target_include_directories(StatefulReaderTests PRIVATE + ${Asio_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/src/cpp + ${THIRDPARTY_BOOST_INCLUDE_DIR} + ) +target_link_libraries(StatefulReaderTests + fastcdr + fastdds::log + fastdds::xtypes::dynamic-types::impl + fastdds::xtypes::type-representation + foonathan_memory + GTest::gmock + ${CMAKE_DL_LIBS} + ${TINYXML2_LIBRARY} + $<$:OpenSSL::SSL$OpenSSL::Crypto> + $<$:iphlpapi$Shlwapi> + ${THIRDPARTY_BOOST_LINK_LIBS} + eProsima_atomic + ) +if(MSVC OR MSVC_IDE) + target_link_libraries(StatefulReaderTests ${PRIVACY} + iphlpapi Shlwapi + ) +endif() +gtest_discover_tests(StatefulReaderTests) diff --git a/test/unittest/rtps/reader/StatefulReaderTests.cpp b/test/unittest/rtps/reader/StatefulReaderTests.cpp new file mode 100644 index 00000000000..210f01cc80c --- /dev/null +++ b/test/unittest/rtps/reader/StatefulReaderTests.cpp @@ -0,0 +1,126 @@ +// 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. + +#include +#include + +// Header for the unit we are testing +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef FASTDDS_STATISTICS + +void register_monitorservice_types_type_objects() +{ +} + +void register_types_type_objects() +{ +} + +#endif // FASTDDS_STATISTICS + +namespace eprosima { + +namespace fastdds { +namespace dds { + +const InstanceHandle_t HANDLE_NIL; + +} // namespace dds +} // namespace fastdds + +namespace fastrtps { +namespace rtps { + +/* Regression Test for improving gaps processing + * https://github.com/eProsima/Fast-DDS/pull/3343 + */ +TEST(StatefulReaderTests, RTPSCorrectGAPProcessing) +{ + RTPSParticipantAttributes part_attrs; + RTPSParticipant* part = RTPSDomain::createParticipant(0, false, part_attrs, nullptr); + + HistoryAttributes hatt{}; + ReaderHistory reader_history(hatt); + WriterHistory writer_history(hatt); + + ReaderAttributes reader_att{}; + reader_att.endpoint.endpointKind = READER; + reader_att.endpoint.reliabilityKind = RELIABLE; + reader_att.endpoint.durabilityKind = TRANSIENT_LOCAL; + + RTPSReader* reader = RTPSDomain::createRTPSReader(part, reader_att, &reader_history, nullptr); + StatefulReader* uut = dynamic_cast(reader); + ASSERT_NE(uut, nullptr); + + WriterAttributes writer_att{}; + writer_att.endpoint.endpointKind = WRITER; + writer_att.endpoint.reliabilityKind = RELIABLE; + writer_att.endpoint.durabilityKind = TRANSIENT_LOCAL; + + RTPSWriter* writer = RTPSDomain::createRTPSWriter(part, writer_att, &writer_history, nullptr); + 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, {}); + + // After registration, the writer should be matched + auto writer_guid = writer->getGuid(); + EXPECT_TRUE(uut->matched_writer_is_matched(writer_guid)); + + // Send a wrong GAP + SequenceNumberSet_t seq_set(SequenceNumber_t(0, 0)); + ASSERT_NO_FATAL_FAILURE(uut->process_gap_msg(writer_guid, {0, 0}, seq_set)); + + // Destroy the writer + RTPSDomain::removeRTPSWriter(writer); + + // Destroy the reader + RTPSDomain::removeRTPSReader(reader); +} + +} // namespace rtps +} // namespace fastrtps +} // namespace eprosima + +int main( + int argc, + char** argv) +{ + testing::InitGoogleMock(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/unittest/rtps/reader/WriterProxyAcknackTests.cpp b/test/unittest/rtps/reader/WriterProxyAcknackTests.cpp index 50b4befe83b..157625870cc 100644 --- a/test/unittest/rtps/reader/WriterProxyAcknackTests.cpp +++ b/test/unittest/rtps/reader/WriterProxyAcknackTests.cpp @@ -49,13 +49,13 @@ TEST(WriterProxyAcknackTests, AcknackBackoff) SequenceNumberSet_t t1(SequenceNumber_t(0, 0)); EXPECT_CALL(readerMock, simp_send_acknack(t1)).Times(2u); EXPECT_EQ ( wproxy.initial_acknack_->getIntervalMilliSec(), - readerMock.getTimes().initialAcknackDelay.to_ns() / 1000000); + readerMock.getTimes().initial_acknack_delay.to_ns() / 1000000); wproxy.perform_initial_ack_nack(); EXPECT_EQ ( wproxy.initial_acknack_->getIntervalMilliSec(), - readerMock.getTimes().initialAcknackDelay.to_ns() * 2 / 1000000); + readerMock.getTimes().initial_acknack_delay.to_ns() * 2 / 1000000); wproxy.perform_initial_ack_nack(); EXPECT_EQ ( wproxy.initial_acknack_->getIntervalMilliSec(), - readerMock.getTimes().initialAcknackDelay.to_ns() * 4 / 1000000); + readerMock.getTimes().initial_acknack_delay.to_ns() * 4 / 1000000); // Simulate heartbeat reception and check if the delay cannot be updated again bool assert_liveliness = false; @@ -73,10 +73,10 @@ TEST(WriterProxyAcknackTests, AcknackBackoff) current_sample_lost); EXPECT_EQ ( wproxy.initial_acknack_->getIntervalMilliSec(), - readerMock.getTimes().initialAcknackDelay.to_ns() * 4 / 1000000); + readerMock.getTimes().initial_acknack_delay.to_ns() * 4 / 1000000); wproxy.perform_initial_ack_nack(); EXPECT_EQ ( wproxy.initial_acknack_->getIntervalMilliSec(), - readerMock.getTimes().initialAcknackDelay.to_ns() * 4 / 1000000); + readerMock.getTimes().initial_acknack_delay.to_ns() * 4 / 1000000); } diff --git a/test/unittest/rtps/reader/WriterProxyStopTest.cpp b/test/unittest/rtps/reader/WriterProxyStopTest.cpp index 675afa2fe4d..c1bcad78c6a 100644 --- a/test/unittest/rtps/reader/WriterProxyStopTest.cpp +++ b/test/unittest/rtps/reader/WriterProxyStopTest.cpp @@ -64,7 +64,7 @@ class WriterProxyTest : public WriterProxy const SequenceNumber_t& initial_sequence) { WriterProxy::start(attributes, initial_sequence); - initial_acknack_test_->update_interval(reader_->getTimes().initialAcknackDelay); + initial_acknack_test_->update_interval(reader_->getTimes().initial_acknack_delay); initial_acknack_test_->restart_timer(); } diff --git a/test/unittest/rtps/reader/WriterProxyTests.cpp b/test/unittest/rtps/reader/WriterProxyTests.cpp index 2d6dfa0f8a2..7e9aea92e94 100644 --- a/test/unittest/rtps/reader/WriterProxyTests.cpp +++ b/test/unittest/rtps/reader/WriterProxyTests.cpp @@ -48,8 +48,8 @@ TEST(WriterProxyTests, MissingChangesUpdate) // Testing the Timed events are properly configured EXPECT_CALL(readerMock, getEventResource()).Times(1u); WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); - EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); - EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); + EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initial_acknack_delay)).Times(1u); + EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeat_response_delay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); wproxy.start(wattr, SequenceNumber_t()); @@ -247,8 +247,8 @@ TEST(WriterProxyTests, LostChangesUpdate) StatefulReader readerMock; EXPECT_CALL(readerMock, getEventResource()).Times(1u); WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); - EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); - EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); + EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initial_acknack_delay)).Times(1u); + EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeat_response_delay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); wproxy.start(wattr, SequenceNumber_t()); @@ -373,8 +373,8 @@ TEST(WriterProxyTests, ReceivedChangeSet) /// Tests that heartbeat response timed event is updated with new interval /// Tests that initial acknack timed event is started - EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); - EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); + EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initial_acknack_delay)).Times(1u); + EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeat_response_delay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); wproxy.start(wattr, SequenceNumber_t()); @@ -543,8 +543,8 @@ TEST(WriterProxyTests, IrrelevantChangeSet) StatefulReader readerMock; EXPECT_CALL(readerMock, getEventResource()).Times(1u); WriterProxy wproxy(&readerMock, RemoteLocatorsAllocationAttributes(), ResourceLimitedContainerConfig()); - EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initialAcknackDelay)).Times(1u); - EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeatResponseDelay)).Times(1u); + EXPECT_CALL(*wproxy.initial_acknack_, update_interval(readerMock.getTimes().initial_acknack_delay)).Times(1u); + EXPECT_CALL(*wproxy.heartbeat_response_, update_interval(readerMock.getTimes().heartbeat_response_delay)).Times(1u); EXPECT_CALL(*wproxy.initial_acknack_, restart_timer()).Times(1u); wproxy.start(wattr, SequenceNumber_t()); diff --git a/test/unittest/rtps/security/SecurityHandshakeProcessTests.cpp b/test/unittest/rtps/security/SecurityHandshakeProcessTests.cpp index ba9588bde2e..08d79c5381a 100644 --- a/test/unittest/rtps/security/SecurityHandshakeProcessTests.cpp +++ b/test/unittest/rtps/security/SecurityHandshakeProcessTests.cpp @@ -97,7 +97,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_not_remote_participa EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_bad_message_class_id) @@ -140,7 +140,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_bad_message_class_id EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); return_handle(remote_identity_handle); } @@ -197,7 +197,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_not_expecting_reques EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); return_handle(remote_identity_handle); } @@ -256,7 +256,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_fail_begin_handshake EXPECT_CALL(participant_, pdp()).Times(1).WillOnce(Return(&pdp_)); EXPECT_CALL(pdp_, get_participant_proxy_data_serialized(BIGEND)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); return_handle(remote_identity_handle); } @@ -341,7 +341,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_ok_begin_handshake_r CacheChange_t* kx_change_to_remove = new CacheChange_t(500); expect_kx_exchange(kx_change_to_add, kx_change_to_remove); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); volatile_writer_->listener_->onWriterChangeReceivedByAll(volatile_writer_, kx_change_to_remove); @@ -407,7 +407,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_new_change_fail) EXPECT_CALL(participant_, pdp()).Times(1).WillOnce(Return(&pdp_)); EXPECT_CALL(pdp_, get_participant_proxy_data_serialized(BIGEND)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); return_handle(remote_identity_handle); return_handle(handshake_handle); @@ -474,7 +474,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_add_change_fail) EXPECT_CALL(participant_, pdp()).Times(1).WillOnce(Return(&pdp_)); EXPECT_CALL(pdp_, get_participant_proxy_data_serialized(BIGEND)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); destroy_manager_and_change(change2, false); @@ -606,7 +606,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_pending_handshake_re info.guid = participant_data.m_guid; EXPECT_CALL(*participant_.getListener(), onParticipantAuthentication(_, info)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); destroy_manager_and_change(change2); @@ -662,7 +662,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_fail_process_handsha info.guid = remote_participant_key; EXPECT_CALL(*participant_.getListener(), onParticipantAuthentication(_, info)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_ok_process_handshake_reply) @@ -738,7 +738,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_ok_process_handshake CacheChange_t* kx_change_to_remove = new CacheChange_t(500); expect_kx_exchange(kx_change_to_add, kx_change_to_remove); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); volatile_writer_->listener_->onWriterChangeReceivedByAll(volatile_writer_, kx_change_to_remove); } @@ -794,7 +794,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_process_handshake_re EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_process_handshake_reply_add_change_fail) @@ -851,7 +851,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_process_handshake_re EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); destroy_manager_and_change(change2, false); } @@ -918,7 +918,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_process_handshake_re EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); destroy_manager_and_change(final_message_change); } @@ -966,7 +966,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_bad_related_guid) EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_bad_related_sequence_number) @@ -1011,7 +1011,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_bad_related_sequence EXPECT_CALL(*stateless_reader_->history_, remove_change_mock(change)).Times(1). WillOnce(Return(true)); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_fail_process_handshake_final) @@ -1062,7 +1062,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_fail_process_handsha info.guid = remote_participant_key; EXPECT_CALL(*participant_.getListener(), onParticipantAuthentication(_, info)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); } TEST_F(SecurityTest, discovered_participant_process_message_ok_process_handshake_final) @@ -1138,7 +1138,7 @@ TEST_F(SecurityTest, discovered_participant_process_message_ok_process_handshake CacheChange_t* kx_change_to_remove = new CacheChange_t(500); expect_kx_exchange(kx_change_to_add, kx_change_to_remove); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); volatile_writer_->listener_->onWriterChangeReceivedByAll(volatile_writer_, kx_change_to_remove); } diff --git a/test/unittest/rtps/security/SecurityTests.cpp b/test/unittest/rtps/security/SecurityTests.cpp index d8743f30de1..dca3c2789f9 100644 --- a/test/unittest/rtps/security/SecurityTests.cpp +++ b/test/unittest/rtps/security/SecurityTests.cpp @@ -158,7 +158,7 @@ void SecurityTest::reply_process_ok( EXPECT_CALL(participant_, pdp()).Times(1).WillOnce(Return(&pdp_)); EXPECT_CALL(pdp_, get_participant_proxy_data_serialized(BIGEND)).Times(1); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); if (reply_message_change != nullptr) { @@ -249,7 +249,7 @@ void SecurityTest::final_message_process_ok( CacheChange_t* kx_change_to_remove = new CacheChange_t(200); expect_kx_exchange(kx_change_to_add, kx_change_to_remove); - stateless_reader_->listener_->onNewCacheChangeAdded(stateless_reader_, change); + stateless_reader_->listener_->on_new_cache_change_added(stateless_reader_, change); volatile_writer_->listener_->onWriterChangeReceivedByAll(volatile_writer_, kx_change_to_remove); diff --git a/test/unittest/statistics/dds/CMakeLists.txt b/test/unittest/statistics/dds/CMakeLists.txt index 89840c6cd77..150cb9efcaa 100644 --- a/test/unittest/statistics/dds/CMakeLists.txt +++ b/test/unittest/statistics/dds/CMakeLists.txt @@ -238,6 +238,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/sqlite3.c ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/SQLite3PersistenceService.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/BaseReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/reader_utils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/RTPSReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatefulPersistentReader.cpp @@ -412,6 +413,7 @@ if (SQLITE3_SUPPORT AND FASTDDS_STATISTICS AND NOT QNX) ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/PersistenceFactory.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/sqlite3.c ${PROJECT_SOURCE_DIR}/src/cpp/rtps/persistence/SQLite3PersistenceService.cpp + ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/BaseReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/reader_utils.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/RTPSReader.cpp ${PROJECT_SOURCE_DIR}/src/cpp/rtps/reader/StatefulPersistentReader.cpp diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index e80f5982c32..b033179bd49 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -712,8 +712,8 @@ TEST_F(RTPSStatisticsTests, statistics_rpts_listener_callbacks) EXPECT_TRUE(reader_->wait_for_unread_cache(Duration_t(5, 0))); // receive the sample - CacheChange_t* reader_change = nullptr; - ASSERT_TRUE(reader_->nextUntakenCache(&reader_change, nullptr)); + CacheChange_t* reader_change = reader_->next_untaken_cache(); + ASSERT_NE(nullptr, reader_change); // wait for acknowledgement EXPECT_TRUE(writer_->wait_for_all_acked(Duration_t(5, 0))); @@ -838,8 +838,8 @@ TEST_F(RTPSStatisticsTests, statistics_rpts_listener_callbacks_fragmented) EXPECT_TRUE(reader_->wait_for_unread_cache(Duration_t(10, 0))); // receive the sample - CacheChange_t* reader_change = nullptr; - ASSERT_TRUE(reader_->nextUntakenCache(&reader_change, nullptr)); + CacheChange_t* reader_change = reader_->next_untaken_cache(); + ASSERT_NE(nullptr, reader_change); // wait for acknowledgement EXPECT_TRUE(writer_->wait_for_all_acked(Duration_t(1, 0))); @@ -990,8 +990,8 @@ TEST_F(RTPSStatisticsTests, statistics_rpts_listener_callbacks_no_enabled_writer EXPECT_TRUE(reader_->wait_for_unread_cache(Duration_t(5, 0))); // receive the sample - CacheChange_t* reader_change = nullptr; - ASSERT_TRUE(reader_->nextUntakenCache(&reader_change, nullptr)); + CacheChange_t* reader_change = reader_->next_untaken_cache(); + ASSERT_NE(nullptr, reader_change); // wait for acknowledgement EXPECT_TRUE(writer_->wait_for_all_acked(Duration_t(5, 0))); @@ -1079,8 +1079,8 @@ TEST_F(RTPSStatisticsTests, statistics_rpts_listener_gap_callback) EXPECT_TRUE(reader_->wait_for_unread_cache(Duration_t(5, 0))); // receive the second sample - CacheChange_t* reader_change = nullptr; - ASSERT_TRUE(reader_->nextUntakenCache(&reader_change, nullptr)); + CacheChange_t* reader_change = reader_->next_untaken_cache(); + ASSERT_NE(nullptr, reader_change); // wait for acknowledgement EXPECT_TRUE(writer_->wait_for_all_acked(Duration_t(1, 0))); diff --git a/test/unittest/xmlparser/XMLElementParserTests.cpp b/test/unittest/xmlparser/XMLElementParserTests.cpp index 61ba62230db..7c2f5f76d99 100644 --- a/test/unittest/xmlparser/XMLElementParserTests.cpp +++ b/test/unittest/xmlparser/XMLElementParserTests.cpp @@ -1075,7 +1075,7 @@ TEST_F(XMLParserTests, getXMLSubscriberAttributes_NegativeClauses) "", "", "", - "", + "", "", "", "", @@ -2909,8 +2909,8 @@ TEST_F(XMLParserTests, getXMLWriterTimes_NegativeClauses) /* * This test checks the negative cases in the xml child element of * 1. Check an invalid tag of: - * - * + * + * * 2. Check invalid element */ TEST_F(XMLParserTests, getXMLReaderTimes_NegativeClauses) @@ -2941,8 +2941,8 @@ TEST_F(XMLParserTests, getXMLReaderTimes_NegativeClauses) std::vector field_vec = { - "initialAcknackDelay", - "heartbeatResponseDelay", + "initial_acknack_delay", + "heartbeat_response_delay", }; for (std::string tag : field_vec) diff --git a/test/unittest/xmlparser/XMLEndpointParserTests.cpp b/test/unittest/xmlparser/XMLEndpointParserTests.cpp index c92dbed8d23..bcc68126fc9 100644 --- a/test/unittest/xmlparser/XMLEndpointParserTests.cpp +++ b/test/unittest/xmlparser/XMLEndpointParserTests.cpp @@ -124,7 +124,7 @@ TEST_F(XMLEndpointParserTests, loadXMLNode) \ 3\ 4\ - true\ + true\ HelloWorldTopic\ HelloWorld\ WITH_KEY\ @@ -207,7 +207,7 @@ TEST_F(XMLEndpointParserTests, loadXMLParticipantEndpoint) \ 3\ 4\ - true\ + true\ HelloWorldTopic\ HelloWorld\ WITH_KEY\ @@ -299,7 +299,7 @@ TEST_F(XMLEndpointParserTests, loadXMLReaderEndpoint) \ 3\ 4\ - true\ + true\ HelloWorldTopic\ HelloWorld\ WITH_KEY\ @@ -467,7 +467,7 @@ TEST_F(XMLEndpointParserTests, loadXMLReaderEndpoint) { "userId", "entityID", - "expectsInlineQos", + "expects_inline_qos", "topicName", "topicDataType", "topicKind", @@ -545,7 +545,7 @@ TEST_F(XMLEndpointParserTests, loadXMLWriterEndpoint) \ 3\ 4\ - true\ + true\ HelloWorldTopic\ HelloWorld\ NO_KEY\ @@ -717,7 +717,7 @@ TEST_F(XMLEndpointParserTests, loadXMLWriterEndpoint) { "userId", "entityID", - "expectsInlineQos", + "expects_inline_qos", "topicName", "topicDataType", "topicKind", diff --git a/test/unittest/xmlparser/XMLProfileParserTests.cpp b/test/unittest/xmlparser/XMLProfileParserTests.cpp index 094317b57f7..3054ecbd13a 100644 --- a/test/unittest/xmlparser/XMLProfileParserTests.cpp +++ b/test/unittest/xmlparser/XMLProfileParserTests.cpp @@ -1167,9 +1167,9 @@ TEST_P(XMLProfileParserTests, XMLParserSubscriber) EXPECT_EQ(sub_qos.m_partition.names()[1], "partition_name_d"); EXPECT_EQ(sub_qos.m_partition.names()[2], "partition_name_e"); EXPECT_EQ(sub_qos.m_partition.names()[3], "partition_name_f"); - EXPECT_EQ(sub_times.initialAcknackDelay, c_TimeZero); - EXPECT_EQ(sub_times.heartbeatResponseDelay.seconds, 18); - EXPECT_EQ(sub_times.heartbeatResponseDelay.nanosec, 81u); + EXPECT_EQ(sub_times.initial_acknack_delay, c_TimeZero); + EXPECT_EQ(sub_times.heartbeat_response_delay.seconds, 18); + EXPECT_EQ(sub_times.heartbeat_response_delay.nanosec, 81u); EXPECT_TRUE(subscriber_atts.ignore_non_matching_locators); check_external_locator(subscriber_atts.external_unicast_locators, 100, 200, 10, "10.10.10.10", 2001); IPLocator::setIPv4(locator, 192, 168, 1, 10); @@ -1239,9 +1239,9 @@ TEST_F(XMLProfileParserBasicTests, XMLParserSubscriberDeprecated) EXPECT_EQ(sub_qos.m_partition.names()[1], "partition_name_d"); EXPECT_EQ(sub_qos.m_partition.names()[2], "partition_name_e"); EXPECT_EQ(sub_qos.m_partition.names()[3], "partition_name_f"); - EXPECT_EQ(sub_times.initialAcknackDelay, c_TimeZero); - EXPECT_EQ(sub_times.heartbeatResponseDelay.seconds, 18); - EXPECT_EQ(sub_times.heartbeatResponseDelay.nanosec, 81u); + EXPECT_EQ(sub_times.initial_acknack_delay, c_TimeZero); + EXPECT_EQ(sub_times.heartbeat_response_delay.seconds, 18); + EXPECT_EQ(sub_times.heartbeat_response_delay.nanosec, 81u); EXPECT_TRUE(subscriber_atts.ignore_non_matching_locators); check_external_locator(subscriber_atts.external_unicast_locators, 100, 200, 10, "10.10.10.10", 2001); IPLocator::setIPv4(locator, 192, 168, 1, 10); @@ -1309,9 +1309,9 @@ TEST_P(XMLProfileParserTests, XMLParserDefaultSubscriberProfile) EXPECT_EQ(sub_qos.m_partition.names()[1], "partition_name_d"); EXPECT_EQ(sub_qos.m_partition.names()[2], "partition_name_e"); EXPECT_EQ(sub_qos.m_partition.names()[3], "partition_name_f"); - EXPECT_EQ(sub_times.initialAcknackDelay, c_TimeZero); - EXPECT_EQ(sub_times.heartbeatResponseDelay.seconds, 18); - EXPECT_EQ(sub_times.heartbeatResponseDelay.nanosec, 81u); + EXPECT_EQ(sub_times.initial_acknack_delay, c_TimeZero); + EXPECT_EQ(sub_times.heartbeat_response_delay.seconds, 18); + EXPECT_EQ(sub_times.heartbeat_response_delay.nanosec, 81u); EXPECT_TRUE(subscriber_atts.ignore_non_matching_locators); check_external_locator(subscriber_atts.external_unicast_locators, 100, 200, 10, "10.10.10.10", 2001); IPLocator::setIPv4(locator, 192, 168, 1, 10); @@ -1379,9 +1379,9 @@ TEST_F(XMLProfileParserBasicTests, XMLParserDefaultSubscriberProfileDeprecated) EXPECT_EQ(sub_qos.m_partition.names()[1], "partition_name_d"); EXPECT_EQ(sub_qos.m_partition.names()[2], "partition_name_e"); EXPECT_EQ(sub_qos.m_partition.names()[3], "partition_name_f"); - EXPECT_EQ(sub_times.initialAcknackDelay, c_TimeZero); - EXPECT_EQ(sub_times.heartbeatResponseDelay.seconds, 18); - EXPECT_EQ(sub_times.heartbeatResponseDelay.nanosec, 81u); + EXPECT_EQ(sub_times.initial_acknack_delay, c_TimeZero); + EXPECT_EQ(sub_times.heartbeat_response_delay.seconds, 18); + EXPECT_EQ(sub_times.heartbeat_response_delay.nanosec, 81u); EXPECT_TRUE(subscriber_atts.ignore_non_matching_locators); check_external_locator(subscriber_atts.external_unicast_locators, 100, 200, 10, "10.10.10.10", 2001); IPLocator::setIPv4(locator, 192, 168, 1, 10); diff --git a/test/unittest/xmlparser/test_xml_deprecated.xml b/test/unittest/xmlparser/test_xml_deprecated.xml index 94406192e9f..db54bcd0bb6 100644 --- a/test/unittest/xmlparser/test_xml_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_deprecated.xml @@ -374,14 +374,14 @@ - + 0 0 - - + + 18 81 - + @@ -421,7 +421,7 @@ 2001 - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/test/unittest/xmlparser/test_xml_profile.xml b/test/unittest/xmlparser/test_xml_profile.xml index f3751a48ba3..2e77e787db1 100644 --- a/test/unittest/xmlparser/test_xml_profile.xml +++ b/test/unittest/xmlparser/test_xml_profile.xml @@ -386,14 +386,14 @@ - + 0 0 - - + + 18 81 - + @@ -433,7 +433,7 @@ 2001 - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/test/unittest/xmlparser/test_xml_profile_env_var.xml b/test/unittest/xmlparser/test_xml_profile_env_var.xml index f61191a6758..6199da9384c 100644 --- a/test/unittest/xmlparser/test_xml_profile_env_var.xml +++ b/test/unittest/xmlparser/test_xml_profile_env_var.xml @@ -369,14 +369,14 @@ - + ${XML_PROFILES_ENV_VAR_133} ${XML_PROFILES_ENV_VAR_134} - - + + ${XML_PROFILES_ENV_VAR_135} ${XML_PROFILES_ENV_VAR_136} - + @@ -416,7 +416,7 @@ ${XML_PROFILES_ENV_VAR_146} - ${XML_PROFILES_ENV_VAR_147} + ${XML_PROFILES_ENV_VAR_147} ${XML_PROFILES_ENV_VAR_148} ${XML_PROFILES_ENV_VAR_149} ${XML_PROFILES_ENV_VAR_150} diff --git a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml index 1e2ee59aef7..bae4faabc90 100644 --- a/test/unittest/xmlparser/test_xml_rooted_deprecated.xml +++ b/test/unittest/xmlparser/test_xml_rooted_deprecated.xml @@ -324,14 +324,14 @@ - + 0 0 - - + + 18 81 - + @@ -364,7 +364,7 @@ - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/test/unittest/xmlparser/test_xml_rooted_profile.xml b/test/unittest/xmlparser/test_xml_rooted_profile.xml index d02b379f79a..4b3e797595c 100644 --- a/test/unittest/xmlparser/test_xml_rooted_profile.xml +++ b/test/unittest/xmlparser/test_xml_rooted_profile.xml @@ -323,14 +323,14 @@ - + 0 0 - - + + 18 81 - + @@ -363,7 +363,7 @@ - true + true PREALLOCATED_WITH_REALLOC 13 31 diff --git a/versions.md b/versions.md index 3e64f5393a2..7505726fb33 100644 --- a/versions.md +++ b/versions.md @@ -6,6 +6,10 @@ Forthcoming * Remove API marked as deprecated. * Removed deprecated FastRTPS API tests. * Removed no longer supported `FASTRTPS_API_TESTS` CMake options. +* RTPS layer APIs refactor (RTPSReader, ReaderListener, ReaderAttributes): + * 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 * Public API that is no longer public: * XML Parser API no longer public. * ParticipantAttributes