33 using measurements::Entry;
36 : m_nameTree(nameTree)
48 entry = make_shared<Entry>(nte.
getPrefix());
54 bind(&Measurements::cleanup,
this, ref(*entry)));
62 shared_ptr<name_tree::Entry> nte = m_nameTree.
lookup(name);
63 return this->
get(*nte);
69 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(fibEntry);
70 return this->
get(*nte);
76 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(pitEntry);
77 return this->
get(*nte);
83 if (child.getName().size() == 0) {
87 shared_ptr<name_tree::Entry> nteChild = m_nameTree.
get(child);
88 shared_ptr<name_tree::Entry> nte = nteChild->
getParent();
89 BOOST_ASSERT(nte !=
nullptr);
90 return this->
get(*nte);
95 Measurements::findLongestPrefixMatchImpl(
const K& key,
101 return entry !=
nullptr && pred(*entry);
103 if (match !=
nullptr) {
104 return match->getMeasurementsEntry();
113 return this->findLongestPrefixMatchImpl(name, pred);
120 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(pitEntry);
121 return this->findLongestPrefixMatchImpl(nte, pred);
127 shared_ptr<name_tree::Entry> nte = m_nameTree.
lookup(name);
129 return nte->getMeasurementsEntry();
135 const time::nanoseconds& lifetime)
137 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(entry);
138 if (nte ==
nullptr ||
139 nte->getMeasurementsEntry().get() != &entry) {
145 if (entry.m_expiry >= expiry) {
151 entry.m_expiry = expiry;
152 entry.m_cleanup =
scheduler::schedule(lifetime, bind(&Measurements::cleanup,
this, ref(entry)));
156 Measurements::cleanup(Entry& entry)
158 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(entry);
159 if (nte !=
nullptr) {
160 nte->setMeasurementsEntry(
nullptr);
shared_ptr< measurements::Entry > getParent(const measurements::Entry &child)
find or insert a Measurements entry for child's parent
shared_ptr< measurements::Entry > findLongestPrefixMatch(const Name &name, const measurements::EntryPredicate &pred=measurements::AnyEntry()) const
perform a longest prefix match for name
shared_ptr< measurements::Entry > get(const Name &name)
find or insert a Measurements entry for name
shared_ptr< Entry > getParent() const
void cancel(const EventId &eventId)
cancel a scheduled event
static time_point now() noexcept
bool eraseEntryIfEmpty(shared_ptr< name_tree::Entry > entry)
Delete a Name Tree Entry if this entry is empty.
shared_ptr< name_tree::Entry > get(const fib::Entry &fibEntry) const
get NameTree entry from attached FIB entry
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects a Entry
shared_ptr< name_tree::Entry > findLongestPrefixMatch(const Name &prefix, const name_tree::EntrySelector &entrySelector=name_tree::AnyEntry()) const
Longest prefix matching for the given name.
Copyright (c) 2011-2015 Regents of the University of California.
void setMeasurementsEntry(shared_ptr< measurements::Entry > measurementsEntry)
shared_ptr< measurements::Entry > findExactMatch(const Name &name) const
perform an exact match
EventId schedule(const time::nanoseconds &after, const std::function< void()> &event)
schedule an event
Name abstraction to represent an absolute name.
shared_ptr< name_tree::Entry > lookup(const Name &prefix)
Look for the Name Tree Entry that contains this name prefix.
const Name & getPrefix() const
static time::nanoseconds getInitialLifetime()
Measurements(NameTree &nametree)
void extendLifetime(measurements::Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry
shared_ptr< measurements::Entry > getMeasurementsEntry() const