NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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) const
55  {
56  return true;
57  }
58 };
59 
62 template<typename T>
64 {
65 public:
66  bool
67  operator()(const Entry& entry) const
68  {
69  return entry.getStrategyInfo<T>() != nullptr;
70  }
71 };
72 
75 class Measurements : noncopyable
76 {
77 public:
78  explicit
79  Measurements(NameTree& nametree);
80 
83  Entry&
84  get(const Name& name);
85 
88  Entry&
89  get(const fib::Entry& fibEntry);
90 
93  Entry&
94  get(const pit::Entry& pitEntry);
95 
99  Entry*
100  getParent(const Entry& child);
101 
104  Entry*
105  findLongestPrefixMatch(const Name& name,
106  const EntryPredicate& pred = AnyEntry()) const;
107 
110  Entry*
111  findLongestPrefixMatch(const pit::Entry& pitEntry,
112  const EntryPredicate& pred = AnyEntry()) const;
113 
116  Entry*
117  findExactMatch(const Name& name) const;
118 
119  static time::nanoseconds
120  getInitialLifetime();
121 
126  void
127  extendLifetime(Entry& entry, const time::nanoseconds& lifetime);
128 
129  size_t
130  size() const;
131 
132 private:
133  void
134  cleanup(Entry& entry);
135 
136  Entry&
137  get(name_tree::Entry& nte);
138 
141  template<typename K>
142  Entry*
143  findLongestPrefixMatchImpl(const K& key, const EntryPredicate& pred) const;
144 
145 private:
146  NameTree& m_nameTree;
147  size_t m_nItems;
148 };
149 
150 inline time::nanoseconds
151 Measurements::getInitialLifetime()
152 {
153  return time::seconds(4);
154 }
155 
156 inline size_t
157 Measurements::size() const
158 {
159  return m_nItems;
160 }
161 
162 } // namespace measurements
163 
165 
166 } // namespace nfd
167 
168 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_HPP
represents a FIB entry
Definition: fib-entry.hpp:51
T * getStrategyInfo() const
get a StrategyInfo item
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects an entry
bool operator()(const Entry &entry) const
represents a Measurements entry
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
an EntryPredicate that accepts an entry if it has StrategyInfo of type T
represents the Measurements table
an EntryPredicate that accepts any entry
Represents an absolute name.
Definition: name.hpp:42
bool operator()(const Entry &entry) const
an entry in the name tree