pit-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2022, 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_ENTRY_HPP
27 #define NFD_DAEMON_TABLE_PIT_ENTRY_HPP
28 
29 #include "pit-in-record.hpp"
30 #include "pit-out-record.hpp"
31 
32 #include <list>
33 
34 namespace nfd::name_tree {
35 class Entry;
36 } // namespace nfd::name_tree
37 
38 namespace nfd::pit {
39 
43 using InRecordCollection = std::list<InRecord>;
44 
48 using OutRecordCollection = std::list<OutRecord>;
49 
61 class Entry : public StrategyInfoHost, noncopyable
62 {
63 public:
64  explicit
65  Entry(const Interest& interest);
66 
72  const Interest&
73  getInterest() const
74  {
75  return *m_interest;
76  }
77 
80  const Name&
81  getName() const
82  {
83  return m_interest->getName();
84  }
85 
90  bool
91  canMatch(const Interest& interest, size_t nEqualNameComps = 0) const;
92 
93 public: // in-record
96  const InRecordCollection&
97  getInRecords() const
98  {
99  return m_inRecords;
100  }
101 
107  bool
108  hasInRecords() const
109  {
110  return !m_inRecords.empty();
111  }
112 
113  InRecordCollection::iterator
115  {
116  return m_inRecords.begin();
117  }
118 
119  InRecordCollection::const_iterator
120  in_begin() const
121  {
122  return m_inRecords.begin();
123  }
124 
125  InRecordCollection::iterator
127  {
128  return m_inRecords.end();
129  }
130 
131  InRecordCollection::const_iterator
132  in_end() const
133  {
134  return m_inRecords.end();
135  }
136 
140  InRecordCollection::iterator
141  getInRecord(const Face& face);
142 
146  InRecordCollection::iterator
147  insertOrUpdateInRecord(Face& face, const Interest& interest);
148 
151  void
152  deleteInRecord(const Face& face);
153 
156  void
157  clearInRecords();
158 
159 public: // out-record
162  const OutRecordCollection&
164  {
165  return m_outRecords;
166  }
167 
174  bool
176  {
177  return !m_outRecords.empty();
178  }
179 
180  OutRecordCollection::iterator
182  {
183  return m_outRecords.begin();
184  }
185 
186  OutRecordCollection::const_iterator
187  out_begin() const
188  {
189  return m_outRecords.begin();
190  }
191 
192  OutRecordCollection::iterator
194  {
195  return m_outRecords.end();
196  }
197 
198  OutRecordCollection::const_iterator
199  out_end() const
200  {
201  return m_outRecords.end();
202  }
203 
207  OutRecordCollection::iterator
208  getOutRecord(const Face& face);
209 
213  OutRecordCollection::iterator
214  insertOrUpdateOutRecord(Face& face, const Interest& interest);
215 
218  void
219  deleteOutRecord(const Face& face);
220 
221 public:
226  scheduler::EventId expiryTimer;
227 
230  bool isSatisfied = false;
231 
235  time::milliseconds dataFreshnessPeriod = 0_ms;
236 
237 private:
238  shared_ptr<const Interest> m_interest;
239  InRecordCollection m_inRecords;
240  OutRecordCollection m_outRecords;
241 
242  name_tree::Entry* m_nameTreeEntry = nullptr;
243 
244  friend ::nfd::name_tree::Entry;
245 };
246 
247 } // namespace nfd::pit
248 
249 #endif // NFD_DAEMON_TABLE_PIT_ENTRY_HPP
Base class for an entity onto which StrategyInfo items may be placed.
Generalization of a network interface.
Definition: face.hpp:56
An entry in the name tree.
Represents an entry in the Interest table (PIT).
Definition: pit-entry.hpp:62
time::milliseconds dataFreshnessPeriod
Data freshness period.
Definition: pit-entry.hpp:235
bool canMatch(const Interest &interest, size_t nEqualNameComps=0) const
Definition: pit-entry.cpp:38
InRecordCollection::iterator in_begin()
Definition: pit-entry.hpp:114
const Interest & getInterest() const
Definition: pit-entry.hpp:73
scheduler::EventId expiryTimer
Expiry timer.
Definition: pit-entry.hpp:226
InRecordCollection::const_iterator in_begin() const
Definition: pit-entry.hpp:120
InRecordCollection::iterator in_end()
Definition: pit-entry.hpp:126
OutRecordCollection::iterator out_end()
Definition: pit-entry.hpp:193
OutRecordCollection::const_iterator out_end() const
Definition: pit-entry.hpp:199
InRecordCollection::iterator getInRecord(const Face &face)
Get the in-record for face.
Definition: pit-entry.cpp:51
const InRecordCollection & getInRecords() const
Definition: pit-entry.hpp:97
OutRecordCollection::iterator out_begin()
Definition: pit-entry.hpp:181
bool hasOutRecords() const
Definition: pit-entry.hpp:175
void deleteInRecord(const Face &face)
Delete the in-record for face if it exists.
Definition: pit-entry.cpp:74
Entry(const Interest &interest)
Definition: pit-entry.cpp:32
const Name & getName() const
Definition: pit-entry.hpp:81
InRecordCollection::const_iterator in_end() const
Definition: pit-entry.hpp:132
bool isSatisfied
Indicates whether this PIT entry is satisfied.
Definition: pit-entry.hpp:230
OutRecordCollection::iterator insertOrUpdateOutRecord(Face &face, const Interest &interest)
Insert or update an out-record.
Definition: pit-entry.cpp:97
bool hasInRecords() const
Definition: pit-entry.hpp:108
void clearInRecords()
Delete all in-records.
Definition: pit-entry.cpp:84
InRecordCollection::iterator insertOrUpdateInRecord(Face &face, const Interest &interest)
Insert or update an in-record.
Definition: pit-entry.cpp:58
OutRecordCollection::const_iterator out_begin() const
Definition: pit-entry.hpp:187
const OutRecordCollection & getOutRecords() const
Definition: pit-entry.hpp:163
OutRecordCollection::iterator getOutRecord(const Face &face)
Get the out-record for face.
Definition: pit-entry.cpp:90
void deleteOutRecord(const Face &face)
Delete the out-record for face if it exists.
Definition: pit-entry.cpp:113
Definition: fib.hpp:40
std::list< OutRecord > OutRecordCollection
An unordered collection of out-records.
Definition: pit-entry.hpp:48
std::list< InRecord > InRecordCollection
An unordered collection of in-records.
Definition: pit-entry.hpp:43