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/tests/route/test-hyperbolic-calculator.cpp b/tests/route/test-hyperbolic-calculator.cpp
index a697e2e..30f8ced 100644
--- a/tests/route/test-hyperbolic-calculator.cpp
+++ b/tests/route/test-hyperbolic-calculator.cpp
@@ -64,11 +64,10 @@
     adjacencies.insert(c);
 
     AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencies);
-    lsdb.installAdjLsa(adjA);
-
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjA));
 
     CoordinateLsa coordA(adjA.getOriginRouter(), 1, MAX_TIME, 16.23, anglesA);
-    lsdb.installCoordinateLsa(coordA);
+    lsdb.installLsa(std::make_shared<CoordinateLsa>(coordA));
 
     // Router B
     a.setFaceId(1);
@@ -79,10 +78,10 @@
     adjacencyListB.insert(c);
 
     AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
-    lsdb.installAdjLsa(adjB);
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjB));
 
     CoordinateLsa coordB(adjB.getOriginRouter(), 1, MAX_TIME, 16.59, anglesB);
-    lsdb.installCoordinateLsa(coordB);
+    lsdb.installLsa(std::make_shared<CoordinateLsa>(coordB));
 
     // Router C
     a.setFaceId(1);
@@ -93,12 +92,13 @@
     adjacencyListC.insert(b);
 
     AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
-    lsdb.installAdjLsa(adjC);
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjC));
 
     CoordinateLsa coordC(adjC.getOriginRouter(), 1, MAX_TIME, 14.11, anglesC);
-    lsdb.installCoordinateLsa(coordC);
+    lsdb.installLsa(std::make_shared<CoordinateLsa>(coordC));
 
-    map.createFromAdjLsdb(lsdb.getAdjLsdb().begin(), lsdb.getAdjLsdb().end());
+    auto lsaRange = lsdb.getLsdbIterator<CoordinateLsa>();
+    map.createFromCoordinateLsdb(lsaRange.first, lsaRange.second);
   }
 
   void runTest(const double& expectedCost)
diff --git a/tests/route/test-link-state-calculator.cpp b/tests/route/test-link-state-calculator.cpp
index a0d04df..057b1c8 100644
--- a/tests/route/test-link-state-calculator.cpp
+++ b/tests/route/test-link-state-calculator.cpp
@@ -67,7 +67,7 @@
     adjacencyListA.insert(c);
 
     AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencyListA);
-    lsdb.installAdjLsa(adjA);
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjA));
 
     // Router B
     a.setLinkCost(LINK_AB_COST);
@@ -78,7 +78,7 @@
     adjacencyListB.insert(c);
 
     AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
-    lsdb.installAdjLsa(adjB);
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjB));
 
     // Router C
     a.setLinkCost(LINK_AC_COST);
@@ -89,9 +89,10 @@
     adjacencyListC.insert(b);
 
     AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
-    lsdb.installAdjLsa(adjC);
+    lsdb.installLsa(std::make_shared<AdjLsa>(adjC));
 
-    map.createFromAdjLsdb(lsdb.getAdjLsdb().begin(), lsdb.getAdjLsdb().end());
+    auto lsaRange = lsdb.getLsdbIterator<AdjLsa>();
+    map.createFromAdjLsdb(lsaRange.first, lsaRange.second);
   }
 
 public:
