adjacency-list.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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 #include <boost/cstdint.hpp>
30 
31 namespace nlsr {
32 
34 {
35 public:
36  typedef std::list<Adjacent>::const_iterator const_iterator;
37  typedef std::list<Adjacent>::iterator iterator;
38 
39  bool
40  insert(Adjacent& adjacent);
41 
42  std::list<Adjacent>&
43  getAdjList();
44 
45  const std::list<Adjacent>&
46  getAdjList() const;
47 
48  bool
49  isNeighbor(const ndn::Name& adjName) const;
50 
51  void
52  incrementTimedOutInterestCount(const ndn::Name& neighbor);
53 
54  int32_t
55  getTimedOutInterestCount(const ndn::Name& neighbor) const;
56 
58  getStatusOfNeighbor(const ndn::Name& neighbor) const;
59 
60  void
61  setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
62 
63  void
64  setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
65 
81  bool
82  isAdjLsaBuildable(const uint32_t interestRetryNo) const;
83 
84  int32_t
85  getNumOfActiveNeighbor() const;
86 
87  Adjacent
88  getAdjacent(const ndn::Name& adjName);
89 
90  bool
91  operator==(const AdjacencyList& adl) const;
92 
93  size_t
94  size() const
95  {
96  return m_adjList.size();
97  }
98 
99  void
101  {
102  m_adjList.clear();
103  }
104 
106  findAdjacent(const ndn::Name& adjName);
107 
109  findAdjacent(uint64_t faceId);
110 
112  findAdjacent(const ndn::FaceUri& faceUri);
113 
120  template <typename T = float> void
121  findAdjacent(const std::string& faceUri)
122  {
123  BOOST_STATIC_ASSERT_MSG(std::is_integral<T>::value,
124  "Don't use std::string with findAdjacent!");
125  }
126 
127  uint64_t
128  getFaceId(const ndn::FaceUri& faceUri);
129 
130  void
131  writeLog();
132 
133 public:
134  const_iterator
135  begin() const
136  {
137  return m_adjList.begin();
138  }
139 
140  const_iterator
141  end() const
142  {
143  return m_adjList.end();
144  }
145 
146 private:
147  iterator
148  find(const ndn::Name& adjName);
149 
150  const_iterator
151  find(const ndn::Name& adjName) const;
152 
153 private:
154  std::list<Adjacent> m_adjList;
155 };
156 
157 } // namespace nlsr
158 #endif // NLSR_ADJACENCY_LIST_HPP
bool operator==(const AdjacencyList &adl) const
void setTimedOutInterestCount(const ndn::Name &neighbor, uint32_t count)
bool isNeighbor(const ndn::Name &adjName) const
void findAdjacent(const std::string &faceUri)
Hack to stop developers from using this function.
std::list< Adjacent >::const_iterator const_iterator
int32_t getNumOfActiveNeighbor() const
Adjacent getAdjacent(const ndn::Name &adjName)
const_iterator begin() const
int32_t getTimedOutInterestCount(const ndn::Name &neighbor) const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
size_t size() const
Adjacent::Status getStatusOfNeighbor(const ndn::Name &neighbor) const
A neighbor reachable over a Face.
Definition: adjacent.hpp:46
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
bool isAdjLsaBuildable(const uint32_t interestRetryNo) const
Determines whether this list can be used to build an adj. LSA.
bool insert(Adjacent &adjacent)
const_iterator end() const
std::list< Adjacent >::iterator iterator
void incrementTimedOutInterestCount(const ndn::Name &neighbor)
uint64_t getFaceId(const ndn::FaceUri &faceUri)
std::list< Adjacent > & getAdjList()
void setStatusOfNeighbor(const ndn::Name &neighbor, Adjacent::Status status)