src: Change adjacency status from uint32_t to enum
refs: #1946
Change-Id: Ic1abd2610061860d0ac183074395a1d3796e870a
diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index f2e0aaf..5c98ed8 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -61,15 +61,18 @@
}
}
-int32_t
-AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, int32_t s)
+bool
+AdjacencyList::updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s)
{
std::list<Adjacent>::iterator it = find(adjName);
+
if (it == m_adjList.end()) {
- return -1;
+ return false;
}
- (*it).setStatus(s);
- return 0;
+ else {
+ it->setStatus(s);
+ return true;
+ }
}
Adjacent
@@ -163,22 +166,25 @@
return (*it).getInterestTimedOutNo();
}
-uint32_t
+Adjacent::Status
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
{
std::list<Adjacent>::iterator it = find(neighbor);
+
if (it == m_adjList.end()) {
- return -1;
+ return Adjacent::STATUS_UNKNOWN;
}
- return (*it).getStatus();
+ else {
+ return it->getStatus();
+ }
}
void
-AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, int32_t status)
+AdjacencyList::setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status)
{
std::list<Adjacent>::iterator it = find(neighbor);
if (it != m_adjList.end()) {
- (*it).setStatus(status);
+ it->setStatus(status);
}
}
@@ -192,9 +198,9 @@
AdjacencyList::isAdjLsaBuildable(Nlsr& pnlsr)
{
uint32_t nbrCount = 0;
- for (std::list<Adjacent>::iterator it = m_adjList.begin();
- it != m_adjList.end() ; it++) {
- if (((*it).getStatus() == 1)) {
+ for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end() ; it++) {
+
+ if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
nbrCount++;
}
else {
@@ -214,9 +220,9 @@
AdjacencyList::getNumOfActiveNeighbor()
{
int32_t actNbrCount = 0;
- for (std::list<Adjacent>::iterator it = m_adjList.begin();
- it != m_adjList.end(); it++) {
- if (((*it).getStatus() == 1)) {
+ for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
+
+ if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
actNbrCount++;
}
}