29 #include <boost/concept/assert.hpp> 30 #include <boost/concept_check.hpp> 31 #include <type_traits> 47 size_t depth = enforceMaxDepth ? std::min(name.size(),
getMaxDepth()) : name.size();
50 const Node* node =
nullptr;
51 Entry* parent =
nullptr;
53 for (
size_t prefixLen = 0; prefixLen <= depth; ++prefixLen) {
55 std::tie(node, isNew) = m_ht.
insert(name, prefixLen, hashes);
57 if (isNew && parent !=
nullptr) {
60 parent = &node->
entry;
71 BOOST_ASSERT(fibEntry.
getPrefix().empty());
83 BOOST_ASSERT(nte !=
nullptr);
86 [&pitEntry] (
const shared_ptr<pit::Entry>& pitEntry1) {
87 return pitEntry1.get() == &pitEntry;
96 BOOST_ASSERT(pitEntry.
getName().at(-1).isImplicitSha256Digest());
105 BOOST_ASSERT(nte !=
nullptr);
115 BOOST_ASSERT(nte !=
nullptr);
124 BOOST_ASSERT(entry !=
nullptr);
127 for (
Entry* parent =
nullptr; entry !=
nullptr && entry->
isEmpty(); entry = parent) {
130 if (parent !=
nullptr) {
137 if (!canEraseAncestors) {
151 const Node* node = m_ht.
find(name, std::min(name.size(), prefixLen));
152 return node ==
nullptr ?
nullptr : &node->
entry;
160 for (ssize_t prefixLen = name.size(); prefixLen >= 0; --prefixLen) {
161 const Node* node = m_ht.
find(name, prefixLen, hashes);
162 if (node !=
nullptr && entrySelector(node->
entry)) {
174 while (entry !=
nullptr) {
175 if (entrySelector(*entry)) {
187 BOOST_ASSERT(nte !=
nullptr);
191 for (
size_t prefixLen = nte->
getName().size() + 1; prefixLen <= pitEntry.
getName().size(); ++prefixLen) {
193 if (exact ==
nullptr) {
203 boost::iterator_range<NameTree::const_iterator>
213 return {
Iterator(make_shared<PrefixMatchImpl>(*
this, entrySelector), entry),
end()};
216 boost::iterator_range<NameTree::const_iterator>
219 return {
Iterator(make_shared<FullEnumerationImpl>(*
this, entrySelector),
nullptr),
end()};
222 boost::iterator_range<NameTree::const_iterator>
227 return {
Iterator(make_shared<PartialEnumerationImpl>(*
this, entrySubTreeSelector), entry),
end()};
void unsetParent()
unset parent of this entry
Entry * findLongestPrefixMatch(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
longest prefix matching
represents a Measurements entry
Entry & lookup(const Name &name, bool enforceMaxDepth=false)
find or insert an entry with specified name
size_t eraseIfEmpty(Entry *entry, bool canEraseAncestors=true)
delete the entry if it is empty
Entry * getEntry(const EntryT &tableEntry) const
HashSequence computeHashes(const Name &name, size_t prefixLen)
computes hash values for each prefix of name.getPrefix(prefixLen)
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
Range fullEnumerate(const EntrySelector &entrySelector=AnyEntry()) const
enumerate all entries
void setParent(Entry &entry)
set parent of this entry
strategy_choice::Entry * getStrategyChoiceEntry() const
std::vector< HashValue > HashSequence
a sequence of hash values
Range partialEnumerate(const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const
enumerate all entries under a prefix
const std::vector< shared_ptr< pit::Entry > > & getPitEntries() const
Entry * findExactMatch(const Name &name, size_t prefixLen=std::numeric_limits< size_t >::max()) const
exact match lookup
Entry * getParent() const
static size_t getMaxDepth()
Maximum depth of the name tree.
fib::Entry * getFibEntry() const
const Name & getPrefix() const
provides options for Hashtable
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
std::pair< const Node *, bool > insert(const Name &name, size_t prefixLen, const HashSequence &hashes)
find or insert node for name.getPrefix(prefixLen)
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
const Node * find(const Name &name, size_t prefixLen) const
find node for name.getPrefix(prefixLen)
Node * getNode(const Entry &entry)
an entry in the name tree
represents a Strategy Choice entry
measurements::Entry * getMeasurementsEntry() const
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
void erase(Node *node)
delete node
const Name & getName() const
const Name & getName() const
NameTree(size_t nBuckets=1024)
const_iterator end() const