table: make name_tree::Node the sole owner of name_tree::Entry
This commit also improves name_tree::Entry test coverage.
refs #3687
Change-Id: I92375f29fbebab82c67da7dff2ea7a2952ba2cca
diff --git a/daemon/table/name-tree-entry.hpp b/daemon/table/name-tree-entry.hpp
index 576139c..d481a5e 100644
--- a/daemon/table/name-tree-entry.hpp
+++ b/daemon/table/name-tree-entry.hpp
@@ -26,7 +26,6 @@
#ifndef NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
#define NFD_DAEMON_TABLE_NAME_TREE_ENTRY_HPP
-#include "name-tree-hashtable.hpp"
#include "table/fib-entry.hpp"
#include "table/pit-entry.hpp"
#include "table/measurements-entry.hpp"
@@ -35,9 +34,11 @@
namespace nfd {
namespace name_tree {
+class Node;
+
/** \brief an entry in the name tree
*/
-class Entry : public enable_shared_from_this<Entry>, noncopyable
+class Entry : noncopyable
{
public:
Entry(const Name& prefix, Node* node);
@@ -151,6 +152,18 @@
void
setStrategyChoiceEntry(unique_ptr<strategy_choice::Entry> strategyChoiceEntry);
+ /** \return name tree entry on which a table entry is attached,
+ * or nullptr if the table entry is detached
+ * \note This function is for NameTree internal use. Other components
+ * should use NameTree::getEntry(tableEntry) instead.
+ */
+ template<typename ENTRY>
+ static Entry*
+ get(const ENTRY& tableEntry)
+ {
+ return tableEntry.m_nameTreeEntry;
+ }
+
private:
Name m_name;
Node* m_node;