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  AdjacencyList();
41 
52  int32_t
53  insert(Adjacent& adjacent);
54 
64  bool
65  updateAdjacentStatus(const ndn::Name& adjName, Adjacent::Status s);
66 
67  int32_t
68  updateAdjacentLinkCost(const ndn::Name& adjName, double lc);
69 
70  std::list<Adjacent>&
71  getAdjList();
72 
73  const std::list<Adjacent>&
74  getAdjList() const;
75 
76  bool
77  isNeighbor(const ndn::Name& adjName);
78 
79  void
80  incrementTimedOutInterestCount(const ndn::Name& neighbor);
81 
82  int32_t
83  getTimedOutInterestCount(const ndn::Name& neighbor);
84 
86  getStatusOfNeighbor(const ndn::Name& neighbor);
87 
88  void
89  setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
90 
91  void
92  setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
93 
101  void
103 
119  bool
120  isAdjLsaBuildable(const uint32_t interestRetryNo) const;
121 
122  int32_t
124 
125  Adjacent
126  getAdjacent(const ndn::Name& adjName);
127 
128  bool
129  operator==(AdjacencyList& adl) const;
130 
131  size_t
132  size() const
133  {
134  return m_adjList.size();
135  }
136 
137  void
139  {
140  if (m_adjList.size() > 0) {
141  m_adjList.clear();
142  }
143  }
144 
146  findAdjacent(const ndn::Name& adjName);
147 
149  findAdjacent(uint64_t faceId);
150 
152  findAdjacent(const ndn::FaceUri& faceUri);
153 
160  template <typename T = float> void
161  findAdjacent(const std::string& faceUri)
162  {
163  BOOST_STATIC_ASSERT_MSG(std::is_integral<T>::value,
164  "Don't use std::string with findAdjacent!");
165  }
166 
167  uint64_t
168  getFaceId(const ndn::FaceUri& faceUri);
169 
170  void
171  writeLog();
172 
173 public:
174  const_iterator
175  begin() const
176  {
177  return m_adjList.begin();
178  }
179 
180  const_iterator
181  end() const
182  {
183  return m_adjList.end();
184  }
185 
186 private:
187  iterator
188  find(const ndn::Name& adjName);
189 
190 private:
191  std::list<Adjacent> m_adjList;
192 };
193 
194 } // namespace nlsr
195 #endif // NLSR_ADJACENCY_LIST_HPP
void setTimedOutInterestCount(const ndn::Name &neighbor, uint32_t count)
bool updateAdjacentStatus(const ndn::Name &adjName, Adjacent::Status s)
Sets the status of an adjacency.
void findAdjacent(const std::string &faceUri)
Hack to stop developers from using this function.
Adjacent::Status getStatusOfNeighbor(const ndn::Name &neighbor)
std::list< Adjacent >::const_iterator const_iterator
bool isAdjLsaBuildable(const uint32_t interestRetryNo) const
Determines whether this list can be used to build an adj. LSA.
Adjacent getAdjacent(const ndn::Name &adjName)
int32_t updateAdjacentLinkCost(const ndn::Name &adjName, double lc)
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
const_iterator begin() const
bool isNeighbor(const ndn::Name &adjName)
int32_t getNumOfActiveNeighbor()
int32_t insert(Adjacent &adjacent)
Inserts an adjacency into the list.
A neighbor reachable over a Face.
Definition: adjacent.hpp:38
int32_t getTimedOutInterestCount(const ndn::Name &neighbor)
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
void addAdjacents(AdjacencyList &adl)
Copies the adjacencies in a list to this one.
std::list< Adjacent >::iterator iterator
size_t size() const
void incrementTimedOutInterestCount(const ndn::Name &neighbor)
uint64_t getFaceId(const ndn::FaceUri &faceUri)
std::list< Adjacent > & getAdjList()
bool operator==(AdjacencyList &adl) const
void setStatusOfNeighbor(const ndn::Name &neighbor, Adjacent::Status status)
const_iterator end() const