face: Rename all ChannelFactories to protocol Factories
Base class is ProtocolFactory and implementations are TcpFactory,
UnixStreamFactory, EthernetFactory.
Since Factories are doing more than just creating channels (some can
create faces directly), more general name is more appropriate.
Change-Id: I3d6c2460a1b29e244f8462453720f4e7785893ca
diff --git a/daemon/face/ethernet-channel-factory.cpp b/daemon/face/ethernet-factory.cpp
similarity index 80%
rename from daemon/face/ethernet-channel-factory.cpp
rename to daemon/face/ethernet-factory.cpp
index 86ad1a5..c8dbcf9 100644
--- a/daemon/face/ethernet-channel-factory.cpp
+++ b/daemon/face/ethernet-factory.cpp
@@ -4,7 +4,7 @@
* See COPYING for copyright and distribution information.
*/
-#include "ethernet-channel-factory.hpp"
+#include "ethernet-factory.hpp"
#include "core/global-io.hpp"
#include <boost/algorithm/string/predicate.hpp>
@@ -12,11 +12,11 @@
namespace nfd {
-NFD_LOG_INIT("EthernetChannelFactory")
+NFD_LOG_INIT("EthernetFactory")
shared_ptr<EthernetFace>
-EthernetChannelFactory::createMulticast(const ethernet::Endpoint& interface,
- const ethernet::Address& address)
+EthernetFactory::createMulticast(const ethernet::Endpoint& interface,
+ const ethernet::Address& address)
{
std::vector<ethernet::Endpoint> ifs = findAllInterfaces();
if (std::find(ifs.begin(), ifs.end(), interface) == ifs.end())
@@ -35,7 +35,7 @@
face = make_shared<EthernetFace>(boost::cref(socket),
boost::cref(interface),
boost::cref(address));
- face->onFail += bind(&EthernetChannelFactory::afterFaceFailed,
+ face->onFail += bind(&EthernetFactory::afterFaceFailed,
this, interface, address);
m_multicastFaces[std::make_pair(interface, address)] = face;
@@ -43,7 +43,7 @@
}
std::vector<ethernet::Endpoint>
-EthernetChannelFactory::findAllInterfaces()
+EthernetFactory::findAllInterfaces()
{
std::vector<ethernet::Endpoint> interfaces;
char errbuf[PCAP_ERRBUF_SIZE];
@@ -84,16 +84,16 @@
}
void
-EthernetChannelFactory::afterFaceFailed(const ethernet::Endpoint& interface,
- const ethernet::Address& address)
+EthernetFactory::afterFaceFailed(const ethernet::Endpoint& interface,
+ const ethernet::Address& address)
{
NFD_LOG_DEBUG("afterFaceFailed: " << interface << "/" << address);
m_multicastFaces.erase(std::make_pair(interface, address));
}
shared_ptr<EthernetFace>
-EthernetChannelFactory::findMulticast(const ethernet::Endpoint& interface,
- const ethernet::Address& address) const
+EthernetFactory::findMulticast(const ethernet::Endpoint& interface,
+ const ethernet::Address& address) const
{
MulticastFacesMap::const_iterator i = m_multicastFaces.find(std::make_pair(interface, address));
if (i != m_multicastFaces.end())
diff --git a/daemon/face/ethernet-channel-factory.hpp b/daemon/face/ethernet-factory.hpp
similarity index 80%
rename from daemon/face/ethernet-channel-factory.hpp
rename to daemon/face/ethernet-factory.hpp
index a9094af..d676f47 100644
--- a/daemon/face/ethernet-channel-factory.hpp
+++ b/daemon/face/ethernet-factory.hpp
@@ -4,23 +4,23 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
-#define NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
+#ifndef NFD_FACE_ETHERNET_FACTORY_HPP
+#define NFD_FACE_ETHERNET_FACTORY_HPP
#include "ethernet-face.hpp"
-#include "channel-factory.hpp"
+#include "protocol-factory.hpp"
namespace nfd {
-class EthernetChannelFactory : public ChannelFactory
+class EthernetFactory : public ProtocolFactory
{
public:
/**
- * \brief Exception of EthernetChannelFactory
+ * \brief Exception of EthernetFactory
*/
- struct Error : public ChannelFactory::Error
+ struct Error : public ProtocolFactory::Error
{
- Error(const std::string& what) : ChannelFactory::Error(what) {}
+ Error(const std::string& what) : ProtocolFactory::Error(what) {}
};
/**
@@ -36,7 +36,7 @@
* \returns always a valid shared pointer to an EthernetFace object,
* an exception will be thrown if the creation fails
*
- * \throws EthernetChannelFactory::Error or EthernetFace::Error
+ * \throws EthernetFactory::Error or EthernetFace::Error
*/
shared_ptr<EthernetFace>
createMulticast(const ethernet::Endpoint& interface,
@@ -75,4 +75,4 @@
} // namespace nfd
-#endif // NFD_FACE_ETHERNET_CHANNEL_FACTORY_HPP
+#endif // NFD_FACE_ETHERNET_FACTORY_HPP
diff --git a/daemon/face/channel-factory.hpp b/daemon/face/protocol-factory.hpp
similarity index 76%
rename from daemon/face/channel-factory.hpp
rename to daemon/face/protocol-factory.hpp
index 566063b..f02941e 100644
--- a/daemon/face/channel-factory.hpp
+++ b/daemon/face/protocol-factory.hpp
@@ -4,14 +4,14 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NFD_FACE_CHANNEL_FACTORY_HPP
-#define NFD_FACE_CHANNEL_FACTORY_HPP
+#ifndef NFD_FACE_PROTOCOL_FACTORY_HPP
+#define NFD_FACE_PROTOCOL_FACTORY_HPP
#include "common.hpp"
namespace nfd {
-class ChannelFactory
+class ProtocolFactory
{
public:
/**
@@ -21,9 +21,8 @@
{
Error(const std::string& what) : std::runtime_error(what) {}
};
-
};
} // namespace nfd
-#endif // NFD_FACE_CHANNEL_FACTORY_HPP
+#endif // NFD_FACE_PROTOCOL_FACTORY_HPP
diff --git a/daemon/face/tcp-channel-factory.cpp b/daemon/face/tcp-factory.cpp
similarity index 81%
rename from daemon/face/tcp-channel-factory.cpp
rename to daemon/face/tcp-factory.cpp
index 3a75183..072ce2e 100644
--- a/daemon/face/tcp-channel-factory.cpp
+++ b/daemon/face/tcp-factory.cpp
@@ -4,13 +4,13 @@
* See COPYING for copyright and distribution information.
*/
-#include "tcp-channel-factory.hpp"
+#include "tcp-factory.hpp"
#include "core/global-io.hpp"
namespace nfd {
shared_ptr<TcpChannel>
-TcpChannelFactory::create(const tcp::Endpoint& endpoint)
+TcpFactory::create(const tcp::Endpoint& endpoint)
{
shared_ptr<TcpChannel> channel = find(endpoint);
if(static_cast<bool>(channel))
@@ -22,7 +22,7 @@
}
shared_ptr<TcpChannel>
-TcpChannelFactory::create(const std::string& localHost, const std::string& localPort)
+TcpFactory::create(const std::string& localHost, const std::string& localPort)
{
using boost::asio::ip::tcp;
@@ -38,7 +38,7 @@
}
shared_ptr<TcpChannel>
-TcpChannelFactory::find(const tcp::Endpoint& localEndpoint)
+TcpFactory::find(const tcp::Endpoint& localEndpoint)
{
ChannelMap::iterator i = m_channels.find(localEndpoint);
if (i != m_channels.end())
diff --git a/daemon/face/tcp-channel-factory.hpp b/daemon/face/tcp-factory.hpp
similarity index 77%
rename from daemon/face/tcp-channel-factory.hpp
rename to daemon/face/tcp-factory.hpp
index c87cdf4..fbda795 100644
--- a/daemon/face/tcp-channel-factory.hpp
+++ b/daemon/face/tcp-factory.hpp
@@ -4,23 +4,23 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NFD_FACE_TCP_CHANNEL_FACTORY_HPP
-#define NFD_FACE_TCP_CHANNEL_FACTORY_HPP
+#ifndef NFD_FACE_TCP_FACTORY_HPP
+#define NFD_FACE_TCP_FACTORY_HPP
-#include "channel-factory.hpp"
+#include "protocol-factory.hpp"
#include "tcp-channel.hpp"
namespace nfd {
-class TcpChannelFactory : public ChannelFactory
+class TcpFactory : public ProtocolFactory
{
public:
/**
- * \brief Exception of TcpChannelFactory
+ * \brief Exception of TcpFactory
*/
- struct Error : public ChannelFactory::Error
+ struct Error : public ProtocolFactory::Error
{
- Error(const std::string& what) : ChannelFactory::Error(what) {}
+ Error(const std::string& what) : ProtocolFactory::Error(what) {}
};
/**
@@ -35,7 +35,7 @@
* \returns always a valid pointer to a TcpChannel object, an exception
* is thrown if it cannot be created.
*
- * \throws TcpChannelFactory::Error
+ * \throws TcpFactory::Error
*
* \see http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/ip__tcp/endpoint.html
* for details on ways to create tcp::Endpoint
@@ -47,11 +47,11 @@
* \brief Create TCP-based channel using specified host and port number
*
* This method will attempt to resolve the provided host and port numbers
- * and will throw TcpChannelFactory::Error when channel cannot be created.
+ * and will throw TcpFactory::Error when channel cannot be created.
*
* Note that this call will **BLOCK** until resolution is done or failed.
*
- * \throws TcpChannelFactory::Error
+ * \throws TcpFactory::Error
*/
shared_ptr<TcpChannel>
create(const std::string& localHost, const std::string& localPort);
@@ -75,4 +75,4 @@
} // namespace nfd
-#endif // NFD_FACE_TCP_CHANNEL_FACTORY_HPP
+#endif // NFD_FACE_TCP_FACTORY_HPP
diff --git a/daemon/face/unix-stream-channel-factory.cpp b/daemon/face/unix-stream-factory.cpp
similarity index 80%
rename from daemon/face/unix-stream-channel-factory.cpp
rename to daemon/face/unix-stream-factory.cpp
index 040c1e2..070d8c1 100644
--- a/daemon/face/unix-stream-channel-factory.cpp
+++ b/daemon/face/unix-stream-factory.cpp
@@ -4,19 +4,15 @@
* See COPYING for copyright and distribution information.
*/
-#include "unix-stream-channel-factory.hpp"
+#include "unix-stream-factory.hpp"
#include "core/global-io.hpp"
#include <boost/filesystem.hpp> // for canonical()
namespace nfd {
-UnixStreamChannelFactory::UnixStreamChannelFactory()
-{
-}
-
shared_ptr<UnixStreamChannel>
-UnixStreamChannelFactory::create(const std::string& unixSocketPath)
+UnixStreamFactory::create(const std::string& unixSocketPath)
{
boost::filesystem::path p(unixSocketPath);
p = boost::filesystem::canonical(p.parent_path()) / p.filename();
@@ -33,7 +29,7 @@
}
shared_ptr<UnixStreamChannel>
-UnixStreamChannelFactory::find(const unix_stream::Endpoint& endpoint)
+UnixStreamFactory::find(const unix_stream::Endpoint& endpoint)
{
ChannelMap::iterator i = m_channels.find(endpoint);
if (i != m_channels.end())
diff --git a/daemon/face/unix-stream-channel-factory.hpp b/daemon/face/unix-stream-factory.hpp
similarity index 71%
rename from daemon/face/unix-stream-channel-factory.hpp
rename to daemon/face/unix-stream-factory.hpp
index bf14117..4b26a3f 100644
--- a/daemon/face/unix-stream-channel-factory.hpp
+++ b/daemon/face/unix-stream-factory.hpp
@@ -4,28 +4,25 @@
* See COPYING for copyright and distribution information.
*/
-#ifndef NFD_FACE_UNIX_STREAM_CHANNEL_FACTORY_HPP
-#define NFD_FACE_UNIX_STREAM_CHANNEL_FACTORY_HPP
+#ifndef NFD_FACE_UNIX_STREAM_FACTORY_HPP
+#define NFD_FACE_UNIX_STREAM_FACTORY_HPP
-#include "channel-factory.hpp"
+#include "protocol-factory.hpp"
#include "unix-stream-channel.hpp"
namespace nfd {
-class UnixStreamChannelFactory : public ChannelFactory
+class UnixStreamFactory : public ProtocolFactory
{
public:
/**
- * \brief Exception of UnixStreamChannelFactory
+ * \brief Exception of UnixStreamFactory
*/
- struct Error : public ChannelFactory::Error
+ struct Error : public ProtocolFactory::Error
{
- Error(const std::string& what) : ChannelFactory::Error(what) {}
+ Error(const std::string& what) : ProtocolFactory::Error(what) {}
};
- explicit
- UnixStreamChannelFactory();
-
/**
* \brief Create stream-oriented Unix channel using specified socket path
*
@@ -36,7 +33,7 @@
* \returns always a valid pointer to a UnixStreamChannel object,
* an exception will be thrown if the channel cannot be created.
*
- * \throws UnixStreamChannelFactory::Error
+ * \throws UnixStreamFactory::Error
*/
shared_ptr<UnixStreamChannel>
create(const std::string& unixSocketPath);
@@ -60,4 +57,4 @@
} // namespace nfd
-#endif // NFD_FACE_UNIX_STREAM_CHANNEL_FACTORY_HPP
+#endif // NFD_FACE_UNIX_STREAM_FACTORY_HPP