src: Replace Tokenizer with the methods of ndn::Name

Purpose of this commit is to replace Tokenizer in all
places except conf-file-processor.*pp with the methods
of ndn::Name. One static method in class NameHelper
is added. Tokenizer will be removed finally when
configuration file parsing commit is complete.

Refs: 1533

Change-Id: I14a67655eb963c5cc5b045c3c9f7d516e405ff19
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1272ab1..fc823c1 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -14,32 +14,31 @@
 using namespace ndn;
 
 static bool
-fibEntryNameCompare(const FibEntry& fibEntry, const string& name)
+fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
 {
   return fibEntry.getName() == name ;
 }
 
 void
-Fib::cancelScheduledExpiringEvent(Nlsr& pnlsr, EventId eid)
+Fib::cancelScheduledExpiringEvent(EventId eid)
 {
-  pnlsr.getScheduler().cancelEvent(eid);
+  m_nlsr.getScheduler().cancelEvent(eid);
 }
 
 
 ndn::EventId
-Fib::scheduleEntryRefreshing(Nlsr& pnlsr, const string& name, int32_t feSeqNum,
+Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
                              int32_t refreshTime)
 {
   std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
-  return pnlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
-                                            ndn::bind(&Fib::refreshEntry, this,
-                                                      boost::ref(pnlsr), 
-                                                      name, feSeqNum));
+  return m_nlsr.getScheduler().scheduleEvent(ndn::time::seconds(refreshTime),
+                                             ndn::bind(&Fib::refreshEntry, this,
+                                                       name, feSeqNum));
 }
 
 void
-Fib::refreshEntry(Nlsr& nlsr, const string& name, int32_t feSeqNum)
+Fib::refreshEntry(const ndn::Name& name, int32_t feSeqNum)
 {
   std::cout << "Fib::refreshEntry Called" << std::endl;
   std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
@@ -53,26 +52,24 @@
     {
       std::cout << "Refreshing the FIB entry" << std::endl;
       for (std::list<NextHop>::iterator nhit =
-           (*it).getNexthopList().getNextHops().begin();
-         nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
+             (*it).getNexthopList().getNextHops().begin();
+           nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
       {
         // add entry to NDN-FIB
-        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(it->getName(), nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
-      
       // increase sequence number and schedule refresh again
       it->setSeqNo(feSeqNum + 1);
-      it->setExpiringEventId(scheduleEntryRefreshing(nlsr,
-                                                     it->getName() ,
-                                                     it->getSeqNo(), 
+      it->setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
+                                                     it->getSeqNo(),
                                                      m_refreshTime));
-      
     }
   }
 }
 
 void
-Fib::remove(Nlsr& pnlsr, const std::string& name)
+Fib::remove(const ndn::Name& name)
 {
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
@@ -84,14 +81,14 @@
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -99,19 +96,19 @@
     }
     std::cout << "Cancellling Scheduled event" << std::endl;
     std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     m_table.erase(it);
   }
 }
 
 
 void
-Fib::update(Nlsr& pnlsr, const string& name, NexthopList& nextHopList)
+Fib::update(const ndn::Name& name, NexthopList& nextHopList)
 {
   std::cout << "Fib::updateFib Called" << std::endl;
   int startFace = 0;
   int endFace = getNumberOfFacesForName(nextHopList,
-                                        pnlsr.getConfParameter().getMaxFacesPerPrefix());
+                                        m_nlsr.getConfParameter().getMaxFacesPerPrefix());
   std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
                                                   m_table.end(),
                                                   bind(&fibEntryNameCompare, _1, name));
@@ -127,13 +124,13 @@
       {
         newEntry.getNexthopList().addNextHop((*nhit));
         //Add entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
       }
       newEntry.getNexthopList().sort();
       newEntry.setTimeToRefresh(m_refreshTime);
       newEntry.setSeqNo(1);
-      newEntry.setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                          name , 1, m_refreshTime));
+      newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1, m_refreshTime));
       m_table.push_back(newEntry);
     }
   }
@@ -148,8 +145,9 @@
         std::list<NextHop> nhl = nextHopList.getNextHops();
         std::list<NextHop>::iterator nhit = nhl.begin();
         // Add first Entry to NDN-FIB
-        registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
-        removeHop(pnlsr, it->getNexthopList(), nhit->getConnectingFace(), name);
+        registerPrefixInNfd(name, nhit->getConnectingFace(),
+                            std::ceil(nhit->getRouteCost()));
+        removeHop(it->getNexthopList(), nhit->getConnectingFace(), name);
         it->getNexthopList().reset();
         it->getNexthopList().addNextHop((*nhit));
         ++startFace;
@@ -158,21 +156,21 @@
         {
           it->getNexthopList().addNextHop((*nhit));
           //Add Entry to NDN_FIB
-          registerPrefixInNfd(name, nhit->getConnectingFace(), std::ceil(nhit->getRouteCost()));
+          registerPrefixInNfd(name, nhit->getConnectingFace(),
+                              std::ceil(nhit->getRouteCost()));
         }
       }
       it->setTimeToRefresh(m_refreshTime);
       std::cout << "Cancellling Scheduled event" << std::endl;
       std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
