adjacency-list.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2021, The University of Memphis,
4  * Regents of the University of California,
5  * Arizona Board of Regents.
6  *
7  * This file is part of NLSR (Named-data Link State Routing).
8  * See AUTHORS.md for complete list of NLSR authors and contributors.
9  *
10  * NLSR is free software: you can redistribute it and/or modify it under the terms
11  * of the GNU General Public License as published by the Free Software Foundation,
12  * either version 3 of the License, or (at your option) any later version.
13  *
14  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along with
19  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20  **/
21 
22 #ifndef NLSR_ADJACENCY_LIST_HPP
23 #define NLSR_ADJACENCY_LIST_HPP
24 
25 #include "adjacent.hpp"
26 #include "common.hpp"
27 
28 #include <list>
29 
30 namespace nlsr {
31 
33 {
34 public:
35  typedef std::list<Adjacent>::const_iterator const_iterator;
36  typedef std::list<Adjacent>::iterator iterator;
37 
38  bool
39  insert(const Adjacent& adjacent);
40 
41  std::list<Adjacent>&
42  getAdjList();
43 
44  const std::list<Adjacent>&
45  getAdjList() const;
46 
47  bool
48  isNeighbor(const ndn::Name& adjName) const;
49 
50  void
51  incrementTimedOutInterestCount(const ndn::Name& neighbor);
52 
53  int32_t
54  getTimedOutInterestCount(const ndn::Name& neighbor) const;
55 
57  getStatusOfNeighbor(const ndn::Name& neighbor) const;
58 
59  void
60  setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
61 
62  void
63  setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
64 
80  bool
81  isAdjLsaBuildable(const uint32_t interestRetryNo) const;
82 
83  int32_t
84  getNumOfActiveNeighbor() const;
85 
86  Adjacent
87  getAdjacent(const ndn::Name& adjName);
88 
89  bool
90  operator==(const AdjacencyList& adl) const;
91 
92  size_t
93  size() const
94  {
95  return m_adjList.size();
96  }
97 
98  void
100  {
101  m_adjList.clear();
102  }
103 
105  findAdjacent(const ndn::Name& adjName);
106 
108  findAdjacent(uint64_t faceId);
109 
111  findAdjacent(const ndn::FaceUri& faceUri);
112 
119  template <typename T = float> void
120  findAdjacent(const std::string& faceUri)
121  {
122  BOOST_STATIC_ASSERT_MSG(std::is_integral<T>::value,
123  "Don't use std::string with findAdjacent!");
124  }
125 
126  uint64_t
127  getFaceId(const ndn::FaceUri& faceUri);
128 
129  void
130  writeLog();
131 
132 public:
134  begin() const
135  {
136  return m_adjList.begin();
137  }
138 
140  end() const
141  {
142  return m_adjList.end();
143  }
144 
145 private:
146  iterator
147  find(const ndn::Name& adjName);
148 
150  find(const ndn::Name& adjName) const;
151 
152 private:
153  std::list<Adjacent> m_adjList;
154 };
155 
156 } // namespace nlsr
157 #endif // NLSR_ADJACENCY_LIST_HPP
void findAdjacent(const std::string &faceUri)
Hack to stop developers from using this function.
int32_t getNumOfActiveNeighbor() const
int32_t getTimedOutInterestCount(const ndn::Name &neighbor) const
void incrementTimedOutInterestCount(const ndn::Name &neighbor)
void setTimedOutInterestCount(const ndn::Name &neighbor, uint32_t count)
bool operator==(const AdjacencyList &adl) const
Adjacent getAdjacent(const ndn::Name &adjName)
size_t size() const
const_iterator begin() const
std::list< Adjacent >::const_iterator const_iterator
uint64_t getFaceId(const ndn::FaceUri &faceUri)
bool isAdjLsaBuildable(const uint32_t interestRetryNo) const
Determines whether this list can be used to build an adj. LSA.
bool insert(const Adjacent &adjacent)
std::list< Adjacent >::iterator iterator
std::list< Adjacent > & getAdjList()
const_iterator end() const
Adjacent::Status getStatusOfNeighbor(const ndn::Name &neighbor) const
bool isNeighbor(const ndn::Name &adjName) const
void setStatusOfNeighbor(const ndn::Name &neighbor, Adjacent::Status status)
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
A neighbor reachable over a Face.
Definition: adjacent.hpp:47
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California,...