NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
name-tree.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_DAEMON_TABLE_NAME_TREE_HPP
27 #define NFD_DAEMON_TABLE_NAME_TREE_HPP
28 
29 #include "name-tree-iterator.hpp"
30 
31 namespace nfd {
32 namespace name_tree {
33 
36 class NameTree : noncopyable
37 {
38 public:
39  explicit
40  NameTree(size_t nBuckets = 1024);
41 
42 public: // information
45  size_t
46  size() const
47  {
48  return m_ht.size();
49  }
50 
53  size_t
54  getNBuckets() const
55  {
56  return m_ht.getNBuckets();
57  }
58 
62  template<typename ENTRY>
63  Entry*
64  getEntry(const ENTRY& tableEntry) const
65  {
66  return Entry::get(tableEntry);
67  }
68 
69 public: // mutation
76  Entry&
77  lookup(const Name& name);
78 
83  Entry&
84  lookup(const fib::Entry& fibEntry);
85 
90  Entry&
91  lookup(const pit::Entry& pitEntry);
92 
97  Entry&
98  lookup(const measurements::Entry& measurementsEntry);
99 
104  Entry&
105  lookup(const strategy_choice::Entry& strategyChoiceEntry);
106 
117  size_t
118  eraseIfEmpty(Entry* entry, bool canEraseAncestors = true);
119 
120 public: // matching
124  Entry*
125  findExactMatch(const Name& name) const;
126 
132  Entry*
133  findLongestPrefixMatch(const Name& name,
134  const EntrySelector& entrySelector = AnyEntry()) const;
135 
140  Entry*
141  findLongestPrefixMatch(const Entry& entry,
142  const EntrySelector& entrySelector = AnyEntry()) const;
143 
150  template<typename ENTRY>
151  Entry*
152  findLongestPrefixMatch(const ENTRY& tableEntry,
153  const EntrySelector& entrySelector = AnyEntry()) const;
154 
160  Entry*
161  findLongestPrefixMatch(const pit::Entry& pitEntry,
162  const EntrySelector& entrySelector = AnyEntry()) const;
163 
183  Range
184  findAllMatches(const Name& name,
185  const EntrySelector& entrySelector = AnyEntry()) const;
186 
187 public: // enumeration
189 
204  Range
205  fullEnumerate(const EntrySelector& entrySelector = AnyEntry()) const;
206 
224  Range
225  partialEnumerate(const Name& prefix,
226  const EntrySubTreeSelector& entrySubTreeSelector = AnyEntrySubTree()) const;
227 
231  const_iterator
232  begin() const
233  {
234  return fullEnumerate().begin();
235  }
236 
240  const_iterator
241  end() const
242  {
243  return Iterator();
244  }
245 
246 private:
247  Hashtable m_ht;
248 
249  friend class EnumerationImpl;
250 };
251 
252 } // namespace name_tree
253 
254 using name_tree::NameTree;
255 
256 } // namespace nfd
257 
258 #endif // NFD_DAEMON_TABLE_NAME_TREE_HPP
represents a FIB entry
Definition: fib-entry.hpp:51
const_iterator end() const
Definition: name-tree.hpp:241
Entry * findExactMatch(const Name &name) const
exact match lookup
Definition: name-tree.cpp:148
function< std::pair< bool, bool >const Entry &entry)> EntrySubTreeSelector
a predicate to accept or reject an Entry and its children
an EntrySelector that accepts every Entry
an EntrySubTreeSelector that accepts every Entry and its children
a hashtable for fast exact name lookup
Entry * findLongestPrefixMatch(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
longest prefix matching
Definition: name-tree.cpp:155
represents a Measurements entry
Range partialEnumerate(const Name &prefix, const EntrySubTreeSelector &entrySubTreeSelector=AnyEntrySubTree()) const
enumerate all entries under a prefix
Definition: name-tree.cpp:242
Range findAllMatches(const Name &name, const EntrySelector &entrySelector=AnyEntry()) const
all-prefixes match lookup
Definition: name-tree.cpp:223
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
an Interest table entry
Definition: pit-entry.hpp:57
Entry & lookup(const Name &name)
find or insert an entry with specified name
Definition: name-tree.cpp:44
static Entry * get(const ENTRY &tableEntry)
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents a Strategy Choice entry
function< bool(const Entry &entry)> EntrySelector
a predicate to accept or reject an Entry in find operations
Range fullEnumerate(const EntrySelector &entrySelector=AnyEntry()) const
enumerate all entries
Definition: name-tree.cpp:236
NameTree(size_t nBuckets=1024)
Definition: name-tree.cpp:38
size_t eraseIfEmpty(Entry *entry, bool canEraseAncestors=true)
delete the entry if it is empty
Definition: name-tree.cpp:121
a common index structure for FIB, PIT, StrategyChoice, and Measurements
Definition: name-tree.hpp:36
size_t getNBuckets() const
Definition: name-tree.hpp:54
boost::iterator_range< Iterator > Range
a Forward Range of name tree entries
Entry * getEntry(const ENTRY &tableEntry) const
Definition: name-tree.hpp:64
size_t size() const
Definition: name-tree.hpp:46
const_iterator begin() const
Definition: name-tree.hpp:232
enumeration operation implementation
an entry in the name tree