NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
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
size_t size() const
Definition: pit.hpp:143
represents an Interest packet
Definition: interest.hpp:45
represents the Interest Table
Definition: pit.hpp:48
Table::const_iterator iterator
Definition: cs-internal.hpp:41
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
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
bool operator!=(const GlobalRouter::Incidency &a, const GlobalRouter::Incidency &b)
const pit::Entry & operator*() const
Definition: pit.hpp:194
shared_ptr< pit::Entry > operator->() const
Definition: pit.hpp:200
represents a Data packet
Definition: data.hpp:39
const_iterator & operator++()
Definition: pit.hpp:181
bool operator==(const GlobalRouter::Incidency &a, const GlobalRouter::Incidency &b)
std::vector< shared_ptr< pit::Entry > > DataMatchResult
Definition: pit.hpp:42