face: pass addFace and NetworkMonitor to ProtocolFactory constructor
refs #4021
Change-Id: I842515eb044bb1c655b347e6069e63c55c4e2d54
diff --git a/daemon/face/face-system.cpp b/daemon/face/face-system.cpp
index 7877ed0..57b391d 100644
--- a/daemon/face/face-system.cpp
+++ b/daemon/face/face-system.cpp
@@ -33,18 +33,24 @@
NFD_LOG_INIT("FaceSystem");
-FaceSystem::FaceSystem(FaceTable& faceTable, const shared_ptr<ndn::net::NetworkMonitor>& netmon)
+FaceSystem::FaceSystem(FaceTable& faceTable, shared_ptr<ndn::net::NetworkMonitor> netmon)
: m_faceTable(faceTable)
+ , m_netmon(std::move(netmon))
{
- BOOST_ASSERT(netmon != nullptr);
-
- auto addFace = bind(&FaceTable::add, &m_faceTable, _1);
+ auto pfCtorParams = this->makePFCtorParams();
for (const std::string& id : ProtocolFactory::listRegistered()) {
NFD_LOG_TRACE("creating factory " << id);
- m_factories[id] = ProtocolFactory::create(id, netmon, addFace);
+ m_factories[id] = ProtocolFactory::create(id, pfCtorParams);
}
}
+ProtocolFactoryCtorParams
+FaceSystem::makePFCtorParams()
+{
+ auto addFace = bind(&FaceTable::add, &m_faceTable, _1);
+ return {addFace, m_netmon};
+}
+
FaceSystem::FaceSystem(FaceTable& faceTable)
: FaceSystem(faceTable, make_shared<ndn::net::NetworkMonitor>(getGlobalIoService()))
{