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 
55  std::list<Adjacent>&
56  getAdjList();
57 
58  const std::list<Adjacent>&
59  getAdjList() const;
60 
61  bool
62  isNeighbor(const ndn::Name& adjName) const;
63 
64  void
65  incrementTimedOutInterestCount(const ndn::Name& neighbor);
66 
67  int32_t
68  getTimedOutInterestCount(const ndn::Name& neighbor) const;
69 
71  getStatusOfNeighbor(const ndn::Name& neighbor) const;
72 
73  void
74  setStatusOfNeighbor(const ndn::Name& neighbor, Adjacent::Status status);
75 
76  void
77  setTimedOutInterestCount(const ndn::Name& neighbor, uint32_t count);
78 
86  void
88 
104  bool
105  isAdjLsaBuildable(const uint32_t interestRetryNo) const;
106 
107  int32_t
108  getNumOfActiveNeighbor() const;
109 
110  Adjacent
111  getAdjacent(const ndn::Name& adjName);
112 
113  bool
114  operator==(const AdjacencyList& adl) const;
115 
116  size_t
117  size() const
118  {
119  return m_adjList.size();
120  }
121 
122  void
124  {
125  if (m_adjList.size() > 0) {
126  m_adjList.clear();
127  }
128  }
129 
131  findAdjacent(const ndn::Name& adjName);
132 
134  findAdjacent(uint64_t faceId);
135 
137  findAdjacent(const ndn::FaceUri& faceUri);
138 
145  template <typename T = float> void
146  findAdjacent(const std::string& faceUri)
147  {
148  BOOST_STATIC_ASSERT_MSG(std::is_integral<T>::value,
149  "Don't use std::string with findAdjacent!");
150  }
151 
152  uint64_t
153  getFaceId(const ndn::FaceUri& faceUri);
154 
155  void
156  writeLog();
157 
158 public:
159  const_iterator
160  begin() const
161  {
162  return m_adjList.begin();
163  }
164 
165  const_iterator
166  end() const
167  {
168  return m_adjList.end();
169  }
170 
171 private:
172  iterator
173  find(const ndn::Name& adjName);
174 
175  const_iterator
176  find(const ndn::Name& adjName) const;
177 
178 private:
179  std::list<Adjacent> m_adjList;
180 };
181 
182 } // namespace nlsr
183 #endif // NLSR_ADJACENCY_LIST_HPP
void setTimedOutInterestCount(const ndn::Name &neighbor, uint32_t count)
void findAdjacent(const std::string &faceUri)
Hack to stop developers from using this function.
bool operator==(const AdjacencyList &adl) const
bool isNeighbor(const ndn::Name &adjName) const
std::list< Adjacent >::const_iterator const_iterator
Adjacent::Status getStatusOfNeighbor(const ndn::Name &neighbor) const
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)
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
const_iterator begin() const
int32_t getTimedOutInterestCount(const ndn::Name &neighbor) const
int32_t insert(Adjacent &adjacent)
Inserts an adjacency into the list.
A neighbor reachable over a Face.
Definition: adjacent.hpp:38
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
AdjacencyList::iterator findAdjacent(const ndn::Name &adjName)
int32_t getNumOfActiveNeighbor() const
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()
void setStatusOfNeighbor(const ndn::Name &neighbor, Adjacent::Status status)
const_iterator end() const