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);
76 BOOST_ASSERT(nte !=
nullptr);
77 return this->
get(*nte);
83 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(pitEntry);
89 return this->
get(*nte);
99 shared_ptr<name_tree::Entry> nteChild = m_nameTree.
get(child);
100 shared_ptr<name_tree::Entry> nte = nteChild->
getParent();
101 BOOST_ASSERT(nte !=
nullptr);
102 return this->
get(*nte);
107 Measurements::findLongestPrefixMatchImpl(
const K& key,
113 return entry !=
nullptr && pred(*entry);
115 if (match !=
nullptr) {
116 return match->getMeasurementsEntry();
125 return this->findLongestPrefixMatchImpl(name, pred);
132 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(pitEntry);
133 return this->findLongestPrefixMatchImpl(nte, pred);
139 shared_ptr<name_tree::Entry> nte = m_nameTree.
lookup(name);
141 return nte->getMeasurementsEntry();
147 const time::nanoseconds& lifetime)
149 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(entry);
150 if (nte ==
nullptr ||
151 nte->getMeasurementsEntry().get() != &entry) {
157 if (entry.m_expiry >= expiry) {
163 entry.m_expiry = expiry;
164 entry.m_cleanup =
scheduler::schedule(lifetime, bind(&Measurements::cleanup,
this, ref(entry)));
168 Measurements::cleanup(
Entry& entry)
170 shared_ptr<name_tree::Entry> nte = m_nameTree.
get(entry);
171 if (nte !=
nullptr) {
172 nte->setMeasurementsEntry(
nullptr);
shared_ptr< Entry > getParent() const
shared_ptr< measurements::Entry > getParent(const measurements::Entry &child)
find or insert a Measurements entry for child's parent
const Name & getName() const
const Name & getPrefix() const
shared_ptr< measurements::Entry > get(const Name &name)
find or insert a Measurements entry for name
void cancel(const EventId &eventId)
cancel a scheduled event
static time_point now() noexcept
shared_ptr< measurements::Entry > findExactMatch(const Name &name) const
perform an exact match
bool eraseEntryIfEmpty(shared_ptr< name_tree::Entry > entry)
Delete a Name Tree Entry if this entry is empty.
std::function< bool(const Entry &)> EntryPredicate
a predicate that accepts or rejects a Entry
shared_ptr< name_tree::Entry > get(const fib::Entry &fibEntry) const
get NameTree entry from FIB entry
const Name & getPrefix() const
shared_ptr< measurements::Entry > getMeasurementsEntry() const
represents a Measurements 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)
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.
size_t size() const
Get the number of components.
static time::nanoseconds getInitialLifetime()
shared_ptr< measurements::Entry > findLongestPrefixMatch(const Name &name, const measurements::EntryPredicate &pred=measurements::AnyEntry()) const
perform a longest prefix match for name
EventId schedule(const time::nanoseconds &after, const Scheduler::Event &event)
schedule an event
bool empty() const
Check if name is emtpy.
Measurements(NameTree &nametree)
void extendLifetime(measurements::Entry &entry, const time::nanoseconds &lifetime)
extend lifetime of an entry