adjacent.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
21 #include <string>
22 #include <cmath>
23 #include <boost/cstdint.hpp>
24 
25 #include <ndn-cxx/face.hpp>
26 #include <ndn-cxx/net/face-uri.hpp>
27 
28 #ifndef NLSR_ADJACENT_HPP
29 #define NLSR_ADJACENT_HPP
30 
31 namespace nlsr {
32 
38 class Adjacent
39 {
40 
41 public:
42  enum Status
43  {
47  };
48 
49  Adjacent();
50 
51  Adjacent(const ndn::Name& an);
52 
53  Adjacent(const ndn::Name& an, const ndn::FaceUri& faceUri, double lc,
54  Status s, uint32_t iton, uint64_t faceId);
55 
56  const ndn::Name&
57  getName() const
58  {
59  return m_name;
60  }
61 
62  void
63  setName(const ndn::Name& an)
64  {
65  m_name = an;
66  }
67 
68  const ndn::FaceUri&
69  getFaceUri() const
70  {
71  return m_faceUri;
72  }
73 
74  void
75  setFaceUri(const ndn::FaceUri& faceUri)
76  {
77  m_faceUri = faceUri;
78  }
79 
80  uint64_t
81  getLinkCost() const
82  {
83  uint64_t linkCost = static_cast<uint64_t>(ceil(m_linkCost));
84  return linkCost;
85  }
86 
87  void
88  setLinkCost(double lc)
89  {
90  m_linkCost = lc;
91  }
92 
93  Status
94  getStatus() const
95  {
96  return m_status;
97  }
98 
99  void
101  {
102  m_status = s;
103  }
104 
105  uint32_t
107  {
108  return m_interestTimedOutNo;
109  }
110 
111  void
112  setInterestTimedOutNo(uint32_t iton)
113  {
114  m_interestTimedOutNo = iton;
115  }
116 
117  void
118  setFaceId(uint64_t faceId)
119  {
120  m_faceId = faceId;
121  }
122 
123  uint64_t
124  getFaceId() const
125  {
126  return m_faceId;
127  }
128 
130  bool
131  operator==(const Adjacent& adjacent) const;
132 
133  bool
134  operator!=(const Adjacent& adjacent) const
135  {
136  return !(*this == adjacent);
137  }
138 
139  bool
140  operator<(const Adjacent& adjacent) const;
141 
142  inline bool
143  compare(const ndn::Name& adjacencyName)
144  {
145  return m_name == adjacencyName;
146  }
147 
148  inline bool
149  compareFaceId(const uint64_t faceId)
150  {
151  return m_faceId == faceId;
152  }
153 
154  inline bool
155  compareFaceUri(const ndn::FaceUri& faceUri)
156  {
157  return m_faceUri == faceUri;
158  }
159 
160  void
161  writeLog();
162 
163 public:
164  static const float DEFAULT_LINK_COST;
165 
166 private:
168  ndn::Name m_name;
170  ndn::FaceUri m_faceUri;
172  double m_linkCost;
174  Status m_status;
176  uint32_t m_interestTimedOutNo;
179  uint64_t m_faceId;
180 
181  friend std::ostream&
182  operator<<(std::ostream& os, const Adjacent& adjacent);
183 };
184 
185 std::ostream&
186 operator<<(std::ostream& os, const Adjacent& adjacent);
187 
188 } // namespace nlsr
189 
190 #endif // NLSR_ADJACENT_HPP
bool operator==(const Adjacent &adjacent) const
Equality is when name, Face URI, and link cost are all equal.
Definition: adjacent.cpp:67
const ndn::FaceUri & getFaceUri() const
Definition: adjacent.hpp:69
static const float DEFAULT_LINK_COST
Definition: adjacent.hpp:164
friend std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:83
uint64_t getFaceId() const
Definition: adjacent.hpp:124
Status getStatus() const
Definition: adjacent.hpp:94
void setStatus(Status s)
Definition: adjacent.hpp:100
bool compare(const ndn::Name &adjacencyName)
Definition: adjacent.hpp:143
void setInterestTimedOutNo(uint32_t iton)
Definition: adjacent.hpp:112
const ndn::Name & getName() const
Definition: adjacent.hpp:57
void setFaceId(uint64_t faceId)
Definition: adjacent.hpp:118
bool operator<(const Adjacent &adjacent) const
Definition: adjacent.cpp:76
bool compareFaceUri(const ndn::FaceUri &faceUri)
Definition: adjacent.hpp:155
A neighbor reachable over a Face.
Definition: adjacent.hpp:38
void writeLog()
Definition: adjacent.cpp:92
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void setFaceUri(const ndn::FaceUri &faceUri)
Definition: adjacent.hpp:75
uint64_t getLinkCost() const
Definition: adjacent.hpp:81
bool compareFaceId(const uint64_t faceId)
Definition: adjacent.hpp:149
void setName(const ndn::Name &an)
Definition: adjacent.hpp:63
void setLinkCost(double lc)
Definition: adjacent.hpp:88
uint32_t getInterestTimedOutNo() const
Definition: adjacent.hpp:106
bool operator!=(const Adjacent &adjacent) const
Definition: adjacent.hpp:134