daemon: Replace shared_ptr with unique_ptr in Nfd
Change-Id: I97d39ddb793abfe4552002c94778b95e6b96f869
Refs: #2496
diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp
index 7ca271c..c4d312f 100644
--- a/daemon/nfd.cpp
+++ b/daemon/nfd.cpp
@@ -54,12 +54,19 @@
{
}
+Nfd::~Nfd()
+{
+ // It is necessary to explicitly define the destructor, because some member variables (e.g.,
+ // unique_ptr<Forwarder>) are forward-declared, but implicitly declared destructor requires
+ // complete types for all members when instantiated.
+}
+
void
Nfd::initialize()
{
initializeLogging();
- m_forwarder = make_shared<Forwarder>();
+ m_forwarder.reset(new Forwarder());
initializeManagement();
@@ -107,23 +114,16 @@
{
m_internalFace = make_shared<InternalFace>();
- m_fibManager = make_shared<FibManager>(ref(m_forwarder->getFib()),
- bind(&Forwarder::getFace, m_forwarder.get(), _1),
- m_internalFace,
- ndn::ref(m_keyChain));
+ m_fibManager.reset(new FibManager(m_forwarder->getFib(),
+ bind(&Forwarder::getFace, m_forwarder.get(), _1),
+ m_internalFace, m_keyChain));
- m_faceManager = make_shared<FaceManager>(ref(m_forwarder->getFaceTable()),
- m_internalFace,
- ndn::ref(m_keyChain));
+ m_faceManager.reset(new FaceManager(m_forwarder->getFaceTable(), m_internalFace, m_keyChain));
- m_strategyChoiceManager =
- make_shared<StrategyChoiceManager>(ref(m_forwarder->getStrategyChoice()),
- m_internalFace,
- ndn::ref(m_keyChain));
+ m_strategyChoiceManager.reset(new StrategyChoiceManager(m_forwarder->getStrategyChoice(),
+ m_internalFace, m_keyChain));
- m_statusServer = make_shared<StatusServer>(m_internalFace,
- ref(*m_forwarder),
- ndn::ref(m_keyChain));
+ m_statusServer.reset(new StatusServer(m_internalFace, *m_forwarder, m_keyChain));
ConfigFile config(&ignoreRibAndLogSections);
general::setConfigFile(config);
diff --git a/daemon/nfd.hpp b/daemon/nfd.hpp
index f9cac45..92e6efd 100644
--- a/daemon/nfd.hpp
+++ b/daemon/nfd.hpp
@@ -62,6 +62,11 @@
Nfd(const ConfigSection& config, ndn::KeyChain& keyChain);
/**
+ * \brief Destructor
+ */
+ ~Nfd();
+
+ /**
* \brief Perform initialization of NFD instance
* After initialization, NFD instance can be started by invoking run on globalIoService
*/
@@ -85,13 +90,13 @@
std::string m_configFile;
ConfigSection m_configSection;
- shared_ptr<Forwarder> m_forwarder;
+ unique_ptr<Forwarder> m_forwarder;
shared_ptr<InternalFace> m_internalFace;
- shared_ptr<FibManager> m_fibManager;
- shared_ptr<FaceManager> m_faceManager;
- shared_ptr<StrategyChoiceManager> m_strategyChoiceManager;
- shared_ptr<StatusServer> m_statusServer;
+ unique_ptr<FibManager> m_fibManager;
+ unique_ptr<FaceManager> m_faceManager;
+ unique_ptr<StrategyChoiceManager> m_strategyChoiceManager;
+ unique_ptr<StatusServer> m_statusServer;
ndn::KeyChain& m_keyChain;
};