NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
rib-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_RIB_RIB_ENTRY_HPP
27 #define NFD_RIB_RIB_ENTRY_HPP
28 
29 #include "route.hpp"
30 
31 namespace nfd {
32 namespace rib {
33 
36 class RibEntry : public enable_shared_from_this<RibEntry>
37 {
38 public:
39  typedef std::list<Route> RouteList;
41  typedef RouteList::const_iterator const_iterator;
42 
44  : m_nRoutesWithCaptureSet(0)
45  {
46  }
47 
48  void
49  setName(const Name& prefix);
50 
51  const Name&
52  getName() const;
53 
54  shared_ptr<RibEntry>
55  getParent() const;
56 
57  bool
58  hasParent() const;
59 
60  void
61  addChild(shared_ptr<RibEntry> child);
62 
63  void
64  removeChild(shared_ptr<RibEntry> child);
65 
66  const std::list<shared_ptr<RibEntry>>&
67  getChildren() const;
68 
69  bool
70  hasChildren() const;
71 
77  bool
78  insertRoute(const Route& route);
79 
82  void
83  eraseRoute(const Route& route);
84 
88  iterator
90 
91  bool
92  hasFaceId(const uint64_t faceId) const;
93 
94  RouteList&
95  getRoutes();
96 
97  size_t
98  getNRoutes() const;
99 
100  iterator
101  findRoute(const Route& route);
102 
103  const_iterator
104  findRoute(const Route& route) const;
105 
106  bool
107  hasRoute(const Route& route);
108 
109  void
110  addInheritedRoute(const Route& route);
111 
112  void
113  removeInheritedRoute(const Route& route);
114 
119  const RouteList&
120  getInheritedRoutes() const;
121 
127  RouteList::const_iterator
128  findInheritedRoute(const Route& route) const;
129 
133  bool
134  hasInheritedRoute(const Route& route) const;
135 
136  bool
137  hasCapture() const;
138 
143  bool
144  hasChildInheritOnFaceId(uint64_t faceId) const;
145 
149  const Route*
150  getRouteWithLowestCostByFaceId(uint64_t faceId) const;
151 
152  const Route*
153  getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const;
154 
160  const Route*
161  getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const;
162 
163  const_iterator
164  begin() const;
165 
166  const_iterator
167  end() const;
168 
169  iterator
170  begin();
171 
172  iterator
173  end();
174 
175 private:
176  void
177  setParent(shared_ptr<RibEntry> parent);
178 
179 private:
180  Name m_name;
181  std::list<shared_ptr<RibEntry>> m_children;
182  shared_ptr<RibEntry> m_parent;
183  RouteList m_routes;
184  RouteList m_inheritedRoutes;
185 
192  uint64_t m_nRoutesWithCaptureSet;
193 };
194 
195 inline void
196 RibEntry::setName(const Name& prefix)
197 {
198  m_name = prefix;
199 }
200 
201 inline const Name&
203 {
204  return m_name;
205 }
206 
207 inline void
208 RibEntry::setParent(shared_ptr<RibEntry> parent)
209 {
210  m_parent = parent;
211 }
212 
213 inline shared_ptr<RibEntry>
215 {
216  return m_parent;
217 }
218 
219 inline const std::list<shared_ptr<RibEntry> >&
221 {
222  return m_children;
223 }
224 
225 inline RibEntry::RouteList&
227 {
228  return m_routes;
229 }
230 
231 inline const RibEntry::RouteList&
233 {
234  return m_inheritedRoutes;
235 }
236 
239 {
240  return m_routes.begin();
241 }
242 
245 {
246  return m_routes.end();
247 }
248 
249 inline RibEntry::iterator
251 {
252  return m_routes.begin();
253 }
254 
255 inline RibEntry::iterator
257 {
258  return m_routes.end();
259 }
260 
261 std::ostream&
262 operator<<(std::ostream& os, const RibEntry& entry);
263 
264 } // namespace rib
265 } // namespace nfd
266 
267 #endif // NFD_RIB_RIB_ENTRY_HPP
shared_ptr< RibEntry > getParent() const
Definition: rib-entry.hpp:214
RouteList & getRoutes()
Definition: rib-entry.hpp:226
void removeChild(shared_ptr< RibEntry > child)
Definition: rib-entry.cpp:106
iterator findRoute(const Route &route)
Definition: rib-entry.cpp:38
void addChild(shared_ptr< RibEntry > child)
Definition: rib-entry.cpp:98
bool hasFaceId(const uint64_t faceId) const
Definition: rib-entry.cpp:84
bool hasRoute(const Route &route)
Definition: rib-entry.cpp:76
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)
Definition: fib-update.hpp:74
size_t getNRoutes() const
Definition: rib-entry.cpp:92
const Route * getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const
Definition: rib-entry.cpp:201
RouteList::iterator iterator
Definition: rib-entry.hpp:40
const Name & getName() const
Definition: rib-entry.hpp:202
void removeInheritedRoute(const Route &route)
Definition: rib-entry.cpp:138
Table::const_iterator iterator
Definition: cs-internal.hpp:41
void addInheritedRoute(const Route &route)
Definition: rib-entry.cpp:132
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
const Route * getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID and its child inherit flag set...
Definition: rib-entry.cpp:225
represents a RIB entry, which contains one or more Routes with the same prefix
Definition: rib-entry.hpp:36
represents a route for a name prefix
Definition: route.hpp:38
bool hasInheritedRoute(const Route &route) const
Determines if the entry has an inherited route with a matching face ID.
Definition: rib-entry.cpp:153
RouteList::const_iterator findInheritedRoute(const Route &route) const
Finds an inherited route with a matching face ID.
Definition: rib-entry.cpp:146
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const_iterator begin() const
Definition: rib-entry.hpp:238
bool hasChildInheritOnFaceId(uint64_t faceId) const
Determines if the entry has an inherited route with the passed face ID and its child inherit flag set...
Definition: rib-entry.cpp:167
bool hasChildren() const
bool hasParent() const
RouteList::const_iterator const_iterator
Definition: rib-entry.hpp:41
void setName(const Name &prefix)
Definition: rib-entry.hpp:196
std::list< Route > RouteList
Definition: rib-entry.hpp:39
const RouteList & getInheritedRoutes() const
Returns the routes this namespace has inherited.
Definition: rib-entry.hpp:232
void eraseRoute(const Route &route)
erases a Route with the same faceId and origin
Definition: rib-entry.cpp:69
bool hasCapture() const
Definition: rib-entry.cpp:161
bool insertRoute(const Route &route)
inserts a new route into the entry&#39;s route list If another route already exists with the same faceId ...
Definition: rib-entry.cpp:50
const Route * getRouteWithLowestCostByFaceId(uint64_t faceId) const
Returns the route with the lowest cost that has the passed face ID.
Definition: rib-entry.cpp:179
const_iterator end() const
Definition: rib-entry.hpp:244
const std::list< shared_ptr< RibEntry > > & getChildren() const
Definition: rib-entry.hpp:220