32 namespace measurements {
35 : m_nameTree(nameTree)
44 if (entry !=
nullptr) {
54 bind(&Measurements::cleanup,
this, ref(*entry)));
63 return this->
get(nte);
70 return this->
get(nte);
77 return this->
get(nte);
89 BOOST_ASSERT(nte !=
nullptr);
90 return &this->
get(*nte);
95 Measurements::findLongestPrefixMatchImpl(
const K& key,
const EntryPredicate& pred)
const 100 return entry !=
nullptr && pred(*entry);
102 if (match !=
nullptr) {
111 return this->findLongestPrefixMatchImpl(name, pred);
117 return this->findLongestPrefixMatchImpl(pitEntry, pred);
130 BOOST_ASSERT(m_nameTree.getEntry(entry) !=
nullptr);
132 time::steady_clock::TimePoint expiry = time::steady_clock::now() + lifetime;
133 if (entry.m_expiry >= expiry) {
139 entry.m_expiry = expiry;
140 entry.m_cleanup =
scheduler::schedule(lifetime, bind(&Measurements::cleanup,
this, ref(entry)));
144 Measurements::cleanup(
Entry& entry)
147 BOOST_ASSERT(nte !=
nullptr);
150 m_nameTree.eraseIfEmpty(nte);
const Name & getName() const
Entry & get(const Name &name)
find or insert a Measurements entry for name
represents a Measurements entry
void cancel(const EventId &eventId)
cancel a scheduled event
void setMeasurementsEntry(unique_ptr< measurements::Entry > measurementsEntry)
Entry * findLongestPrefixMatch(const Name &name, const EntryPredicate &pred=AnyEntry()) const
perform a longest prefix match for name
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects an entry
Entry * findExactMatch(const Name &name) const
perform an exact match
Entry * getParent(const Entry &child)
find or insert a Measurements entry for child's parent
Entry * getParent() const
static time::nanoseconds getInitialLifetime()
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Measurements(NameTree &nametree)
an entry in the name tree
measurements::Entry * getMeasurementsEntry() const
EventId schedule(time::nanoseconds after, const EventCallback &event)
schedule an event
const Name & getName() const
void extendLifetime(Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry