src: Discard usage of std::pair of reference type and rename functions
Refs: #1531
Change-Id: Ief2a525b8fb8addbd491d202d6b02d5db2b41ea4
diff --git a/src/route/npt.cpp b/src/route/npt.cpp
index 665dbb2..e094fe3 100644
--- a/src/route/npt.cpp
+++ b/src/route/npt.cpp
@@ -83,11 +83,11 @@
void
Npt::addNpteByDestName(string name, string destRouter, Nlsr& pnlsr)
{
- std::pair<RoutingTableEntry&, bool> rteCheck =
+ RoutingTableEntry* rteCheck =
pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
- if (rteCheck.second)
+ if (rteCheck != 0)
{
- addNpte(name, rteCheck.first, pnlsr);
+ addNpte(name, *(rteCheck) , pnlsr);
}
else
{
@@ -99,11 +99,11 @@
void
Npt::removeNpte(string name, string destRouter, Nlsr& pnlsr)
{
- std::pair<RoutingTableEntry&, bool> rteCheck =
+ RoutingTableEntry* rteCheck =
pnlsr.getRoutingTable().findRoutingTableEntry(destRouter);
- if (rteCheck.second)
+ if (rteCheck != 0)
{
- removeNpte(name, rteCheck.first, pnlsr);
+ removeNpte(name, *(rteCheck), pnlsr);
}
else
{
@@ -122,11 +122,11 @@
for (std::list<RoutingTableEntry>::iterator rteit = rteList.begin();
rteit != rteList.end(); ++rteit)
{
- std::pair<RoutingTableEntry&, bool> rteCheck =
+ RoutingTableEntry* rteCheck =
pnlsr.getRoutingTable().findRoutingTableEntry((*rteit).getDestination());
- if (rteCheck.second)
+ if (rteCheck != 0)
{
- addNpte((*it).getNamePrefix(), rteCheck.first, pnlsr);
+ addNpte((*it).getNamePrefix(), *(rteCheck), pnlsr);
}
else
{
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index 6c6dad3..d63904e 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -448,13 +448,14 @@
double distance = 0.0;
string srcRouterKey = pMap.getRouterNameByMappingNo(src) + "/3";
string destRouterKey = pMap.getRouterNameByMappingNo(dest) + "/3";
- double srcRadius = (pnlsr.getLsdb().getCorLsa(
- srcRouterKey).first).getCorRadius();
- double srcTheta = (pnlsr.getLsdb().getCorLsa(srcRouterKey).first).getCorTheta();
- double destRadius = (pnlsr.getLsdb().getCorLsa(
- destRouterKey).first).getCorRadius();
- double destTheta = (pnlsr.getLsdb().getCorLsa(
- destRouterKey).first).getCorTheta();
+ double srcRadius = (pnlsr.getLsdb().findCoordinateLsa(
+ srcRouterKey))->getCorRadius();
+ double srcTheta = (pnlsr.getLsdb().findCoordinateLsa(
+ srcRouterKey))->getCorTheta();
+ double destRadius = (pnlsr.getLsdb().findCoordinateLsa(
+ destRouterKey))->getCorRadius();
+ double destTheta = (pnlsr.getLsdb().findCoordinateLsa(
+ destRouterKey))->getCorTheta();
double diffTheta = fabs(srcTheta - destTheta);
if (diffTheta > MATH_PI)
{
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 9e2c19c..097e95a 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -140,8 +140,8 @@
void
RoutingTable::addNextHop(string destRouter, NextHop& nh)
{
- std::pair<RoutingTableEntry&, bool> rte = findRoutingTableEntry(destRouter);
- if (!rte.second)
+ RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter);
+ if (rteChk == 0)
{
RoutingTableEntry rte(destRouter);
rte.getNhl().addNextHop(nh);
@@ -149,22 +149,21 @@
}
else
{
- (rte.first).getNhl().addNextHop(nh);
+ rteChk->getNhl().addNextHop(nh);
}
}
-std::pair<RoutingTableEntry&, bool>
-RoutingTable::findRoutingTableEntry(string destRouter)
+RoutingTableEntry*
+RoutingTable::findRoutingTableEntry(const string destRouter)
{
std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
m_rTable.end(),
bind(&routingTableEntryCompare, _1, destRouter));
if (it != m_rTable.end())
{
- return std::make_pair(boost::ref((*it)), true);
+ return &(*it);
}
- RoutingTableEntry rteEmpty;
- return std::make_pair(boost::ref(rteEmpty), false);
+ return 0;
}
void
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index cc04915..8518b12 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -34,8 +34,8 @@
void
printDryRoutingTable();
- std::pair<RoutingTableEntry&, bool>
- findRoutingTableEntry(std::string destRouter);
+ RoutingTableEntry*
+ findRoutingTableEntry(const std::string destRouter);
void
scheduleRoutingTableCalculation(Nlsr& pnlsr);