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-2022, 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  using const_iterator = std::list<Adjacent>::const_iterator;
36  using iterator = std::list<Adjacent>::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  void
120  findAdjacent(const std::string&) = delete;
121 
122  uint64_t
123  getFaceId(const ndn::FaceUri& faceUri);
124 
125  void
126  writeLog();
127 
128 public:
130  begin() const
131  {
132  return m_adjList.begin();
133  }
134 
136  end() const
137  {
138  return m_adjList.end();
139  }
140 
141 private:
142  iterator
143  find(const ndn::Name& adjName);
144 
146  find(const ndn::Name& adjName) const;
147 
148 private:
149  std::list<Adjacent> m_adjList;
150 };
151 
152 } // namespace nlsr
153 #endif // NLSR_ADJACENCY_LIST_HPP
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)
std::list< Adjacent >::iterator iterator
std::list< Adjacent >::const_iterator const_iterator
size_t size() const
void findAdjacent(const std::string &)=delete
Hack to stop developers from using this function.
const_iterator begin() const
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 > & 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.