NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
fib.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_FIB_HPP
27 #define NFD_DAEMON_TABLE_FIB_HPP
28 
29 #include "fib-entry.hpp"
30 #include "name-tree.hpp"
31 
32 namespace nfd {
33 
34 namespace measurements {
35 class Entry;
36 }
37 namespace pit {
38 class Entry;
39 }
40 
44 class Fib : noncopyable
45 {
46 public:
47  explicit
48  Fib(NameTree& nameTree);
49 
50  ~Fib();
51 
52  size_t
53  size() const;
54 
55 public: // lookup
57  shared_ptr<fib::Entry>
58  findLongestPrefixMatch(const Name& prefix) const;
59 
61  shared_ptr<fib::Entry>
62  findLongestPrefixMatch(const pit::Entry& pitEntry) const;
63 
65  shared_ptr<fib::Entry>
66  findLongestPrefixMatch(const measurements::Entry& measurementsEntry) const;
67 
68  shared_ptr<fib::Entry>
69  findExactMatch(const Name& prefix) const;
70 
71 public: // mutation
76  std::pair<shared_ptr<fib::Entry>, bool>
77  insert(const Name& prefix);
78 
79  void
80  erase(const Name& prefix);
81 
82  void
83  erase(const fib::Entry& entry);
84 
92  void
93  removeNextHopFromAllEntries(shared_ptr<Face> face);
94 
95 public: // enumeration
96  class const_iterator;
97 
104  begin() const;
105 
111  end() const;
112 
113  class const_iterator : public std::iterator<std::forward_iterator_tag, const fib::Entry>
114  {
115  public:
116  const_iterator() = default;
117 
118  explicit
120 
121  ~const_iterator();
122 
123  const fib::Entry&
124  operator*() const;
125 
126  shared_ptr<fib::Entry>
127  operator->() const;
128 
130  operator++();
131 
133  operator++(int);
134 
135  bool
136  operator==(const const_iterator& other) const;
137 
138  bool
139  operator!=(const const_iterator& other) const;
140 
141  private:
142  NameTree::const_iterator m_nameTreeIterator;
143  };
144 
145 private:
146  shared_ptr<fib::Entry>
147  findLongestPrefixMatch(shared_ptr<name_tree::Entry> nameTreeEntry) const;
148 
149  void
150  erase(shared_ptr<name_tree::Entry> nameTreeEntry);
151 
152 private:
153  NameTree& m_nameTree;
154  size_t m_nItems;
155 
162  static const shared_ptr<fib::Entry> s_emptyEntry;
163 };
164 
165 inline size_t
166 Fib::size() const
167 {
168  return m_nItems;
169 }
170 
171 inline Fib::const_iterator
172 Fib::end() const
173 {
174  return const_iterator(m_nameTree.end());
175 }
176 
177 inline
179  : m_nameTreeIterator(it)
180 {
181 }
182 
183 inline
185 {
186 }
187 
188 inline
191 {
192  Fib::const_iterator temp(*this);
193  ++(*this);
194  return temp;
195 }
196 
197 inline Fib::const_iterator&
199 {
200  ++m_nameTreeIterator;
201  return *this;
202 }
203 
204 inline const fib::Entry&
206 {
207  return *this->operator->();
208 }
209 
210 inline shared_ptr<fib::Entry>
212 {
213  return m_nameTreeIterator->getFibEntry();
214 }
215 
216 inline bool
218 {
219  return m_nameTreeIterator == other.m_nameTreeIterator;
220 }
221 
222 inline bool
224 {
225  return m_nameTreeIterator != other.m_nameTreeIterator;
226 }
227 
228 } // namespace nfd
229 
230 #endif // NFD_DAEMON_TABLE_FIB_HPP
const fib::Entry & operator*() const
Definition: fib.hpp:205
const_iterator end() const
returns an iterator referring to the past-the-end FIB entry
Definition: fib.hpp:172
represents a FIB entry
Definition: fib-entry.hpp:53
bool operator!=(const const_iterator &other) const
Definition: fib.hpp:223
represents the FIB
Definition: fib.hpp:44
represents a Measurements entry
Table::const_iterator iterator
Definition: cs-internal.hpp:41
shared_ptr< fib::Entry > operator->() const
Definition: fib.hpp:211
const_iterator & operator++()
Definition: fib.hpp:198
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
represents a PIT entry
Definition: pit-entry.hpp:69
Class Name Tree.
Definition: name-tree.hpp:79
Name abstraction to represent an absolute name.
Definition: name.hpp:46
size_t size() const
Definition: fib.hpp:166
bool operator!=(const GlobalRouter::Incidency &a, const GlobalRouter::Incidency &b)
bool operator==(const const_iterator &other) const
Definition: fib.hpp:217
bool operator==(const GlobalRouter::Incidency &a, const GlobalRouter::Incidency &b)