Follow ndn::Scheduler API changes
Switch from ndn::EventId to ndn::scheduler::EventId
and simplify some code.
Refs: #4883
Change-Id: Ifbd3b00da441ca0a277900265f8f6e31fdcebf2a
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 1da774b..5966108 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
@@ -49,7 +49,7 @@
Fib::remove(const ndn::Name& name)
{
NLSR_LOG_DEBUG("Fib::remove called");
- std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
+ auto it = m_table.find(name);
// Only unregister the prefix if it ISN'T a neighbor.
if (it != m_table.end() && isNotNeighbor((it->second).getName())) {
@@ -96,12 +96,11 @@
unsigned int nFaces = 0;
// Create a list of next hops to be installed with length == maxFaces
- for (NexthopList::iterator it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces;
- ++it, ++nFaces) {
+ for (auto it = allHops.cbegin(); it != allHops.cend() && nFaces < maxFaces; ++it, ++nFaces) {
hopsToAdd.addNextHop(*it);
}
- std::map<ndn::Name, FibEntry>::iterator entryIt = m_table.find(name);
+ auto entryIt = m_table.find(name);
// New FIB entry that has nextHops
if (entryIt == m_table.end() && hopsToAdd.size() != 0) {
@@ -236,7 +235,7 @@
NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getName() <<
" Face Uri: " << faceUri << " faceId: " << commandSuccessResult.getFaceId());
- AdjacencyList::iterator adjacent = m_adjacencyList.findAdjacent(faceUri);
+ auto adjacent = m_adjacencyList.findAdjacent(faceUri);
if (adjacent != m_adjacencyList.end()) {
adjacent->setFaceId(commandSuccessResult.getFaceId());
}
@@ -311,29 +310,24 @@
.setStrategy(strategy);
m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
- std::bind(&Fib::onSetStrategySuccess, this, _1,
- "Successfully set strategy choice"),
+ std::bind(&Fib::onSetStrategySuccess, this, _1),
std::bind(&Fib::onSetStrategyFailure, this, _1,
- parameters,
- count,
- "Failed to set strategy choice"));
+ parameters, count));
}
void
-Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
- const std::string& message)
+Fib::onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult)
{
- NLSR_LOG_DEBUG(message << ": " << commandSuccessResult.getStrategy() <<
+ NLSR_LOG_DEBUG("Successfully set strategy choice: " << commandSuccessResult.getStrategy() <<
" for name: " << commandSuccessResult.getName());
}
void
Fib::onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
const ndn::nfd::ControlParameters& parameters,
- uint32_t count,
- const std::string& message)
+ uint32_t count)
{
- NLSR_LOG_DEBUG(message << ": " << parameters.getStrategy() <<
+ NLSR_LOG_DEBUG("Failed to set strategy choice: " << parameters.getStrategy() <<
" for name: " << parameters.getName());
if (count < 3) {
setStrategy(parameters.getName(), parameters.getStrategy().toUri(), count + 1);
@@ -347,9 +341,9 @@
" Seq Num: " << entry.getSeqNo() <<
" in " << m_refreshTime << " seconds");
- entry.setRefreshEventId(m_scheduler.scheduleEvent(ndn::time::seconds(m_refreshTime),
- std::bind(&Fib::refreshEntry, this,
- entry.getName(), refreshCallback)));
+ entry.setRefreshEventId(m_scheduler.schedule(ndn::time::seconds(m_refreshTime),
+ std::bind(&Fib::refreshEntry, this,
+ entry.getName(), refreshCallback)));
}
void
@@ -362,16 +356,13 @@
Fib::cancelEntryRefresh(const FibEntry& entry)
{
NLSR_LOG_DEBUG("Canceling refresh for " << entry.getName() << " Seq Num: " << entry.getSeqNo());
-
- m_scheduler.cancelEvent(entry.getRefreshEventId());
- entry.getRefreshEventId().reset();
+ entry.getRefreshEventId().cancel();
}
void
Fib::refreshEntry(const ndn::Name& name, afterRefreshCallback refreshCb)
{
- std::map<ndn::Name, FibEntry>::iterator it = m_table.find(name);
-
+ auto it = m_table.find(name);
if (it == m_table.end()) {
return;
}