@@ -134,7 +135,7 @@
 BOOST_AUTO_TEST_CASE(Basic)
 {
   LinkStateRoutingTableCalculator calculator(map.getMapSize());
-  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+  calculator.calculatePath(map, routingTable, conf, lsdb);
 
   RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
   BOOST_REQUIRE(entryB != nullptr);
@@ -171,8 +172,7 @@
 BOOST_AUTO_TEST_CASE(Asymmetric)
 {
   // Asymmetric link cost between B and C
-  ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
-  AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
+  auto lsa = nlsr.m_lsdb.findLsa<AdjLsa>(ndn::Name(ROUTER_B_NAME));
   BOOST_REQUIRE(lsa != nullptr);
 
   auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
@@ -183,7 +183,7 @@
 
   // Calculation should consider the link between B and C as having cost = higherLinkCost
   LinkStateRoutingTableCalculator calculator(map.getMapSize());
-  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+  calculator.calculatePath(map, routingTable, conf, lsdb);
 
   RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
   BOOST_REQUIRE(entryB != nullptr);
@@ -220,8 +220,7 @@
 BOOST_AUTO_TEST_CASE(NonAdjacentCost)
 {
   // Asymmetric link cost between B and C
-  ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
-  auto lsa = nlsr.m_lsdb.findAdjLsa(key);
+  auto lsa = nlsr.m_lsdb.findLsa<AdjLsa>(ROUTER_B_NAME);
   BOOST_REQUIRE(lsa != nullptr);
 
   auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
@@ -232,7 +231,7 @@
 
   // Calculation should consider the link between B and C as down
   LinkStateRoutingTableCalculator calculator(map.getMapSize());
-  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+  calculator.calculatePath(map, routingTable, conf, lsdb);
 
   // Router A should be able to get to B through B but not through C
   RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
@@ -262,8 +261,7 @@
 BOOST_AUTO_TEST_CASE(AsymmetricZeroCostLink)
 {
   // Asymmetric and zero link cost between B - C, and B - A.
-  ndn::Name keyB = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
-  auto lsaB = nlsr.m_lsdb.findAdjLsa(keyB);
+  auto lsaB = nlsr.m_lsdb.findLsa<AdjLsa>(ROUTER_B_NAME);
   BOOST_REQUIRE(lsaB != nullptr);
 
   auto c = lsaB->m_adl.findAdjacent(ROUTER_C_NAME);
@@ -275,8 +273,7 @@
   auto a = lsaB->m_adl.findAdjacent(ROUTER_A_NAME);
   BOOST_REQUIRE(a != conf.getAdjacencyList().end());
 
-  ndn::Name keyA = ndn::Name(ROUTER_A_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
-  auto lsaA = nlsr.m_lsdb.findAdjLsa(keyA);
+  auto lsaA = nlsr.m_lsdb.findLsa<AdjLsa>(ROUTER_A_NAME);
   BOOST_REQUIRE(lsaA != nullptr);
 
   auto b = lsaA->m_adl.findAdjacent(ROUTER_B_NAME);
@@ -288,7 +285,7 @@
 
   // Calculation should consider 0 link-cost between B and C
   LinkStateRoutingTableCalculator calculator(map.getMapSize());
-  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+  calculator.calculatePath(map, routingTable, conf, lsdb);
 
   // Router A should be able to get to B through B and C
   RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
diff --git a/tests/route/test-name-prefix-table.cpp b/tests/route/test-name-prefix-table.cpp
index 213ba04..d603d91 100644
--- a/tests/route/test-name-prefix-table.cpp
+++ b/tests/route/test-name-prefix-table.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #include "route/name-prefix-table.hpp"
 #include "nlsr.hpp"
@@ -69,11 +69,11 @@
   // This router's Adjacency LSA
   conf.getAdjacencyList().insert(bupt);
   AdjLsa thisRouterAdjLsa(thisRouter.getName(), 1,
-                          ndn::time::system_clock::now() + ndn::time::seconds::max(),
+                          ndn::time::system_clock::now() + 3600_s,
                           2,
                           conf.getAdjacencyList());
 
-  lsdb.installAdjLsa(thisRouterAdjLsa);
+  lsdb.installLsa(std::make_shared<AdjLsa>(thisRouterAdjLsa));
 
   // BUPT Adjacency LSA
   AdjacencyList buptAdjacencies;
@@ -82,17 +82,17 @@
                     ndn::time::system_clock::now() + ndn::time::seconds(5),
                     0 , buptAdjacencies);
 
-  lsdb.installAdjLsa(buptAdjLsa);
+  lsdb.installLsa(std::make_shared<AdjLsa>(buptAdjLsa));
 
   // BUPT Name LSA
   ndn::Name buptAdvertisedName("/ndn/cn/edu/bupt");
 
   NamePrefixList buptNames{buptAdvertisedName};
 
-  NameLsa buptNameLsa(buptRouterName, 1, ndn::time::system_clock::now(),
+  NameLsa buptNameLsa(buptRouterName, 1, ndn::time::system_clock::now() + ndn::time::seconds(5),
                       buptNames);
 
-  lsdb.installNameLsa(buptNameLsa);
+  lsdb.installLsa(std::make_shared<NameLsa>(buptNameLsa));
 
   // Advance clocks to expire LSAs
   this->advanceClocks(ndn::time::seconds(15));
@@ -106,7 +106,7 @@
                          ndn::time::system_clock::now() + ndn::time::seconds(3600),
                          buptNames);
 
-  lsdb.installNameLsa(buptNewNameLsa);
+  lsdb.installLsa(std::make_shared<NameLsa>(buptNewNameLsa));
 
   this->advanceClocks(ndn::time::seconds(1));
 
@@ -114,7 +114,7 @@
   AdjLsa buptNewAdjLsa(buptRouterName, 12,
                        ndn::time::system_clock::now() + ndn::time::seconds(3600),
                        0, buptAdjacencies);
-  lsdb.installAdjLsa(buptNewAdjLsa);
+  lsdb.installLsa(std::make_shared<AdjLsa>(buptNewAdjLsa));
 
   this->advanceClocks(ndn::time::seconds(1));