lsdb: rebuild using boost::multi_index to replace 3 LSA lists

refs: #4127

Co-authored-by: Nick Gordon <nmgordon@memphis.edu>

Change-Id: Ic179f90019e472157b0d61c6db02a4afaf4843b6
diff --git a/src/publisher/dataset-interest-handler.cpp b/src/publisher/dataset-interest-handler.cpp
index 24c6e1a..373b62b 100644
--- a/src/publisher/dataset-interest-handler.cpp
+++ b/src/publisher/dataset-interest-handler.cpp
@@ -50,44 +50,26 @@
 {
   dispatcher.addStatusDataset(ADJACENCIES_DATASET,
     ndn::mgmt::makeAcceptAllAuthorization(),
-    std::bind(&DatasetInterestHandler::publishAdjStatus, this, _1, _2, _3));
+    std::bind(&DatasetInterestHandler::publishLsaStatus<AdjLsa>, this, _1, _2, _3));
   dispatcher.addStatusDataset(COORDINATES_DATASET,
     ndn::mgmt::makeAcceptAllAuthorization(),
-    std::bind(&DatasetInterestHandler::publishCoordinateStatus, this, _1, _2, _3));
+    std::bind(&DatasetInterestHandler::publishLsaStatus<CoordinateLsa>, this, _1, _2, _3));
   dispatcher.addStatusDataset(NAMES_DATASET,
     ndn::mgmt::makeAcceptAllAuthorization(),
-    std::bind(&DatasetInterestHandler::publishNameStatus, this, _1, _2, _3));
+    std::bind(&DatasetInterestHandler::publishLsaStatus<NameLsa>, this, _1, _2, _3));
   dispatcher.addStatusDataset(RT_DATASET,
     ndn::mgmt::makeAcceptAllAuthorization(),
     std::bind(&DatasetInterestHandler::publishRtStatus, this, _1, _2, _3));
 }
 
+template <typename T>
 void
-DatasetInterestHandler::publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
+DatasetInterestHandler::publishLsaStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
                                          ndn::mgmt::StatusDatasetContext& context)
 {
-  for (const auto& adjLsa : m_lsdb.getAdjLsdb()) {
-    context.append(adjLsa.wireEncode());
-  }
-  context.end();
-}
-
-void
-DatasetInterestHandler::publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
-                                                ndn::mgmt::StatusDatasetContext& context)
-{
-  for (const auto& coordinateLsa : m_lsdb.getCoordinateLsdb()) {
-    context.append(coordinateLsa.wireEncode());
-  }
-  context.end();
-}
-
-void
-DatasetInterestHandler::publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
-                                          ndn::mgmt::StatusDatasetContext& context)
-{
-  for (const auto& nameLsa : m_lsdb.getNameLsdb()) {
-    context.append(nameLsa.wireEncode());
+  auto lsaRange = m_lsdb.getLsdbIterator<T>();
+  for (auto lsaIt = lsaRange.first; lsaIt != lsaRange.second; ++lsaIt) {
+    context.append((*lsaIt)->wireEncode());
   }
   context.end();
 }
diff --git a/src/publisher/dataset-interest-handler.hpp b/src/publisher/dataset-interest-handler.hpp
index b39ac25..cfd21c9 100644
--- a/src/publisher/dataset-interest-handler.hpp
+++ b/src/publisher/dataset-interest-handler.hpp
@@ -82,24 +82,13 @@
   publishRtStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
                   ndn::mgmt::StatusDatasetContext& context);
 
-  /*! \brief provide adjacent status dataset
+  /*! \brief provide LSA status dataset
    */
+  template <typename T>
   void
-  publishAdjStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
+  publishLsaStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
                    ndn::mgmt::StatusDatasetContext& context);
 
-  /*! \brief provide coordinate status dataset
-   */
-  void
-  publishCoordinateStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
-                          ndn::mgmt::StatusDatasetContext& context);
-
-  /*! \brief provide name status dataset
-   */
-  void
-  publishNameStatus(const ndn::Name& topPrefix, const ndn::Interest& interest,
-                    ndn::mgmt::StatusDatasetContext& context);
-
 private:
   ndn::mgmt::Dispatcher& m_dispatcher;
   const Lsdb& m_lsdb;