NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
measurements.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_HPP
27 #define NFD_DAEMON_TABLE_MEASUREMENTS_HPP
28 
29 #include "measurements-entry.hpp"
30 #include "name-tree.hpp"
31 
32 namespace nfd {
33 
34 namespace fib {
35 class Entry;
36 } // namespace fib
37 
38 namespace pit {
39 class Entry;
40 } // namespace pit
41 
42 namespace measurements {
43 
46 typedef std::function<bool(const Entry&)> EntryPredicate;
47 
50 class AnyEntry
51 {
52 public:
53  bool
54  operator()(const Entry& entry)
55  {
56  return true;
57  }
58 };
59 
60 template<typename T>
62 {
63 public:
64  bool
65  operator()(const Entry& entry)
66  {
67  return entry.getStrategyInfo<T>() != nullptr;
68  }
69 };
70 
71 } // namespace measurements
72 
75 class Measurements : noncopyable
76 {
77 public:
78  explicit
79  Measurements(NameTree& nametree);
80 
83  shared_ptr<measurements::Entry>
84  get(const Name& name);
85 
88  shared_ptr<measurements::Entry>
89  get(const fib::Entry& fibEntry);
90 
93  shared_ptr<measurements::Entry>
94  get(const pit::Entry& pitEntry);
95 
99  shared_ptr<measurements::Entry>
100  getParent(const measurements::Entry& child);
101 
104  shared_ptr<measurements::Entry>
105  findLongestPrefixMatch(const Name& name,
106  const measurements::EntryPredicate& pred =
107  measurements::AnyEntry()) const;
108 
111  shared_ptr<measurements::Entry>
112  findLongestPrefixMatch(const pit::Entry& pitEntry,
113  const measurements::EntryPredicate& pred =
114  measurements::AnyEntry()) const;
115 
118  shared_ptr<measurements::Entry>
119  findExactMatch(const Name& name) const;
120 
121  static time::nanoseconds
122  getInitialLifetime();
123 
128  void
129  extendLifetime(measurements::Entry& entry, const time::nanoseconds& lifetime);
130 
131  size_t
132  size() const;
133 
134 private:
135  void
136  cleanup(measurements::Entry& entry);
137 
138  shared_ptr<measurements::Entry>
139  get(name_tree::Entry& nte);
140 
143  template<typename K>
144  shared_ptr<measurements::Entry>
145  findLongestPrefixMatchImpl(const K& key, const measurements::EntryPredicate& pred) const;
146 
147 private:
148  NameTree& m_nameTree;
149  size_t m_nItems;
150 };
151 
152 inline time::nanoseconds
154 {
155  return time::seconds(4);
156 }
157 
158 inline size_t
160 {
161  return m_nItems;
162 }
163 
164 } // namespace nfd
165 
166 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_HPP
represents a FIB entry
Definition: fib-entry.hpp:53
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects a Entry
represents the Measurements table
represents a Measurements entry
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
represents a PIT entry
Definition: pit-entry.hpp:67
Class Name Tree.
Definition: name-tree.hpp:79
an EntryPredicate that accepts any Entry
Name abstraction to represent an absolute name.
Definition: name.hpp:46
static time::nanoseconds getInitialLifetime()
size_t size() const
bool operator()(const Entry &entry)
Name Tree Entry Class.
shared_ptr< T > getStrategyInfo() const
get a StrategyInfo item