core: eliminate MapValueIterator in favor of boost::adaptors::map_values

refs #2239

Change-Id: Ifcc03513b1cbe580de12725baa4338f822a71417
diff --git a/daemon/fw/face-table.cpp b/daemon/fw/face-table.cpp
index a95c562..f1db53b 100644
--- a/daemon/fw/face-table.cpp
+++ b/daemon/fw/face-table.cpp
@@ -42,6 +42,19 @@
 
 }
 
+shared_ptr<Face>
+FaceTable::get(FaceId id) const
+{
+  std::map<FaceId, shared_ptr<Face> >::const_iterator i = m_faces.find(id);
+  return (i == m_faces.end()) ? (shared_ptr<Face>()) : (i->second);
+}
+
+size_t
+FaceTable::size() const
+{
+  return m_faces.size();
+}
+
 void
 FaceTable::add(shared_ptr<Face> face)
 {
@@ -104,6 +117,22 @@
   m_forwarder.getFib().removeNextHopFromAllEntries(face);
 }
 
+FaceTable::ForwardRange
+FaceTable::getForwardRange() const
+{
+  return m_faces | boost::adaptors::map_values;
+}
 
+FaceTable::const_iterator
+FaceTable::begin() const
+{
+  return this->getForwardRange().begin();
+}
+
+FaceTable::const_iterator
+FaceTable::end() const
+{
+  return this->getForwardRange().end();
+}
 
 } // namespace nfd
diff --git a/daemon/fw/face-table.hpp b/daemon/fw/face-table.hpp
index a255cfe..70ceb11 100644
--- a/daemon/fw/face-table.hpp
+++ b/daemon/fw/face-table.hpp
@@ -27,7 +27,7 @@
 #define NFD_DAEMON_FW_FACE_TABLE_HPP
 
 #include "face/face.hpp"
-#include "core/map-value-iterator.hpp"
+#include <boost/range/adaptor/map.hpp>
 
 namespace nfd
 {
@@ -59,15 +59,13 @@
   size() const;
 
 public: // enumeration
-  typedef std::map<FaceId, shared_ptr<Face> > FaceMap;
+  typedef std::map<FaceId, shared_ptr<Face>> FaceMap;
+
+  typedef boost::select_second_const_range<FaceMap> ForwardRange;
 
   /** \brief ForwardIterator for shared_ptr<Face>
    */
-  typedef MapValueIterator<FaceMap> const_iterator;
-
-  /** \brief ReverseIterator for shared_ptr<Face>
-   */
-  typedef MapValueReverseIterator<FaceMap> const_reverse_iterator;
+  typedef boost::range_iterator<ForwardRange>::type const_iterator;
 
   const_iterator
   begin() const;
@@ -75,12 +73,6 @@
   const_iterator
   end() const;
 
-  const_reverse_iterator
-  rbegin() const;
-
-  const_reverse_iterator
-  rend() const;
-
 public: // events
   /** \brief fires after a Face is added
    */
@@ -101,49 +93,15 @@
   void
   remove(shared_ptr<Face> face);
 
+  ForwardRange
+  getForwardRange() const;
+
 private:
   Forwarder& m_forwarder;
   FaceId m_lastFaceId;
   FaceMap m_faces;
 };
 
-inline shared_ptr<Face>
-FaceTable::get(FaceId id) const
-{
-  std::map<FaceId, shared_ptr<Face> >::const_iterator i = m_faces.find(id);
-  return (i == m_faces.end()) ? (shared_ptr<Face>()) : (i->second);
-}
-
-inline size_t
-FaceTable::size() const
-{
-  return m_faces.size();
-}
-
-inline FaceTable::const_iterator
-FaceTable::begin() const
-{
-  return const_iterator(m_faces.begin());
-}
-
-inline FaceTable::const_iterator
-FaceTable::end() const
-{
-  return const_iterator(m_faces.end());
-}
-
-inline FaceTable::const_reverse_iterator
-FaceTable::rbegin() const
-{
-  return const_reverse_iterator(m_faces.rbegin());
-}
-
-inline FaceTable::const_reverse_iterator
-FaceTable::rend() const
-{
-  return const_reverse_iterator(m_faces.rend());
-}
-
 } // namespace nfd
 
 #endif // NFD_DAEMON_FW_FACE_TABLE_HPP
diff --git a/daemon/mgmt/face-query-status-publisher.cpp b/daemon/mgmt/face-query-status-publisher.cpp
index 02fd4b6..d208087 100644
--- a/daemon/mgmt/face-query-status-publisher.cpp
+++ b/daemon/mgmt/face-query-status-publisher.cpp
@@ -25,6 +25,7 @@
 
 #include "face-query-status-publisher.hpp"
 #include "core/logger.hpp"
+#include <boost/range/adaptor/reversed.hpp>
 
 #include <ndn-cxx/management/nfd-face-status.hpp>
 
@@ -95,10 +96,7 @@
 {
   size_t totalLength = 0;
 
-  for (FaceTable::const_reverse_iterator i = m_faceTable.rbegin();
-       i != m_faceTable.rend(); ++i) {
-    const shared_ptr<Face>& face = *i;
-
+  for (const shared_ptr<Face>& face : m_faceTable | boost::adaptors::reversed) {
     if (doesMatchFilter(face)) {
       ndn::nfd::FaceStatus status = face->getFaceStatus();
       totalLength += status.wireEncode(outBuffer);
diff --git a/daemon/mgmt/face-status-publisher.cpp b/daemon/mgmt/face-status-publisher.cpp
index 04542c8..759f9ce 100644
--- a/daemon/mgmt/face-status-publisher.cpp
+++ b/daemon/mgmt/face-status-publisher.cpp
@@ -25,6 +25,7 @@
 #include "face-status-publisher.hpp"
 #include "core/logger.hpp"
 #include "fw/face-table.hpp"
+#include <boost/range/adaptor/reversed.hpp>
 
 #include <ndn-cxx/management/nfd-face-status.hpp>
 
@@ -54,9 +55,7 @@
 {
   size_t totalLength = 0;
 
-  for (FaceTable::const_reverse_iterator i = m_faceTable.rbegin();
-       i != m_faceTable.rend(); ++i) {
-    const shared_ptr<Face>& face = *i;
+  for (const shared_ptr<Face>& face : m_faceTable | boost::adaptors::reversed) {
     ndn::nfd::FaceStatus status = face->getFaceStatus();
     totalLength += status.wireEncode(outBuffer);
   }