NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: 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*
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
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
152 {
153  return time::seconds(4);
154 }
155 
156 inline size_t
158 {
159  return m_nItems;
160 }
161 
162 } // namespace measurements
163 
165 
166 } // namespace nfd
167 
168 #endif // NFD_DAEMON_TABLE_MEASUREMENTS_HPP
Entry * findExactMatch(const Name &name) const
perform an exact match
represents a FIB entry
Definition: fib-entry.hpp:51
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects an entry
Entry * findLongestPrefixMatch(const Name &name, const EntryPredicate &pred=AnyEntry()) const
perform a longest prefix match for name
represents a Measurements entry
Entry * getParent(const Entry &child)
find or insert a Measurements entry for child&#39;s parent
bool operator()(const Entry &entry) const
bool operator()(const Entry &entry) const
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
an EntryPredicate that accepts an entry if it has StrategyInfo of type T
Measurements(NameTree &nametree)
represents the Measurements table
an EntryPredicate that accepts any entry
Represents an absolute name.
Definition: name.hpp:42
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:36
static time::nanoseconds getInitialLifetime()
an entry in the name tree
T * getStrategyInfo() const
get a StrategyInfo item