diff --git a/examples/C++/RTPSTest_as_socket/TestReaderSocket.h b/examples/C++/RTPSTest_as_socket/TestReaderSocket.h index 4c7a77a999c..c7f815b48d5 100644 --- a/examples/C++/RTPSTest_as_socket/TestReaderSocket.h +++ b/examples/C++/RTPSTest_as_socket/TestReaderSocket.h @@ -28,23 +28,42 @@ class TestReaderSocket { public: + TestReaderSocket(); + virtual ~TestReaderSocket(); + eprosima::fastrtps::rtps::RTPSParticipant* mp_participant; + eprosima::fastrtps::rtps::RTPSReader* mp_reader; + eprosima::fastrtps::rtps::ReaderHistory* mp_history; - bool init(std::string ip,uint32_t port); + + bool init( + std::string ip, + uint32_t port); + void run(); - class MyListener:public eprosima::fastrtps::rtps::ReaderListener + + class MyListener : public eprosima::fastrtps::rtps::ReaderListener { public: - MyListener():m_received(0){}; - ~MyListener(){}; + + MyListener() + : m_received(0) + { + } + + ~MyListener() + { + } + void onNewCacheChangeAdded( eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change) override; uint32_t m_received; - }m_listener; + } + m_listener; }; diff --git a/examples/C++/RTPSTest_as_socket/TestWriterSocket.h b/examples/C++/RTPSTest_as_socket/TestWriterSocket.h index 84704980493..08202aacfe6 100644 --- a/examples/C++/RTPSTest_as_socket/TestWriterSocket.h +++ b/examples/C++/RTPSTest_as_socket/TestWriterSocket.h @@ -27,15 +27,27 @@ #include #include -class TestWriterSocket { +class TestWriterSocket +{ + public: - TestWriterSocket(); - virtual ~TestWriterSocket(); - eprosima::fastrtps::rtps::RTPSParticipant* mp_participant; - eprosima::fastrtps::rtps::RTPSWriter* mp_writer; - eprosima::fastrtps::rtps::WriterHistory* mp_history; - bool init(std::string ip,uint32_t port); - void run(uint16_t nmsgs); + + TestWriterSocket(); + + virtual ~TestWriterSocket(); + + eprosima::fastrtps::rtps::RTPSParticipant* mp_participant; + + eprosima::fastrtps::rtps::RTPSWriter* mp_writer; + + eprosima::fastrtps::rtps::WriterHistory* mp_history; + + bool init( + std::string ip, + uint32_t port); + + void run( + uint16_t nmsgs); }; #endif /* TESTWRITER_H_ */ diff --git a/examples/C++/RTPSTest_custom_transport/TestReaderSocket.cpp b/examples/C++/RTPSTest_custom_transport/TestReaderSocket.cpp index 315fef3d34a..52ef9d0c480 100644 --- a/examples/C++/RTPSTest_custom_transport/TestReaderSocket.cpp +++ b/examples/C++/RTPSTest_custom_transport/TestReaderSocket.cpp @@ -45,8 +45,6 @@ TestReaderSocket::TestReaderSocket() , mp_reader(nullptr) , mp_history(nullptr) { - - } TestReaderSocket::~TestReaderSocket() @@ -91,7 +89,7 @@ bool TestReaderSocket::init( #else // Header reduction on top of timestamp auto hrDesc = std::make_shared(tsDesc); -#endif +#endif // if HAVE_ZLIB || HAVE_BZIP2 PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_version", "true")); PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_vendor_id", diff --git a/examples/C++/RTPSTest_custom_transport/TestReaderSocket.h b/examples/C++/RTPSTest_custom_transport/TestReaderSocket.h index d1679b8fb56..c6183868031 100644 --- a/examples/C++/RTPSTest_custom_transport/TestReaderSocket.h +++ b/examples/C++/RTPSTest_custom_transport/TestReaderSocket.h @@ -39,7 +39,7 @@ class TestReaderSocket void run(); class MyListener : public eprosima::fastrtps::rtps::ReaderListener { -public: + public: MyListener() : m_received(0) @@ -54,8 +54,9 @@ class TestReaderSocket eprosima::fastrtps::rtps::RTPSReader* reader, const eprosima::fastrtps::rtps::CacheChange_t* const change); uint32_t m_received; - } m_listener; + } + m_listener; }; -#endif /* TESTREADER_H_ */ +#endif // ifndef TESTREADERSOCKET_H_ diff --git a/examples/C++/RTPSTest_custom_transport/TestWriterSocket.cpp b/examples/C++/RTPSTest_custom_transport/TestWriterSocket.cpp index 6521a0d3a9a..c722f5787f8 100644 --- a/examples/C++/RTPSTest_custom_transport/TestWriterSocket.cpp +++ b/examples/C++/RTPSTest_custom_transport/TestWriterSocket.cpp @@ -43,8 +43,6 @@ TestWriterSocket::TestWriterSocket() , mp_writer(nullptr) , mp_history(nullptr) { - - } TestWriterSocket::~TestWriterSocket() @@ -89,7 +87,7 @@ bool TestWriterSocket::init( #else // Header reduction on top of timestamp auto hrDesc = std::make_shared(tsDesc); -#endif +#endif // if HAVE_ZLIB || HAVE_BZIP2 PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_version", "true")); PParam.properties.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_vendor_id", @@ -142,16 +140,17 @@ void TestWriterSocket::run( { for (int i = 0; i < nmsgs; ++i ) { - fastrtps::rtps::CacheChange_t* ch = mp_writer->new_change([]() -> uint32_t { - return 255; - }, fastrtps::rtps::ALIVE); + fastrtps::rtps::CacheChange_t* ch = mp_writer->new_change([]() -> uint32_t + { + return 255; + }, fastrtps::rtps::ALIVE); #if defined(_WIN32) ch->serializedPayload.length = sprintf_s((char*)ch->serializedPayload.data, 255, "My example string %d", i) + 1; #else ch->serializedPayload.length = sprintf((char*)ch->serializedPayload.data, "My example string %d", i) + 1; -#endif +#endif // if defined(_WIN32) printf("Sending: %s\n", (char*)ch->serializedPayload.data); mp_history->add_change(ch); } diff --git a/examples/C++/RTPSTest_custom_transport/main_RTPSTest.cpp b/examples/C++/RTPSTest_custom_transport/main_RTPSTest.cpp index 3d0554ffb83..2b3c1bea316 100644 --- a/examples/C++/RTPSTest_custom_transport/main_RTPSTest.cpp +++ b/examples/C++/RTPSTest_custom_transport/main_RTPSTest.cpp @@ -32,20 +32,27 @@ using namespace rtps; using namespace std; -int main(int argc, char** argv){ +int main( + int argc, + char** argv) +{ std::cout << "Starting" << std::endl; int type; uint32_t port = 7000; - if(argc > 1) + if (argc > 1) { - if(strcmp(argv[1],"writer")==0) + if (strcmp(argv[1], "writer") == 0) + { type = 1; - else if(strcmp(argv[1],"reader")==0) + } + else if (strcmp(argv[1], "reader") == 0) + { type = 2; + } else { - std::cout << "NEEDS writer OR reader as first argument"< -#endif +#endif // ifndef NETWORK_FACTORY_HPP diff --git a/include/fastrtps/transport/TransportInterface.h b/include/fastrtps/transport/TransportInterface.h index 41a5007370d..9e0d3ab729b 100644 --- a/include/fastrtps/transport/TransportInterface.h +++ b/include/fastrtps/transport/TransportInterface.h @@ -37,4 +37,4 @@ static const std::string s_IPv6AddressAny = fastdds::rtps::s_IPv6AddressAny; } // namespace fastrtps } // namespace eprosima -#endif +#endif // ifndef TRANSPORT_INTERFACE_H diff --git a/include/fastrtps/transport/UDPv4TransportDescriptor.h b/include/fastrtps/transport/UDPv4TransportDescriptor.h index 9d3e994123d..835c24c9c37 100644 --- a/include/fastrtps/transport/UDPv4TransportDescriptor.h +++ b/include/fastrtps/transport/UDPv4TransportDescriptor.h @@ -29,4 +29,4 @@ using UDPv4TransportDescriptor = fastdds::rtps::UDPv4TransportDescriptor; } // namespace fastrtps } // namespace eprosima -#endif +#endif // ifndef UDPV4_TRANSPORT_DESCRIPTOR diff --git a/include/fastrtps/transport/UDPv6TransportDescriptor.h b/include/fastrtps/transport/UDPv6TransportDescriptor.h index 6a4d086099d..546dc81d5be 100644 --- a/include/fastrtps/transport/UDPv6TransportDescriptor.h +++ b/include/fastrtps/transport/UDPv6TransportDescriptor.h @@ -29,4 +29,4 @@ using UDPv6TransportDescriptor = fastdds::rtps::UDPv6TransportDescriptor; } // namespace fastrtps } // namespace eprosima -#endif +#endif // ifndef UDPV6_TRANSPORT_DESCRIPTOR diff --git a/include/fastrtps/transport/test_UDPv4TransportDescriptor.h b/include/fastrtps/transport/test_UDPv4TransportDescriptor.h index afda9b3bd07..878fb671c58 100644 --- a/include/fastrtps/transport/test_UDPv4TransportDescriptor.h +++ b/include/fastrtps/transport/test_UDPv4TransportDescriptor.h @@ -29,4 +29,4 @@ using test_UDPv4TransportDescriptor = fastdds::rtps::test_UDPv4TransportDescript } // namespace fastrtps } // namespace eprosima -#endif +#endif // ifndef TEST_UDPV4_TRANSPORT_DESCRIPTOR diff --git a/include/fastrtps/utils/StringMatching.h b/include/fastrtps/utils/StringMatching.h index 16765ad3618..420cf507d7d 100644 --- a/include/fastrtps/utils/StringMatching.h +++ b/include/fastrtps/utils/StringMatching.h @@ -67,8 +67,9 @@ class RTPS_DllAPI StringMatching int base = 10); }; -} +} // namespace rtps } /* namespace rtps */ } /* namespace eprosima */ + #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif /* STRINGMATCHING_H_ */ +#endif // ifndef STRINGMATCHING_H_ diff --git a/src/cpp/rtps/transport/ChainingReceiverResource.hpp b/src/cpp/rtps/transport/ChainingReceiverResource.hpp index 373504b73d2..37fef728a1f 100644 --- a/src/cpp/rtps/transport/ChainingReceiverResource.hpp +++ b/src/cpp/rtps/transport/ChainingReceiverResource.hpp @@ -46,8 +46,8 @@ class ChainingReceiverResource : public TransportReceiverInterface }; -} -} -} +} // namespace rtps +} // namespace fastdds +} // namespace eprosima #endif // TRANSPORT_CHAININGRECEIVERRESOURCE_HPP diff --git a/src/cpp/rtps/transport/ChainingTransport.cpp b/src/cpp/rtps/transport/ChainingTransport.cpp index 9c3d9e9a042..1f2859d00db 100644 --- a/src/cpp/rtps/transport/ChainingTransport.cpp +++ b/src/cpp/rtps/transport/ChainingTransport.cpp @@ -44,6 +44,6 @@ bool ChainingTransport::OpenOutputChannel( return returned_value; } -} -} -} +} // namespace rtps +} // namespace fastdds +} // namespace eprosima diff --git a/src/cpp/rtps/transport/UDPTransportInterface.h b/src/cpp/rtps/transport/UDPTransportInterface.h index e23b2e186f4..e9b0a07f066 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.h +++ b/src/cpp/rtps/transport/UDPTransportInterface.h @@ -169,7 +169,7 @@ class UDPTransportInterface : public TransportInterface std::vector currentInterfaces; mutable std::recursive_mutex mInputMapMutex; - std::map > mInputSockets; + std::map> mInputSockets; uint32_t mSendBufferSize; uint32_t mReceiveBufferSize; diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h index d5f1a4f9098..096f3b954e2 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h +++ b/src/cpp/rtps/transport/shared_mem/SharedMemTransport.h @@ -219,7 +219,7 @@ class SharedMemTransport : public TransportInterface std::shared_ptr shared_mem_segment_; - std::shared_ptr > packet_logger_; + std::shared_ptr> packet_logger_; friend class SharedMemChannelResource; diff --git a/src/cpp/utils/StringMatching.cpp b/src/cpp/utils/StringMatching.cpp index d19504c39cc..a9e18c1a6cd 100644 --- a/src/cpp/utils/StringMatching.cpp +++ b/src/cpp/utils/StringMatching.cpp @@ -152,26 +152,37 @@ bool StringMatching::matchString( #endif // if defined(__cplusplus_winrt) -std::vector StringMatching::split(const std::string& str, const std::string& delim) +std::vector StringMatching::split( + const std::string& str, + const std::string& delim) { std::vector tokens; size_t prev = 0, pos = 0; do { pos = str.find(delim, prev); - if (pos == std::string::npos) pos = str.length(); + if (pos == std::string::npos) + { + pos = str.length(); + } std::string token = str.substr(prev, pos - prev); - if (!token.empty()) tokens.push_back(token); + if (!token.empty()) + { + tokens.push_back(token); + } prev = pos + delim.length(); } while (pos < str.length() && prev < str.length()); return tokens; } -bool StringMatching::readUint32(uint32_t& n, std::string const& str, int base) +bool StringMatching::readUint32( + uint32_t& n, + std::string const& str, + int base) { - char *endp; + char* endp; unsigned long value = strtoul(str.c_str(), &endp, base); - if ( (endp == str.c_str()) || (value == ULONG_MAX && errno == ERANGE) ) + if ((endp == str.c_str()) || (value == ULONG_MAX && errno == ERANGE)) { return false; } diff --git a/test/blackbox/BlackboxTestsTransportCustom.cpp b/test/blackbox/BlackboxTestsTransportCustom.cpp index 97dccef4978..6a30713c4aa 100644 --- a/test/blackbox/BlackboxTestsTransportCustom.cpp +++ b/test/blackbox/BlackboxTestsTransportCustom.cpp @@ -81,7 +81,7 @@ TEST(CustomTransport, PubSubSrcTimestampHelloworld) auto trDesc = std::make_shared(udpTr); int callback_num = 0; trDesc->callback_parameter = &callback_num; - trDesc->callback = [] (void* p, int32_t /*s_time*/, int32_t /*r_time*/, uint32_t /*len*/) + trDesc->callback = [](void* p, int32_t /*s_time*/, int32_t /*r_time*/, uint32_t /*len*/) { int* pp = (int*)p; *pp = *pp + 1; @@ -148,7 +148,7 @@ TEST(CustomTransport, PubSubCompressZLibHelloworld) // Block reader until reception finished or timeout. reader.block_for_at_least(2); } -#endif +#endif // if HAVE_ZLIB #if HAVE_BZIP2 TEST(CustomTransport, PubSubCompressBZip2Helloworld) @@ -185,7 +185,7 @@ TEST(CustomTransport, PubSubCompressBZip2Helloworld) // Block reader until reception finished or timeout. reader.block_for_at_least(2); } -#endif +#endif // if HAVE_BZIP2 #if HAVE_ZLIB || HAVE_BZIP2 TEST(CustomTransport, PubSubCompressAutoHelloworld) @@ -222,7 +222,7 @@ TEST(CustomTransport, PubSubCompressAutoHelloworld) // Block reader until reception finished or timeout. reader.block_for_at_least(2); } -#endif +#endif // if HAVE_ZLIB || HAVE_BZIP2 TEST(CustomTransport, PubSubChainReductionsHelloworld) { @@ -248,14 +248,14 @@ TEST(CustomTransport, PubSubChainReductionsHelloworld) auto zDesc = std::make_shared(tsDesc); policies.properties().emplace_back(fastrtps::rtps::Property("rtps.payload_compression.compression_library", "AUTOMATIC")); -#endif +#endif // if HAVE_ZLIB || HAVE_BZIP2 // Header reduction on top of compression (or timestamp if compression not available) #if HAVE_ZLIB || HAVE_BZIP2 auto hrDesc = std::make_shared(zDesc); #else auto hrDesc = std::make_shared(tsDesc); -#endif +#endif // if HAVE_ZLIB || HAVE_BZIP2 policies.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_protocol", "true")); policies.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_version", "true")); policies.properties().emplace_back(fastrtps::rtps::Property("rtps.header_reduction.remove_vendor_id", "true")); diff --git a/test/unittest/rtps/network/mock/MockTransport.cpp b/test/unittest/rtps/network/mock/MockTransport.cpp index 57b89dd4afb..f830115e7a5 100644 --- a/test/unittest/rtps/network/mock/MockTransport.cpp +++ b/test/unittest/rtps/network/mock/MockTransport.cpp @@ -18,13 +18,14 @@ using namespace std; -namespace eprosima{ -namespace fastrtps{ -namespace rtps{ +namespace eprosima { +namespace fastrtps { +namespace rtps { std::vector MockTransport::mockTransportInstances; -MockTransport::MockTransport(const MockTransportDescriptor& descriptor) +MockTransport::MockTransport( + const MockTransportDescriptor& descriptor) : TransportInterface(descriptor.supportedKind) , mockMaximumChannels(descriptor.maximumChannels) { @@ -42,28 +43,33 @@ MockTransport::~MockTransport() { // Remove this mock from the handle vector mockTransportInstances.erase(std::remove(mockTransportInstances.begin(), - mockTransportInstances.end(), - this), - mockTransportInstances.end()); + mockTransportInstances.end(), + this), + mockTransportInstances.end()); } -bool MockTransport::init(const PropertyPolicy* /*properties*/) +bool MockTransport::init( + const PropertyPolicy* /*properties*/) { return true; } -bool MockTransport::IsInputChannelOpen(const Locator_t& locator) const +bool MockTransport::IsInputChannelOpen( + const Locator_t& locator) const { - return (find(mockOpenInputChannels.begin(), mockOpenInputChannels.end(), locator.port) != mockOpenInputChannels.end()); + return (find(mockOpenInputChannels.begin(), mockOpenInputChannels.end(), + locator.port) != mockOpenInputChannels.end()); } -bool MockTransport::IsLocatorSupported(const Locator_t& locator) const +bool MockTransport::IsLocatorSupported( + const Locator_t& locator) const { return locator.kind == transport_kind_; } -bool MockTransport::is_locator_allowed(const Locator_t& /*locator*/) const +bool MockTransport::is_locator_allowed( + const Locator_t& /*locator*/) const { return true; } @@ -92,7 +98,8 @@ bool MockTransport::OpenOutputChannel( bool MockTransport::OpenInputChannel( const Locator_t& locator, - TransportReceiverInterface*, uint32_t) + TransportReceiverInterface*, + uint32_t) { mockOpenInputChannels.push_back(locator.port); return true; @@ -105,7 +112,8 @@ bool MockTransport::DoInputLocatorsMatch( return left.port == right.port; } -Locator_t MockTransport::RemoteToMainLocal(const Locator_t& remote) const +Locator_t MockTransport::RemoteToMainLocal( + const Locator_t& remote) const { Locator_t mainLocal(remote); //memset(mainLocal.address, 0x00, sizeof(mainLocal.address)); @@ -113,23 +121,26 @@ Locator_t MockTransport::RemoteToMainLocal(const Locator_t& remote) const return mainLocal; } -bool MockTransport::CloseInputChannel(const Locator_t& locator) +bool MockTransport::CloseInputChannel( + const Locator_t& locator) { - mockOpenInputChannels.erase(std::remove(mockOpenInputChannels.begin(), - mockOpenInputChannels.end(), - locator.port), - mockOpenInputChannels.end()); - return true; + mockOpenInputChannels.erase(std::remove(mockOpenInputChannels.begin(), + mockOpenInputChannels.end(), + locator.port), + mockOpenInputChannels.end()); + return true; } -LocatorList_t MockTransport::NormalizeLocator(const Locator_t& locator) +LocatorList_t MockTransport::NormalizeLocator( + const Locator_t& locator) { LocatorList_t list; list.push_back(locator); return list; } -void MockTransport::select_locators(LocatorSelector& selector) const +void MockTransport::select_locators( + LocatorSelector& selector) const { ResourceLimitedVector& entries = selector.transport_starts(); for (size_t i = 0; i < entries.size(); ++i) diff --git a/test/unittest/rtps/network/mock/MockTransport.h b/test/unittest/rtps/network/mock/MockTransport.h index 98cc0d7fbde..fb83d0d3d45 100644 --- a/test/unittest/rtps/network/mock/MockTransport.h +++ b/test/unittest/rtps/network/mock/MockTransport.h @@ -70,9 +70,9 @@ class MockTransport : public TransportInterface const Locator_t&) override; virtual bool OpenInputChannel( - const Locator_t&, - TransportReceiverInterface*, - uint32_t) override; + const Locator_t&, + TransportReceiverInterface*, + uint32_t) override; virtual bool CloseInputChannel( const Locator_t&) override; @@ -231,4 +231,4 @@ class MockTransportDescriptor : public SocketTransportDescriptor } // namespace fastrtps } // namespace eprosima -#endif +#endif // ifndef MOCK_TRANSPORT_H