table: simplify FIB iterator with Boost.Range

refs #3738

Change-Id: I0bfe985c9dac86a67988f77a89f4d2694c4fd9f5
diff --git a/daemon/table/name-tree-entry.hpp b/daemon/table/name-tree-entry.hpp
index b36aae9..ab385da 100644
--- a/daemon/table/name-tree-entry.hpp
+++ b/daemon/table/name-tree-entry.hpp
@@ -178,6 +178,33 @@
   friend Node* getNode(const Entry& entry);
 };
 
+/** \brief a functor to get a table entry from a name tree entry
+ *  \tparam ENTRY type of single table entry attached to name tree entry, such as fib::Entry
+ */
+template<typename ENTRY>
+class GetTableEntry
+{
+public:
+  /** \brief a function pointer to the getter on Entry class that returns ENTRY
+   */
+  using Getter = ENTRY* (Entry::*)() const;
+
+  explicit
+  GetTableEntry(Getter getter)
+    : m_getter(getter)
+  {
+  }
+
+  const ENTRY&
+  operator()(const Entry& nte) const
+  {
+    return *(nte.*m_getter)();
+  }
+
+private:
+  Getter m_getter;
+};
+
 } // namespace name_tree
 } // namespace nfd