table: Allow iteration over PIT entries

Change-Id: If48d7f827ccb5df0480cfa27bd2f3db4e3f796fa
Refs: #2339
diff --git a/daemon/table/pit.cpp b/daemon/table/pit.cpp
index e4199e8..5e333aa 100644
--- a/daemon/table/pit.cpp
+++ b/daemon/table/pit.cpp
@@ -26,6 +26,10 @@
 #include "pit.hpp"
 #include <type_traits>
 
+#include <boost/concept/assert.hpp>
+#include <boost/concept_check.hpp>
+#include <type_traits>
+
 namespace nfd {
 namespace pit {
 
@@ -36,6 +40,17 @@
 
 } // namespace pit
 
+// http://en.cppreference.com/w/cpp/concept/ForwardIterator
+BOOST_CONCEPT_ASSERT((boost::ForwardIterator<Pit::const_iterator>));
+// boost::ForwardIterator follows SGI standard http://www.sgi.com/tech/stl/ForwardIterator.html,
+// which doesn't require DefaultConstructible
+#ifdef HAVE_IS_DEFAULT_CONSTRUCTIBLE
+static_assert(std::is_default_constructible<Pit::const_iterator>::value,
+              "Pit::const_iterator must be default-constructible");
+#else
+BOOST_CONCEPT_ASSERT((boost::DefaultConstructible<Pit::const_iterator>));
+#endif // HAVE_IS_DEFAULT_CONSTRUCTIBLE
+
 Pit::Pit(NameTree& nameTree)
   : m_nameTree(nameTree)
   , m_nItems(0)
@@ -101,4 +116,11 @@
   --m_nItems;
 }
 
+Pit::const_iterator
+Pit::begin() const
+{
+  return const_iterator(m_nameTree.fullEnumerate(
+    [] (const name_tree::Entry& entry) { return entry.hasPitEntries(); }).begin());
+}
+
 } // namespace nfd