-      cancelScheduledExpiringEvent(pnlsr, it->getExpiringEventId());
+      cancelScheduledExpiringEvent(it->getExpiringEventId());
       it->setSeqNo(it->getSeqNo() + 1);
-      (*it).setExpiringEventId(scheduleEntryRefreshing(pnlsr,
-                                                       it->getName() ,
+      (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
                                                        it->getSeqNo(), m_refreshTime));
     }
     else
     {
-      remove(pnlsr, name);
+      remove(name);
     }
   }
 }
@@ -180,27 +178,28 @@
 
 
 void
-Fib::clean(Nlsr& pnlsr)
+Fib::clean()
 {
   for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
        ++it)
   {
     std::cout << "Cancellling Scheduled event" << std::endl;
-    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() << std::endl;
-    cancelScheduledExpiringEvent(pnlsr, (*it).getExpiringEventId());
+    std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() <<
+              std::endl;
+    cancelScheduledExpiringEvent((*it).getExpiringEventId());
     for (std::list<NextHop>::iterator nhit =
            (*it).getNexthopList().getNextHops().begin();
          nhit != (*it).getNexthopList().getNextHops().end(); nhit++)
     {
       //Remove entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(it->getName()))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName()))
       {
         unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() != 
-           nhit->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFace() !=
+            nhit->getConnectingFace())
         {
           unregisterPrefixFromNfd(it->getName(), nhit->getConnectingFace());
         }
@@ -214,7 +213,8 @@
 }
 
 int
-Fib::getNumberOfFacesForName(NexthopList& nextHopList, uint32_t maxFacesPerPrefix)
+Fib::getNumberOfFacesForName(NexthopList& nextHopList,
+                             uint32_t maxFacesPerPrefix)
 {
   int endFace = 0;
   if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix))
@@ -229,8 +229,8 @@
 }
 
 void
-Fib::removeHop(Nlsr& pnlsr, NexthopList& nl, uint32_t doNotRemoveHopFaceId,
-               const std::string& name)
+Fib::removeHop(NexthopList& nl, uint32_t doNotRemoveHopFaceId,
+               const ndn::Name& name)
 {
   for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
        it != nl.getNextHops().end();   ++it)
@@ -238,14 +238,14 @@
     if (it->getConnectingFace() != doNotRemoveHopFaceId)
     {
       //Remove FIB Entry from NDN-FIB
-      if (!pnlsr.getAdjacencyList().isNeighbor(name))
+      if (!m_nlsr.getAdjacencyList().isNeighbor(name))
       {
         unregisterPrefixFromNfd(name, it->getConnectingFace());
       }
       else
       {
-        if(pnlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() != 
-           it->getConnectingFace())
+        if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFace() !=
+            it->getConnectingFace())
         {
           unregisterPrefixFromNfd(name, it->getConnectingFace());
         }
@@ -255,32 +255,31 @@
 }
 
 void
-Fib::registerPrefixInNfd(const std::string& namePrefix, uint64_t faceId, uint64_t faceCost)
+Fib::registerPrefixInNfd(const ndn::Name& namePrefix, uint64_t faceId,
+                         uint64_t faceCost)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setCost(faceCost)
-    .setFaceId(faceId)
-    .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime*1000))
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setCost(faceCost)
+  .setFaceId(faceId)
+  .setExpirationPeriod(ndn::time::milliseconds(m_refreshTime * 1000))
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
                                                    ndn::bind(&Fib::onSuccess, this, _1,
                                                              "Successful in name registration"),
                                                    ndn::bind(&Fib::onFailure, this, _1, _2,
                                                              "Failed in name registration"));
 }
-  
+
 void
-Fib::unregisterPrefixFromNfd(const std::string& namePrefix, uint64_t faceId)
+Fib::unregisterPrefixFromNfd(const ndn::Name& namePrefix, uint64_t faceId)
 {
   ndn::nfd::ControlParameters controlParameters;
   controlParameters
-    .setName(namePrefix)
-    .setFaceId(faceId)
-    .setOrigin(128);
-
+  .setName(namePrefix)
+  .setFaceId(faceId)
+  .setOrigin(128);
   m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
                                                      ndn::bind(&Fib::onSuccess, this, _1,
                                                                "Successful in unregistering name"),
@@ -289,13 +288,15 @@
 }
 
 void
-Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, const std::string& message)
+Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
+               const std::string& message)
 {
   std::cout << message << ": " << commandSuccessResult << std::endl;
 }
 
 void
-Fib::onFailure(uint32_t code, const std::string& error, const std::string& message)
+Fib::onFailure(uint32_t code, const std::string& error,
+               const std::string& message)
 {
   std::cout << message << ": " << error << " (code: " << code << ")";
 }