face: move Channel and subclasses into nfd::face namespace
Change-Id: I163ef20e11b65d19d68585ec075fd3cd224a573b
diff --git a/daemon/face/channel.cpp b/daemon/face/channel.cpp
index 65e0a25..ed13cb2 100644
--- a/daemon/face/channel.cpp
+++ b/daemon/face/channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,10 +26,9 @@
#include "channel.hpp"
namespace nfd {
+namespace face {
-Channel::~Channel()
-{
-}
+Channel::~Channel() = default;
void
Channel::setUri(const FaceUri& uri)
@@ -40,8 +39,6 @@
void
connectFaceClosedSignal(Face& face, const std::function<void()>& f)
{
- using face::FaceState;
-
face.afterStateChange.connect(
[f] (FaceState oldState, FaceState newState) {
if (newState == FaceState::CLOSED) {
@@ -50,4 +47,5 @@
});
}
+} // namespace face
} // namespace nfd
diff --git a/daemon/face/channel.hpp b/daemon/face/channel.hpp
index 1c0452d..300435c 100644
--- a/daemon/face/channel.hpp
+++ b/daemon/face/channel.hpp
@@ -29,6 +29,7 @@
#include "face.hpp"
namespace nfd {
+namespace face {
/**
* \brief Prototype for the callback that is invoked when the face
@@ -82,6 +83,7 @@
void
connectFaceClosedSignal(Face& face, const std::function<void()>& f);
+} // namespace face
} // namespace nfd
#endif // NFD_DAEMON_FACE_CHANNEL_HPP
diff --git a/daemon/face/ethernet-factory.cpp b/daemon/face/ethernet-factory.cpp
index fef7e96..cf0b34c 100644
--- a/daemon/face/ethernet-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -161,12 +161,12 @@
return found->second;
}
- face::GenericLinkService::Options opts;
+ GenericLinkService::Options opts;
opts.allowFragmentation = true;
opts.allowReassembly = true;
- auto linkService = make_unique<face::GenericLinkService>(opts);
- auto transport = make_unique<face::MulticastEthernetTransport>(netif, address, m_mcastConfig.linkType);
+ auto linkService = make_unique<GenericLinkService>(opts);
+ auto transport = make_unique<MulticastEthernetTransport>(netif, address, m_mcastConfig.linkType);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_mcastFaces[key] = face;
diff --git a/daemon/face/internal-transport.hpp b/daemon/face/internal-transport.hpp
index 78f62a2..6296110 100644
--- a/daemon/face/internal-transport.hpp
+++ b/daemon/face/internal-transport.hpp
@@ -50,7 +50,7 @@
/** \brief implements a forwarder-side transport that can be paired with another
*/
-class InternalForwarderTransport : public face::Transport, public InternalTransportBase
+class InternalForwarderTransport : public Transport, public InternalTransportBase
{
public:
InternalForwarderTransport(const FaceUri& localUri = FaceUri("internal://"),
diff --git a/daemon/face/tcp-channel.cpp b/daemon/face/tcp-channel.cpp
index 656b671..5f0f940 100644
--- a/daemon/face/tcp-channel.cpp
+++ b/daemon/face/tcp-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,6 +29,7 @@
#include "core/global-io.hpp"
namespace nfd {
+namespace face {
NFD_LOG_INIT("TcpChannel");
@@ -108,12 +109,12 @@
if (it == m_channelFaces.end()) {
auto persistency = isOnDemand ? ndn::nfd::FACE_PERSISTENCY_ON_DEMAND
: ndn::nfd::FACE_PERSISTENCY_PERSISTENT;
- auto linkService = make_unique<face::GenericLinkService>();
+ auto linkService = make_unique<GenericLinkService>();
auto options = linkService->getOptions();
options.allowLocalFields = wantLocalFieldsEnabled;
linkService->setOptions(options);
- auto transport = make_unique<face::TcpTransport>(std::move(socket), persistency);
+ auto transport = make_unique<TcpTransport>(std::move(socket), persistency);
face = make_shared<Face>(std::move(linkService), std::move(transport));
@@ -220,4 +221,5 @@
onConnectFailed(504, "Connect to remote endpoint timed out");
}
+} // namespace face
} // namespace nfd
diff --git a/daemon/face/tcp-channel.hpp b/daemon/face/tcp-channel.hpp
index 1b2fd93..9038f59 100644
--- a/daemon/face/tcp-channel.hpp
+++ b/daemon/face/tcp-channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,6 +35,8 @@
typedef boost::asio::ip::tcp::endpoint Endpoint;
} // namespace tcp
+namespace face {
+
/**
* \brief Class implementing TCP-based channel to create faces
*
@@ -129,6 +131,7 @@
return m_acceptor.is_open();
}
+} // namespace face
} // namespace nfd
#endif // NFD_DAEMON_FACE_TCP_CHANNEL_HPP
diff --git a/daemon/face/udp-channel.cpp b/daemon/face/udp-channel.cpp
index b89a8ad..491ad82 100644
--- a/daemon/face/udp-channel.cpp
+++ b/daemon/face/udp-channel.cpp
@@ -29,10 +29,11 @@
#include "core/global-io.hpp"
namespace nfd {
+namespace face {
NFD_LOG_INIT("UdpChannel");
-using namespace boost::asio;
+namespace ip = boost::asio::ip;
UdpChannel::UdpChannel(const udp::Endpoint& localEndpoint,
const time::seconds& timeout)
@@ -136,7 +137,7 @@
onFaceCreated(face);
// dispatch the datagram to the face for processing
- static_cast<face::UnicastUdpTransport*>(face->getTransport())->receiveDatagram(m_inputBuffer, nBytesReceived, error);
+ static_cast<UnicastUdpTransport*>(face->getTransport())->receiveDatagram(m_inputBuffer, nBytesReceived, error);
this->waitForNewPeer(onFaceCreated, onReceiveFailed);
}
@@ -156,8 +157,8 @@
socket.bind(m_localEndpoint);
socket.connect(remoteEndpoint);
- auto linkService = make_unique<face::GenericLinkService>();
- auto transport = make_unique<face::UnicastUdpTransport>(std::move(socket), persistency, m_idleFaceTimeout);
+ auto linkService = make_unique<GenericLinkService>();
+ auto transport = make_unique<UnicastUdpTransport>(std::move(socket), persistency, m_idleFaceTimeout);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[remoteEndpoint] = face;
@@ -170,4 +171,5 @@
return {true, face};
}
+} // namespace face
} // namespace nfd
diff --git a/daemon/face/udp-channel.hpp b/daemon/face/udp-channel.hpp
index e86e8e9..b9b71a8 100644
--- a/daemon/face/udp-channel.hpp
+++ b/daemon/face/udp-channel.hpp
@@ -30,6 +30,7 @@
#include "udp-protocol.hpp"
namespace nfd {
+namespace face {
/**
* \brief Class implementing UDP-based channel to create faces
@@ -133,6 +134,7 @@
return m_socket.is_open();
}
+} // namespace face
} // namespace nfd
#endif // NFD_DAEMON_FACE_UDP_CHANNEL_HPP
diff --git a/daemon/face/unix-stream-channel.cpp b/daemon/face/unix-stream-channel.cpp
index 85416fd..e09cd98 100644
--- a/daemon/face/unix-stream-channel.cpp
+++ b/daemon/face/unix-stream-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,6 +32,7 @@
#include <sys/stat.h> // for chmod()
namespace nfd {
+namespace face {
NFD_LOG_INIT("UnixStreamChannel");
@@ -132,8 +133,8 @@
NFD_LOG_DEBUG("[" << m_endpoint << "] Incoming connection");
- auto linkService = make_unique<face::GenericLinkService>();
- auto transport = make_unique<face::UnixStreamTransport>(std::move(m_socket));
+ auto linkService = make_unique<GenericLinkService>();
+ auto transport = make_unique<UnixStreamTransport>(std::move(m_socket));
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
onFaceCreated(face);
@@ -141,4 +142,5 @@
accept(onFaceCreated, onAcceptFailed);
}
+} // namespace face
} // namespace nfd
diff --git a/daemon/face/unix-stream-channel.hpp b/daemon/face/unix-stream-channel.hpp
index 8bd87d8..1916134 100644
--- a/daemon/face/unix-stream-channel.hpp
+++ b/daemon/face/unix-stream-channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -34,6 +34,8 @@
typedef boost::asio::local::stream_protocol::endpoint Endpoint;
} // namespace unix_stream
+namespace face {
+
/**
* \brief Class implementing a local channel to create faces
*
@@ -101,6 +103,7 @@
return m_acceptor.is_open();
}
+} // namespace face
} // namespace nfd
#endif // NFD_DAEMON_FACE_UNIX_STREAM_CHANNEL_HPP
diff --git a/daemon/face/websocket-channel.cpp b/daemon/face/websocket-channel.cpp
index 75626ab..cd0df70 100644
--- a/daemon/face/websocket-channel.cpp
+++ b/daemon/face/websocket-channel.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,6 +29,7 @@
#include "core/global-io.hpp"
namespace nfd {
+namespace face {
NFD_LOG_INIT("WebSocketChannel");
@@ -77,7 +78,7 @@
{
auto it = m_channelFaces.find(hdl);
if (it != m_channelFaces.end()) {
- static_cast<face::WebSocketTransport*>(it->second->getTransport())->handlePongTimeout();
+ static_cast<WebSocketTransport*>(it->second->getTransport())->handlePongTimeout();
}
else {
NFD_LOG_WARN("Pong timeout on unknown transport");
@@ -89,7 +90,7 @@
{
auto it = m_channelFaces.find(hdl);
if (it != m_channelFaces.end()) {
- static_cast<face::WebSocketTransport*>(it->second->getTransport())->handlePong();
+ static_cast<WebSocketTransport*>(it->second->getTransport())->handlePong();
}
else {
NFD_LOG_WARN("Pong received on unknown transport");
@@ -102,7 +103,7 @@
{
auto it = m_channelFaces.find(hdl);
if (it != m_channelFaces.end()) {
- static_cast<face::WebSocketTransport*>(it->second->getTransport())->receiveMessage(msg->get_payload());
+ static_cast<WebSocketTransport*>(it->second->getTransport())->receiveMessage(msg->get_payload());
}
else {
NFD_LOG_WARN("Message received on unknown transport");
@@ -112,8 +113,8 @@
void
WebSocketChannel::handleOpen(websocketpp::connection_hdl hdl)
{
- auto linkService = make_unique<face::GenericLinkService>();
- auto transport = make_unique<face::WebSocketTransport>(hdl, ref(m_server), m_pingInterval);
+ auto linkService = make_unique<GenericLinkService>();
+ auto transport = make_unique<WebSocketTransport>(hdl, ref(m_server), m_pingInterval);
auto face = make_shared<Face>(std::move(linkService), std::move(transport));
m_channelFaces[hdl] = face;
@@ -153,4 +154,5 @@
return m_channelFaces.size();
}
+} // namespace face
} // namespace nfd
diff --git a/daemon/face/websocket-channel.hpp b/daemon/face/websocket-channel.hpp
index 1d56731..99153f7 100644
--- a/daemon/face/websocket-channel.hpp
+++ b/daemon/face/websocket-channel.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -35,6 +35,8 @@
typedef boost::asio::ip::tcp::endpoint Endpoint;
} // namespace websocket
+namespace face {
+
/**
* \brief Class implementing WebSocket-based channel to create faces
*/
@@ -114,6 +116,7 @@
return m_server.is_listening();
}
+} // namespace face
} // namespace nfd
#endif // NFD_DAEMON_FACE_WEBSOCKET_CHANNEL_HPP