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-2019, 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 = 0;
139 };
140 
141 } // namespace pit
142 
143 using pit::Pit;
144 
145 } // namespace nfd
146 
147 #endif // NFD_DAEMON_TABLE_PIT_HPP
nfd::pit::Pit::begin
const_iterator begin() const
Definition: pit.cpp:126
nfd::name_tree::NameTree
A common index structure for FIB, PIT, StrategyChoice, and Measurements.
Definition: name-tree.hpp:37
nfd::pit::Iterator
PIT iterator.
Definition: pit-iterator.hpp:38
nfd::pit::Pit::size
size_t size() const
Definition: pit.hpp:56
nfd::pit::Pit::insert
std::pair< shared_ptr< Entry >, bool > insert(const Interest &interest)
Inserts a PIT entry for interest.
Definition: pit.hpp:77
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::pit::Pit::deleteInOutRecords
void deleteInOutRecords(Entry *entry, const Face &face)
Deletes in-records and out-records for face.
Definition: pit.cpp:115
pit-entry.hpp
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
pit-iterator.hpp
nfd::pit::Entry
An Interest table entry.
Definition: pit-entry.hpp:59
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
nfd::pit::Pit::Pit
Pit(NameTree &nameTree)
Definition: pit.cpp:37
nfd::pit::Pit::end
const_iterator end() const
Definition: pit.hpp:116
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::pit::Pit::find
shared_ptr< Entry > find(const Interest &interest) const
Finds a PIT entry for interest.
Definition: pit.hpp:66
nfd::pit::Pit
Represents the Interest Table.
Definition: pit.hpp:48
nfd::pit::Pit::const_iterator
Iterator const_iterator
Definition: pit.hpp:102
nfd::pit::Pit::findAllDataMatches
DataMatchResult findAllDataMatches(const Data &data) const
Performs a Data match.
Definition: pit.cpp:86
nfd::pit::DataMatchResult
std::vector< shared_ptr< Entry > > DataMatchResult
Definition: pit.hpp:43
nfd::pit::Pit::erase
void erase(Entry *entry)
Deletes an entry.
Definition: pit.hpp:91