measurements-accessor.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_MEASUREMENTS_ACCESSOR_HPP
27 #define NFD_DAEMON_TABLE_MEASUREMENTS_ACCESSOR_HPP
28 
29 #include "measurements.hpp"
30 #include "strategy-choice.hpp"
31 
32 namespace nfd {
33 
34 namespace fw {
35 class Strategy;
36 } // namespace fw
37 
38 namespace measurements {
39 
46 class MeasurementsAccessor : noncopyable
47 {
48 public:
49  MeasurementsAccessor(Measurements& measurements, const StrategyChoice& strategyChoice,
50  const fw::Strategy& strategy);
51 
53 
56  Entry*
57  get(const Name& name);
58 
61  Entry*
62  get(const fib::Entry& fibEntry);
63 
66  Entry*
67  get(const pit::Entry& pitEntry);
68 
71  Entry*
72  getParent(const Entry& child);
73 
76  Entry*
77  findLongestPrefixMatch(const Name& name,
78  const EntryPredicate& pred = AnyEntry()) const;
79 
82  Entry*
83  findLongestPrefixMatch(const pit::Entry& pitEntry,
84  const EntryPredicate& pred = AnyEntry()) const;
85 
88  Entry*
89  findExactMatch(const Name& name) const;
90 
95  void
96  extendLifetime(Entry& entry, const time::nanoseconds& lifetime);
97 
98 private:
102  Entry*
103  filter(Entry* entry) const;
104 
105  Entry*
106  filter(Entry& entry) const;
107 
108 private:
109  Measurements& m_measurements;
110  const StrategyChoice& m_strategyChoice;
111  const fw::Strategy* m_strategy;
112 };
113 
114 inline Entry*
115 MeasurementsAccessor::filter(Entry& entry) const
116 {
117  return this->filter(&entry);
118 }
119 
120 inline Entry*
121 MeasurementsAccessor::get(const Name& name)
122 {
123  return this->filter(m_measurements.get(name));
124 }
125 
126 inline Entry*
128 {
129  return this->filter(m_measurements.get(fibEntry));
130 }
131 
132 inline Entry*
134 {
135  return this->filter(m_measurements.get(pitEntry));
136 }
137 
138 inline Entry*
140 {
141  return this->filter(m_measurements.getParent(child));
142 }
143 
144 inline Entry*
146  const EntryPredicate& pred) const
147 {
148  return this->filter(m_measurements.findLongestPrefixMatch(name, pred));
149 }
150 
151 inline Entry*
153  const EntryPredicate& pred) const
154 {
155  return this->filter(m_measurements.findLongestPrefixMatch(pitEntry, pred));
156 }
157 
158 inline Entry*
160 {
161  return this->filter(m_measurements.findExactMatch(name));
162 }
163 
164 inline void
165 MeasurementsAccessor::extendLifetime(Entry& entry, const time::nanoseconds& lifetime)
166 {
167  m_measurements.extendLifetime(entry, lifetime);
168 }
169 
170 } // namespace measurements
171 
173 
174 } // namespace nfd
175 
176 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_ACCESSOR_HPP
Represents an entry in the FIB.
Definition: fib-entry.hpp:91
Base class of all forwarding strategies.
Definition: strategy.hpp:46
An EntryPredicate that accepts any entry.
Represents an entry in the Measurements table.
Allows fw::Strategy to access the portion of Measurements table under its namespace.
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
Extend lifetime of an entry.
Entry * findLongestPrefixMatch(const Name &name, const EntryPredicate &pred=AnyEntry()) const
Perform a longest prefix match for name.
Entry * getParent(const Entry &child)
Find or insert a Measurements entry for child's parent.
MeasurementsAccessor(Measurements &measurements, const StrategyChoice &strategyChoice, const fw::Strategy &strategy)
Entry * get(const Name &name)
Find or insert a Measurements entry for name.
Entry * findExactMatch(const Name &name) const
Perform an exact match.
The Measurements table.
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
Extend lifetime of an entry.
Entry * getParent(const Entry &child)
Find or insert a parent entry.
Entry & get(const Name &name)
Find or insert an entry by name.
Entry * findExactMatch(const Name &name) const
Perform an exact match.
Entry * findLongestPrefixMatch(const Name &name, const EntryPredicate &pred=AnyEntry()) const
Perform a longest prefix match for name.
Represents an entry in the Interest table (PIT).
Definition: pit-entry.hpp:197
Represents the Strategy Choice table.
std::function< bool(const Entry &)> EntryPredicate
A predicate that accepts or rejects an entry.
-status-http-server
Definition: common.hpp:71