NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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 
80  std::pair<RibEntry::iterator, bool>
81  insertRoute(const Route& route);
82 
85  void
86  eraseRoute(const Route& route);
87 
91  iterator
93 
94  bool
95  hasFaceId(const uint64_t faceId) const;
96 
97  RouteList&
98  getRoutes();
99 
100  size_t
101  getNRoutes() const;
102 
103  iterator
104  findRoute(const Route& route);
105 
106  const_iterator
107  findRoute(const Route& route) const;
108 
109  bool
110  hasRoute(const Route& route);
111 
112  void
113  addInheritedRoute(const Route& route);
114 
115  void
116  removeInheritedRoute(const Route& route);
117 
122  const RouteList&
123  getInheritedRoutes() const;
124 
130  RouteList::const_iterator
131  findInheritedRoute(const Route& route) const;
132 
136  bool
137  hasInheritedRoute(const Route& route) const;
138 
139  bool
140  hasCapture() const;
141 
146  bool
147  hasChildInheritOnFaceId(uint64_t faceId) const;
148 
152  const Route*
153  getRouteWithLowestCostByFaceId(uint64_t faceId) const;
154 
155  const Route*
156  getRouteWithSecondLowestCostByFaceId(uint64_t faceId) const;
157 
163  const Route*
164  getRouteWithLowestCostAndChildInheritByFaceId(uint64_t faceId) const;
165 
166  const_iterator
167  begin() const;
168 
169  const_iterator
170  end() const;
171 
172  iterator
173  begin();
174 
175  iterator
176  end();
177 
178 private:
179  void
180  setParent(shared_ptr<RibEntry> parent);
181 
182 private:
183  Name m_name;
184  std::list<shared_ptr<RibEntry>> m_children;
185  shared_ptr<RibEntry> m_parent;
186  RouteList m_routes;
187  RouteList m_inheritedRoutes;
188 
195  uint64_t m_nRoutesWithCaptureSet;
196 };
197 
198 inline void
199 RibEntry::setName(const Name& prefix)
200 {
201  m_name = prefix;
202 }
203 
204 inline const Name&
206 {
207  return m_name;
208 }
209 
210 inline void
211 RibEntry::setParent(shared_ptr<RibEntry> parent)
212 {
213  m_parent = parent;
214 }
215 
216 inline shared_ptr<RibEntry>
218 {
219  return m_parent;
220 }
221 
222 inline const std::list<shared_ptr<RibEntry> >&
224 {
225  return m_children;
226 }
227 
228 inline RibEntry::RouteList&
230 {
231  return m_routes;
232 }
233 
234 inline const RibEntry::RouteList&
236 {
237  return m_inheritedRoutes;
238 }
239 
242 {
243  return m_routes.begin();
244 }
245 
248 {
249  return m_routes.end();
250 }
251 
252 inline RibEntry::iterator
254 {
255  return m_routes.begin();
256 }
257 
258 inline RibEntry::iterator
260 {
261  return m_routes.end();
262 }
263 
264 std::ostream&
265 operator<<(std::ostream& os, const RibEntry& entry);
266 
267 } // namespace rib
268 } // namespace nfd
269 
270 #endif // NFD_RIB_RIB_ENTRY_HPP
shared_ptr< RibEntry > getParent() const
Definition: rib-entry.hpp:217
RouteList & getRoutes()
Definition: rib-entry.hpp:229
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:205
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:37
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:241
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
std::pair< RibEntry::iterator, 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
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:199
std::list< Route > RouteList
Definition: rib-entry.hpp:39
const RouteList & getInheritedRoutes() const
Returns the routes this namespace has inherited.
Definition: rib-entry.hpp:235
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
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:247
const std::list< shared_ptr< RibEntry > > & getChildren() const
Definition: rib-entry.hpp:223