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  double
81  getLinkCost() const
82  {
83  return ceil(m_linkCost);
84  }
85 
86  void
87  setLinkCost(double lc);
88 
89  Status
90  getStatus() const
91  {
92  return m_status;
93  }
94 
95  void
97  {
98  m_status = s;
99  }
100 
101  uint32_t
103  {
104  return m_interestTimedOutNo;
105  }
106 
107  void
108  setInterestTimedOutNo(uint32_t iton)
109  {
110  m_interestTimedOutNo = iton;
111  }
112 
113  void
114  setFaceId(uint64_t faceId)
115  {
116  m_faceId = faceId;
117  }
118 
119  uint64_t
120  getFaceId() const
121  {
122  return m_faceId;
123  }
124 
126  bool
127  operator==(const Adjacent& adjacent) const;
128 
129  bool
130  operator!=(const Adjacent& adjacent) const
131  {
132  return !(*this == adjacent);
133  }
134 
135  bool
136  operator<(const Adjacent& adjacent) const;
137 
138  inline bool
139  compare(const ndn::Name& adjacencyName) const
140  {
141  return m_name == adjacencyName;
142  }
143 
144  inline bool
145  compareFaceId(const uint64_t faceId) const
146  {
147  return m_faceId == faceId;
148  }
149 
150  inline bool
151  compareFaceUri(const ndn::FaceUri& faceUri) const
152  {
153  return m_faceUri == faceUri;
154  }
155 
156 public:
157  static const double DEFAULT_LINK_COST;
158  static const double NON_ADJACENT_COST;
159 
160 private:
162  ndn::Name m_name;
164  ndn::FaceUri m_faceUri;
166  double m_linkCost;
168  Status m_status;
170  uint32_t m_interestTimedOutNo;
173  uint64_t m_faceId;
174 
175  friend std::ostream&
176  operator<<(std::ostream& os, const Adjacent& adjacent);
177 };
178 
179 std::ostream&
180 operator<<(std::ostream& os, const Adjacent& adjacent);
181 
182 } // namespace nlsr
183 
184 #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:82
const ndn::FaceUri & getFaceUri() const
Definition: adjacent.hpp:69
friend std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:99
uint64_t getFaceId() const
Definition: adjacent.hpp:120
static const double DEFAULT_LINK_COST
Definition: adjacent.hpp:157
Status getStatus() const
Definition: adjacent.hpp:90
double getLinkCost() const
Definition: adjacent.hpp:81
static const double NON_ADJACENT_COST
Definition: adjacent.hpp:158
void setStatus(Status s)
Definition: adjacent.hpp:96
bool compare(const ndn::Name &adjacencyName) const
Definition: adjacent.hpp:139
void setInterestTimedOutNo(uint32_t iton)
Definition: adjacent.hpp:108
bool compareFaceUri(const ndn::FaceUri &faceUri) const
Definition: adjacent.hpp:151
const ndn::Name & getName() const
Definition: adjacent.hpp:57
void setFaceId(uint64_t faceId)
Definition: adjacent.hpp:114
bool operator<(const Adjacent &adjacent) const
Definition: adjacent.cpp:91
A neighbor reachable over a Face.
Definition: adjacent.hpp:38
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void setFaceUri(const ndn::FaceUri &faceUri)
Definition: adjacent.hpp:75
bool compareFaceId(const uint64_t faceId) const
Definition: adjacent.hpp:145
void setName(const ndn::Name &an)
Definition: adjacent.hpp:63
void setLinkCost(double lc)
Definition: adjacent.cpp:68
uint32_t getInterestTimedOutNo() const
Definition: adjacent.hpp:102
bool operator!=(const Adjacent &adjacent) const
Definition: adjacent.hpp:130