NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pit.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_PIT_HPP
27 #define NFD_DAEMON_TABLE_PIT_HPP
28 
29 #include "name-tree.hpp"
30 #include "pit-entry.hpp"
31 
32 namespace nfd {
33 namespace pit {
34 
42 typedef std::vector<shared_ptr<pit::Entry>> DataMatchResult;
43 
44 } // namespace pit
45 
48 class Pit : noncopyable
49 {
50 public:
51  explicit
52  Pit(NameTree& nameTree);
53 
54  ~Pit();
55 
58  size_t
59  size() const;
60 
66  std::pair<shared_ptr<pit::Entry>, bool>
67  insert(const Interest& interest);
68 
73  findAllDataMatches(const Data& data) const;
74 
78  void
79  erase(shared_ptr<pit::Entry> pitEntry);
80 
81 public: // enumeration
82  class const_iterator;
83 
90  begin() const;
91 
97  end() const;
98 
99  class const_iterator : public std::iterator<std::forward_iterator_tag, const pit::Entry>
100  {
101  public:
102  const_iterator();
103 
104  explicit
106 
107  ~const_iterator();
108 
109  const pit::Entry&
110  operator*() const;
111 
112  shared_ptr<pit::Entry>
113  operator->() const;
114 
116  operator++();
117 
119  operator++(int);
120 
121  bool
122  operator==(const const_iterator& other) const;
123 
124  bool
125  operator!=(const const_iterator& other) const;
126 
127  private:
128  NameTree::const_iterator m_nameTreeIterator;
134  size_t m_iPitEntry;
135  };
136 
137 private:
138  NameTree& m_nameTree;
139  size_t m_nItems;
140 };
141 
142 inline size_t
143 Pit::size() const
144 {
145  return m_nItems;
146 }
147 
148 inline Pit::const_iterator
149 Pit::end() const
150 {
151  return const_iterator(m_nameTree.end());
152 }
153 
154 inline
156  : m_iPitEntry(0)
157 {
158 }
159 
160 inline
162  : m_nameTreeIterator(it)
163  , m_iPitEntry(0)
164 {
165 }
166 
167 inline
169 {
170 }
171 
172 inline Pit::const_iterator
174 {
175  Pit::const_iterator temp(*this);
176  ++(*this);
177  return temp;
178 }
179 
180 inline Pit::const_iterator&
182 {
183  ++m_iPitEntry;
184  if (m_iPitEntry < m_nameTreeIterator->getPitEntries().size()) {
185  return *this;
186  }
187 
188  ++m_nameTreeIterator;
189  m_iPitEntry = 0;
190  return *this;
191 }
192 
193 inline const pit::Entry&
195 {
196  return *(this->operator->());
197 }
198 
199 inline shared_ptr<pit::Entry>
201 {
202  return m_nameTreeIterator->getPitEntries().at(m_iPitEntry);
203 }
204 
205 inline bool
207 {
208  return m_nameTreeIterator == other.m_nameTreeIterator &&
209  m_iPitEntry == other.m_iPitEntry;
210 }
211 
212 inline bool
214 {
215  return !(*this == other);
216 }
217 
218 } // namespace nfd
219 
220 #endif // NFD_DAEMON_TABLE_PIT_HPP
bool operator!=(const const_iterator &other) const
Definition: pit.hpp:213
bool operator==(const const_iterator &other) const
Definition: pit.hpp:206
void erase(shared_ptr< pit::Entry > pitEntry)
erases a PIT Entry
Definition: pit.cpp:108
size_t size() const
Definition: pit.hpp:143
const_iterator end() const
Get an iterator referring to the past-the-end FIB entry.
Definition: name-tree.hpp:378
pit::DataMatchResult findAllDataMatches(const Data &data) const
performs a Data match
Definition: pit.cpp:91
represents the Interest Table
Definition: pit.hpp:48
Pit(NameTree &nameTree)
Definition: pit.cpp:54
const_iterator end() const
returns an iterator referring to the past-the-end PIT entry
Definition: pit.hpp:149
represents a PIT entry
Definition: pit-entry.hpp:67
Class Name Tree.
Definition: name-tree.hpp:79
std::pair< shared_ptr< pit::Entry >, bool > insert(const Interest &interest)
inserts a PIT entry for Interest
Definition: pit.cpp:65
const_iterator begin() const
returns an iterator pointing to the first PIT entry
Definition: pit.cpp:120
const pit::Entry & operator*() const
Definition: pit.hpp:194
shared_ptr< pit::Entry > operator->() const
Definition: pit.hpp:200
const_iterator & operator++()
Definition: pit.hpp:181
~Pit()
Definition: pit.cpp:60
std::vector< shared_ptr< pit::Entry > > DataMatchResult
Definition: pit.hpp:42