NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
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 }
37 
40 class MeasurementsAccessor : noncopyable
41 {
42 public:
43  MeasurementsAccessor(Measurements& measurements, const StrategyChoice& strategyChoice,
44  const fw::Strategy& strategy);
45 
47 
50  shared_ptr<measurements::Entry>
51  get(const Name& name);
52 
55  shared_ptr<measurements::Entry>
56  get(const fib::Entry& fibEntry);
57 
60  shared_ptr<measurements::Entry>
61  get(const pit::Entry& pitEntry);
62 
66  shared_ptr<measurements::Entry>
67  getParent(const measurements::Entry& child);
68 
71  shared_ptr<measurements::Entry>
72  findLongestPrefixMatch(const Name& name,
73  const measurements::EntryPredicate& pred =
74  measurements::AnyEntry()) const;
75 
78  shared_ptr<measurements::Entry>
79  findLongestPrefixMatch(const pit::Entry& pitEntry,
80  const measurements::EntryPredicate& pred =
81  measurements::AnyEntry()) const;
82 
85  shared_ptr<measurements::Entry>
86  findExactMatch(const Name& name) const;
87 
92  void
93  extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime);
94 
95 private:
99  shared_ptr<measurements::Entry>
100  filter(const shared_ptr<measurements::Entry>& entry) const;
101 
102 private:
103  Measurements& m_measurements;
104  const StrategyChoice& m_strategyChoice;
105  const fw::Strategy* m_strategy;
106 };
107 
108 inline shared_ptr<measurements::Entry>
110 {
111  return this->filter(m_measurements.get(name));
112 }
113 
114 inline shared_ptr<measurements::Entry>
116 {
117  return this->filter(m_measurements.get(fibEntry));
118 }
119 
120 inline shared_ptr<measurements::Entry>
122 {
123  return this->filter(m_measurements.get(pitEntry));
124 }
125 
126 inline shared_ptr<measurements::Entry>
128 {
129  return this->filter(m_measurements.getParent(child));
130 }
131 
132 inline shared_ptr<measurements::Entry>
134  const measurements::EntryPredicate& pred) const
135 {
136  return this->filter(m_measurements.findLongestPrefixMatch(name, pred));
137 }
138 
139 inline shared_ptr<measurements::Entry>
141  const measurements::EntryPredicate& pred) const
142 {
143  return this->filter(m_measurements.findLongestPrefixMatch(pitEntry, pred));
144 }
145 
146 inline shared_ptr<measurements::Entry>
148 {
149  return this->filter(m_measurements.findExactMatch(name));
150 }
151 
152 inline void
154  const time::nanoseconds& lifetime)
155 {
156  m_measurements.extendLifetime(entry, lifetime);
157 }
158 
159 } // namespace nfd
160 
161 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_ACCESSOR_HPP
represents the Strategy Choice table
represents a FIB entry
Definition: fib-entry.hpp:53
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects a Entry
shared_ptr< measurements::Entry > get(const Name &name)
find or insert a Measurements entry for name
represents the Measurements table
represents a Measurements entry
allows Strategy to access portion of Measurements table under its namespace
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
represents a PIT entry
Definition: pit-entry.hpp:69
an EntryPredicate that accepts any Entry
Name abstraction to represent an absolute name.
Definition: name.hpp:46
shared_ptr< measurements::Entry > findExactMatch(const Name &name) const
perform an exact match
represents a forwarding strategy
Definition: strategy.hpp:38
void extendLifetime(measurements::Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
shared_ptr< measurements::Entry > getParent(const measurements::Entry &child)
find or insert a Measurements entry for child&#39;s parent
shared_ptr< measurements::Entry > findLongestPrefixMatch(const Name &name, const measurements::EntryPredicate &pred=measurements::AnyEntry()) const
perform a longest prefix match for name