measurements-accessor.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
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 
45 class MeasurementsAccessor : noncopyable
46 {
47 public:
48  MeasurementsAccessor(Measurements& measurements, const StrategyChoice& strategyChoice,
49  const fw::Strategy& strategy);
50 
52 
55  Entry*
56  get(const Name& name);
57 
60  Entry*
61  get(const fib::Entry& fibEntry);
62 
65  Entry*
66  get(const pit::Entry& pitEntry);
67 
70  Entry*
71  getParent(const Entry& child);
72 
75  Entry*
76  findLongestPrefixMatch(const Name& name,
77  const EntryPredicate& pred =
78  AnyEntry()) const;
79 
82  Entry*
83  findLongestPrefixMatch(const pit::Entry& pitEntry,
84  const EntryPredicate& pred =
85  AnyEntry()) const;
86 
89  Entry*
90  findExactMatch(const Name& name) const;
91 
96  void
97  extendLifetime(Entry& entry, const time::nanoseconds& lifetime);
98 
99 private:
103  Entry*
104  filter(Entry* entry) const;
105 
106  Entry*
107  filter(Entry& entry) const;
108 
109 private:
110  Measurements& m_measurements;
111  const StrategyChoice& m_strategyChoice;
112  const fw::Strategy* m_strategy;
113 };
114 
115 inline Entry*
116 MeasurementsAccessor::filter(Entry& entry) const
117 {
118  return this->filter(&entry);
119 }
120 
121 inline Entry*
122 MeasurementsAccessor::get(const Name& name)
123 {
124  return this->filter(m_measurements.get(name));
125 }
126 
127 inline Entry*
128 MeasurementsAccessor::get(const fib::Entry& fibEntry)
129 {
130  return this->filter(m_measurements.get(fibEntry));
131 }
132 
133 inline Entry*
134 MeasurementsAccessor::get(const pit::Entry& pitEntry)
135 {
136  return this->filter(m_measurements.get(pitEntry));
137 }
138 
139 inline Entry*
140 MeasurementsAccessor::getParent(const Entry& child)
141 {
142  return this->filter(m_measurements.getParent(child));
143 }
144 
145 inline Entry*
146 MeasurementsAccessor::findLongestPrefixMatch(const Name& name,
147  const EntryPredicate& pred) const
148 {
149  return this->filter(m_measurements.findLongestPrefixMatch(name, pred));
150 }
151 
152 inline Entry*
153 MeasurementsAccessor::findLongestPrefixMatch(const pit::Entry& pitEntry,
154  const EntryPredicate& pred) const
155 {
156  return this->filter(m_measurements.findLongestPrefixMatch(pitEntry, pred));
157 }
158 
159 inline Entry*
160 MeasurementsAccessor::findExactMatch(const Name& name) const
161 {
162  return this->filter(m_measurements.findExactMatch(name));
163 }
164 
165 inline void
166 MeasurementsAccessor::extendLifetime(Entry& entry, const time::nanoseconds& lifetime)
167 {
168  m_measurements.extendLifetime(entry, lifetime);
169 }
170 
171 } // namespace measurements
172 
174 
175 } // namespace nfd
176 
177 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_ACCESSOR_HPP
represents a Measurements entry
represents a FIB entry
Definition: fib-entry.hpp:51
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects an entry
represents the Measurements table
an Interest table entry
Definition: pit-entry.hpp:57
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
allows Strategy to access portion of Measurements table under its namespace
represents a forwarding strategy
Definition: strategy.hpp:37
an EntryPredicate that accepts any entry