transport: minor refactoring
Duplicate code in StreamTransportImpl<BaseTransport, Protocol>::send
overloads is split to another internal function.
This commit also corrects code style in transport directory.
refs #3136
Change-Id: I47958c4117b6d2c7dde356430e405da2505f942a
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
index b0b5124..eb7878b 100644
--- a/src/transport/tcp-transport.hpp
+++ b/src/transport/tcp-transport.hpp
@@ -22,56 +22,61 @@
#ifndef NDN_TRANSPORT_TCP_TRANSPORT_HPP
#define NDN_TRANSPORT_TCP_TRANSPORT_HPP
-#include "../common.hpp"
#include "transport.hpp"
#include "../util/config-file.hpp"
-
-// forward declaration
-namespace boost { namespace asio { namespace ip { class tcp; } } }
+namespace boost {
+namespace asio {
+namespace ip {
+class tcp;
+} // namespace ip
+} // namespace asio
+} // namespace boost
namespace ndn {
-// forward declaration
-template<class T, class U> class StreamTransportImpl;
-template<class T, class U> class StreamTransportWithResolverImpl;
+template<typename BaseTransport, typename Protocol>
+class StreamTransportImpl;
+template<typename BaseTransport, typename Protocol>
+class StreamTransportWithResolverImpl;
+
+/** \brief a transport using TCP socket
+ */
class TcpTransport : public Transport
{
public:
+ explicit
TcpTransport(const std::string& host, const std::string& port = "6363");
+
~TcpTransport();
- // from Transport
virtual void
connect(boost::asio::io_service& ioService,
- const ReceiveCallback& receiveCallback);
+ const ReceiveCallback& receiveCallback) override;
virtual void
- close();
+ close() override;
virtual void
- pause();
+ pause() override;
virtual void
- resume();
+ resume() override;
virtual void
- send(const Block& wire);
+ send(const Block& wire) override;
virtual void
- send(const Block& header, const Block& payload);
+ send(const Block& header, const Block& payload) override;
- /**
- * @brief Create transport with parameters defined in URI
- *
- * @throws Transport::Error if incorrect URI or unsupported protocol is specified
+ /** \brief Create transport with parameters defined in URI
+ * \throw Transport::Error incorrect URI or unsupported protocol is specified
*/
static shared_ptr<TcpTransport>
create(const std::string& uri);
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-
static std::pair<std::string, std::string>
getSocketHostAndPortFromUri(const std::string& uri);
@@ -82,7 +87,7 @@
typedef StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp> Impl;
friend class StreamTransportImpl<TcpTransport, boost::asio::ip::tcp>;
friend class StreamTransportWithResolverImpl<TcpTransport, boost::asio::ip::tcp>;
- shared_ptr< Impl > m_impl;
+ shared_ptr<Impl> m_impl;
};
} // namespace ndn