NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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; -*- */
2 /*
3  * Copyright (c) 2014-2018, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef NFD_DAEMON_TABLE_PIT_HPP
27 #define NFD_DAEMON_TABLE_PIT_HPP
28 
29 #include "pit-entry.hpp"
30 #include "pit-iterator.hpp"
31 
32 namespace nfd {
33 namespace pit {
34 
43 using DataMatchResult = std::vector<shared_ptr<Entry>>;
44 
47 class Pit : noncopyable
48 {
49 public:
50  explicit
51  Pit(NameTree& nameTree);
52 
55  size_t
56  size() const
57  {
58  return m_nItems;
59  }
60 
65  shared_ptr<Entry>
66  find(const Interest& interest) const
67  {
68  return const_cast<Pit*>(this)->findOrInsert(interest, false).first;
69  }
70 
76  std::pair<shared_ptr<Entry>, bool>
77  insert(const Interest& interest)
78  {
79  return this->findOrInsert(interest, true);
80  }
81 
86  findAllDataMatches(const Data& data) const;
87 
90  void
91  erase(Entry* entry)
92  {
93  this->erase(entry, true);
94  }
95 
98  void
99  deleteInOutRecords(Entry* entry, const Face& face);
100 
101 public: // enumeration
103 
110  begin() const;
111 
116  end() const
117  {
118  return Iterator();
119  }
120 
121 private:
122  void
123  erase(Entry* pitEntry, bool canDeleteNte);
124 
133  std::pair<shared_ptr<Entry>, bool>
134  findOrInsert(const Interest& interest, bool allowInsert);
135 
136 private:
137  NameTree& m_nameTree;
138  size_t m_nItems;
139 };
140 
141 } // namespace pit
142 
143 using pit::Pit;
144 
145 } // namespace nfd
146 
147 #endif // NFD_DAEMON_TABLE_PIT_HPP
void erase(Entry *entry)
deletes an entry
Definition: pit.hpp:91
generalization of a network interface
Definition: face.hpp:67
void deleteInOutRecords(Entry *entry, const Face &face)
deletes in-record and out-record for face
Definition: pit.cpp:116
PIT iterator.
Represents an Interest packet.
Definition: interest.hpp:44
Iterator const_iterator
Definition: pit.hpp:102
DataMatchResult findAllDataMatches(const Data &data) const
performs a Data match
Definition: pit.cpp:87
represents the Interest Table
Definition: pit.hpp:47
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:59
std::pair< shared_ptr< Entry >, bool > insert(const Interest &interest)
inserts a PIT entry for Interest
Definition: pit.hpp:77
size_t size() const
Definition: pit.hpp:56
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:38
An unordered iterable of all PIT entries matching Data.
shared_ptr< Entry > find(const Interest &interest) const
finds a PIT entry for Interest
Definition: pit.hpp:66
const_iterator begin() const
Definition: pit.cpp:127
Pit(NameTree &nameTree)
Definition: pit.cpp:37
const_iterator end() const
Definition: pit.hpp:116
Represents a Data packet.
Definition: data.hpp:35