face: pass addFace and NetworkMonitor to ProtocolFactory constructor
refs #4021
Change-Id: I842515eb044bb1c655b347e6069e63c55c4e2d54
diff --git a/daemon/face/protocol-factory.cpp b/daemon/face/protocol-factory.cpp
index 010190d..0a8a150 100644
--- a/daemon/face/protocol-factory.cpp
+++ b/daemon/face/protocol-factory.cpp
@@ -38,8 +38,7 @@
}
unique_ptr<ProtocolFactory>
-ProtocolFactory::create(const std::string& id, shared_ptr<ndn::net::NetworkMonitor> netmon,
- const FaceCreatedCallback& addFace)
+ProtocolFactory::create(const std::string& id, const CtorParams& params)
{
Registry& registry = getRegistry();
auto found = registry.find(id);
@@ -47,10 +46,7 @@
return nullptr;
}
- auto factory = found->second();
- factory->netmon = std::move(netmon);
- factory->addFace = addFace;
- return factory;
+ return found->second(params);
}
std::set<std::string>
@@ -62,5 +58,13 @@
return factoryIds;
}
+ProtocolFactory::ProtocolFactory(const CtorParams& params)
+ : addFace(params.addFace)
+ , netmon(params.netmon)
+{
+ BOOST_ASSERT(addFace != nullptr);
+ BOOST_ASSERT(netmon != nullptr);
+}
+
} // namespace face
} // namespace nfd