Browse Source

src: improve constness

Change-Id: I8b3084e311642578628ea7c1017dc2a58979ab83
refs: #4472
pull/14/head
Nick Gordon 8 years ago
parent
commit
4964870e9d
  1. 29
      src/adjacency-list.cpp
  2. 15
      src/adjacency-list.hpp
  3. 8
      src/adjacent.hpp
  4. 18
      src/nlsr.hpp

29
src/adjacency-list.cpp

@ -85,7 +85,7 @@ AdjacencyList::getAdjacent(const ndn::Name& adjName)
}
bool
AdjacencyList::operator==(AdjacencyList& adl) const
AdjacencyList::operator==(const AdjacencyList& adl) const
{
if (size() != adl.size()) {
return false;
@ -127,9 +127,9 @@ AdjacencyList::updateAdjacentLinkCost(const ndn::Name& adjName, double lc)
}
bool
AdjacencyList::isNeighbor(const ndn::Name& adjName)
AdjacencyList::isNeighbor(const ndn::Name& adjName) const
{
std::list<Adjacent>::iterator it = find(adjName);
std::list<Adjacent>::const_iterator it = find(adjName);
if (it == m_adjList.end())
{
return false;
@ -158,9 +158,9 @@ AdjacencyList::setTimedOutInterestCount(const ndn::Name& neighbor,
}
int32_t
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return -1;
}
@ -168,9 +168,9 @@ AdjacencyList::getTimedOutInterestCount(const ndn::Name& neighbor)
}
Adjacent::Status
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor)
AdjacencyList::getStatusOfNeighbor(const ndn::Name& neighbor) const
{
std::list<Adjacent>::iterator it = find(neighbor);
std::list<Adjacent>::const_iterator it = find(neighbor);
if (it == m_adjList.end()) {
return Adjacent::STATUS_UNKNOWN;
@ -225,10 +225,10 @@ AdjacencyList::isAdjLsaBuildable(const uint32_t interestRetryNo) const
}
int32_t
AdjacencyList::getNumOfActiveNeighbor()
AdjacencyList::getNumOfActiveNeighbor() const
{
int32_t actNbrCount = 0;
for (std::list<Adjacent>::iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
for (std::list<Adjacent>::const_iterator it = m_adjList.begin(); it != m_adjList.end(); it++) {
if (it->getStatus() == Adjacent::STATUS_ACTIVE) {
actNbrCount++;
@ -247,6 +247,17 @@ AdjacencyList::find(const ndn::Name& adjName)
return it;
}
std::list<Adjacent>::const_iterator
AdjacencyList::find(const ndn::Name& adjName) const
{
std::list<Adjacent>::const_iterator it = std::find_if(m_adjList.cbegin(),
m_adjList.cend(),
std::bind(&Adjacent::compare,
_1, std::cref(adjName)));
return it;
}
AdjacencyList::iterator
AdjacencyList::findAdjacent(const ndn::Name& adjName)
{

15
src/adjacency-list.hpp

@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, The University of Memphis,
* Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@ -74,16 +74,16 @@ public:
getAdjList() const;
bool
isNeighbor(const ndn::Name& adjName);
isNeighbor(const ndn::Name& adjName) const;
void
incrementTimedOutInterestCount(const ndn::Name& neighbor);
int32_t
getTimedOutInterestCount(const ndn::Name& neighbor);
getTimedOutInterestCount(const ndn::Name& neighbor) const;
Adjacent::Status
getStatusOfNeighbor(const ndn::Name& neighbor);
getStatusOfNeighbor(const ndn::Name& neighbor) const;
void
setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
@ -120,13 +120,13 @@ public:
isAdjLsaBuildable(const uint32_t interestRetryNo) const;
int32_t
getNumOfActiveNeighbor();
getNumOfActiveNeighbor() const;
Adjacent
getAdjacent(const ndn::Name& adjName);
bool
operator==(AdjacencyList& adl) const;
operator==(const AdjacencyList& adl) const;
size_t
size() const
@ -187,6 +187,9 @@ private:
iterator
find(const ndn::Name& adjName);
const_iterator
find(const ndn::Name& adjName) const;
private:
std::list<Adjacent> m_adjList;
};

8
src/adjacent.hpp

@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, The University of Memphis,
* Copyright (c) 2014-2018, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@ -140,19 +140,19 @@ public:
operator<(const Adjacent& adjacent) const;
inline bool
compare(const ndn::Name& adjacencyName)
compare(const ndn::Name& adjacencyName) const
{
return m_name == adjacencyName;
}
inline bool
compareFaceId(const uint64_t faceId)
compareFaceId(const uint64_t faceId) const
{
return m_faceId == faceId;
}
inline bool
compareFaceUri(const ndn::FaceUri& faceUri)
compareFaceUri(const ndn::FaceUri& faceUri) const
{
return m_faceUri == faceUri;
}

18
src/nlsr.hpp

@ -123,18 +123,36 @@ public:
return m_confParam;
}
const ConfParameter&
getConfParameter() const
{
return m_confParam;
}
AdjacencyList&
getAdjacencyList()
{
return m_adjacencyList;
}
const AdjacencyList&
getAdjacencyList() const
{
return m_adjacencyList;
}
NamePrefixList&
getNamePrefixList()
{
return m_namePrefixList;
}
const NamePrefixList&
getNamePrefixList() const
{
return m_namePrefixList;
}
ndn::Face&
getNlsrFace()
{

Loading…
Cancel
Save