face: Updating the way to select Controller
It is impossible to set Controller during construction of the face,
since all controllers implementation require face during construction.
Change-Id: Ib80f3f906d9849e4d89cfaccd6f957aac349c027
diff --git a/src/face.cpp b/src/face.cpp
index aa25e8d..25ce3ab 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -24,55 +24,42 @@
Face::Face()
{
construct(shared_ptr<Transport>(new UnixTransport()),
- make_shared<boost::asio::io_service>(),
- shared_ptr<Controller>());
-}
-
-Face::Face(const shared_ptr<Controller>& controller)
-{
- construct(shared_ptr<Transport>(new UnixTransport()),
- make_shared<boost::asio::io_service>(),
- controller);
+ make_shared<boost::asio::io_service>());
}
Face::Face(const shared_ptr<boost::asio::io_service>& ioService)
{
construct(shared_ptr<Transport>(new UnixTransport()),
- ioService,
- shared_ptr<Controller>());
+ ioService);
}
Face::Face(const std::string& host, const std::string& port/* = "6363"*/)
{
construct(shared_ptr<Transport>(new TcpTransport(host, port)),
- make_shared<boost::asio::io_service>(),
- shared_ptr<Controller>());
+ make_shared<boost::asio::io_service>());
}
Face::Face(const shared_ptr<Transport>& transport)
{
construct(transport,
- make_shared<boost::asio::io_service>(),
- shared_ptr<Controller>());
+ make_shared<boost::asio::io_service>());
}
Face::Face(const shared_ptr<Transport>& transport,
const shared_ptr<boost::asio::io_service>& ioService)
{
- construct(transport, ioService, shared_ptr<Controller>());
+ construct(transport, ioService);
}
-Face::Face(const shared_ptr<Transport>& transport,
- const shared_ptr<boost::asio::io_service>& ioService,
- const shared_ptr<Controller>& controller)
+void
+Face::setController(const shared_ptr<Controller>& controller)
{
- construct(transport, ioService, controller);
+ m_fwController = controller;
}
void
Face::construct(const shared_ptr<Transport>& transport,
- const shared_ptr<boost::asio::io_service>& ioService,
- const shared_ptr<Controller>& controller)
+ const shared_ptr<boost::asio::io_service>& ioService)
{
m_pitTimeoutCheckTimerActive = false;
m_transport = transport;
@@ -81,22 +68,15 @@
m_pitTimeoutCheckTimer = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
m_processEventsTimeoutTimer = make_shared<boost::asio::deadline_timer>(boost::ref(*m_ioService));
- if (static_cast<bool>(controller))
+ if (std::getenv("NFD") != 0)
{
- m_fwController = controller;
+ if (std::getenv("NRD") != 0)
+ m_fwController = make_shared<nrd::Controller>(boost::ref(*this));
+ else
+ m_fwController = make_shared<nfd::Controller>(boost::ref(*this));
}
else
- {
- if (std::getenv("NFD") != 0)
- {
- if (std::getenv("NRD") != 0)
- m_fwController = make_shared<nrd::Controller>(boost::ref(*this));
- else
- m_fwController = make_shared<nfd::Controller>(boost::ref(*this));
- }
- else
- m_fwController = make_shared<ndnd::Controller>(boost::ref(*this));
- }
+ m_fwController = make_shared<ndnd::Controller>(boost::ref(*this));
}
diff --git a/src/face.hpp b/src/face.hpp
index 895c39e..6a9a87c 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -61,14 +61,6 @@
Face();
/**
- * @brief Create face, explicitly selecting which controller to use
- *
- * Controller controls the way prefixes are registered with local forwarder.
- */
- explicit
- Face(const shared_ptr<Controller>& controller);
-
- /**
* @brief Create a new Face for communication with an NDN Forwarder using the default UnixTransport.
* @param ioService A shared pointer to boost::io_service object that should control all IO operations
*/
@@ -106,13 +98,10 @@
const shared_ptr<boost::asio::io_service>& ioService);
/**
- * @brief Create face, explicitly selecting which controller to use
- *
- * Controller controls the way prefixes are registered with local forwarder.
+ * @brief Set controller used for prefix registration
*/
- Face(const shared_ptr<Transport>& transport,
- const shared_ptr<boost::asio::io_service>& ioService,
- const shared_ptr<Controller>& controller);
+ void
+ setController(const shared_ptr<Controller>& controller);
/**
* @brief Express Interest
@@ -214,8 +203,7 @@
private:
void
construct(const shared_ptr<Transport>& transport,
- const shared_ptr<boost::asio::io_service>& ioService,
- const shared_ptr<Controller>& controller);
+ const shared_ptr<boost::asio::io_service>& ioService);
struct ProcessEventsTimeout {};
typedef std::list<shared_ptr<PendingInterest> > PendingInterestTable;