HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Junxiao Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 24 | */ |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_TABLE_NAME_TREE_HPP |
| 27 | #define NFD_DAEMON_TABLE_NAME_TREE_HPP |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 28 | |
| 29 | #include "common.hpp" |
| 30 | #include "name-tree-entry.hpp" |
| 31 | |
| 32 | namespace nfd { |
| 33 | namespace name_tree { |
| 34 | |
| 35 | /** |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 36 | * \brief Compute the hash value of the given name prefix's WIRE FORMAT |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 37 | */ |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 38 | size_t |
| 39 | computeHash(const Name& prefix); |
| 40 | |
| 41 | /** |
| 42 | * \brief Incrementally compute hash values |
| 43 | * \return Return a vector of hash values, starting from the root prefix |
| 44 | */ |
| 45 | std::vector<size_t> |
| 46 | computeHashSet(const Name& prefix); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 47 | |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 48 | /// a predicate to accept or reject an Entry in find operations |
| 49 | typedef function<bool (const Entry& entry)> EntrySelector; |
| 50 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 51 | /** |
| 52 | * \brief a predicate to accept or reject an Entry and its children |
| 53 | * \return .first indicates whether entry should be accepted; |
| 54 | * .second indicates whether entry's children should be visited |
| 55 | */ |
| 56 | typedef function<std::pair<bool,bool> (const Entry& entry)> EntrySubTreeSelector; |
| 57 | |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 58 | struct AnyEntry { |
| 59 | bool |
| 60 | operator()(const Entry& entry) |
| 61 | { |
| 62 | return true; |
| 63 | } |
| 64 | }; |
| 65 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 66 | struct AnyEntrySubTree { |
| 67 | std::pair<bool, bool> |
| 68 | operator()(const Entry& entry) |
| 69 | { |
| 70 | return std::make_pair(true, true); |
| 71 | } |
| 72 | }; |
| 73 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 74 | } // namespace name_tree |
| 75 | |
| 76 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 77 | * \brief Class Name Tree |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 78 | */ |
| 79 | class NameTree : noncopyable |
| 80 | { |
| 81 | public: |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 82 | class const_iterator; |
| 83 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 84 | explicit |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 85 | NameTree(size_t nBuckets = 1024); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 86 | |
| 87 | ~NameTree(); |
| 88 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 89 | public: // information |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 90 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 91 | * \brief Get the number of occupied entries in the Name Tree |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 92 | */ |
| 93 | size_t |
| 94 | size() const; |
| 95 | |
| 96 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 97 | * \brief Get the number of buckets in the Name Tree (NPHT) |
| 98 | * \details The number of buckets is the one that used to create the hash |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 99 | * table, i.e., m_nBuckets. |
| 100 | */ |
| 101 | size_t |
| 102 | getNBuckets() const; |
| 103 | |
| 104 | /** |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 105 | * \brief Dump all the information stored in the Name Tree for debugging. |
| 106 | */ |
| 107 | void |
| 108 | dump(std::ostream& output) const; |
| 109 | |
| 110 | public: // mutation |
| 111 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 112 | * \brief Look for the Name Tree Entry that contains this name prefix. |
| 113 | * \details Starts from the shortest name prefix, and then increase the |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 114 | * number of name components by one each time. All non-existing Name Tree |
| 115 | * Entries will be created. |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 116 | * \param prefix The querying name prefix. |
| 117 | * \return The pointer to the Name Tree Entry that contains this full name |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 118 | * prefix. |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 119 | * \note Existing iterators are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 120 | */ |
| 121 | shared_ptr<name_tree::Entry> |
| 122 | lookup(const Name& prefix); |
| 123 | |
| 124 | /** |
Junxiao Shi | ee5a444 | 2014-07-27 17:13:43 -0700 | [diff] [blame] | 125 | * \brief Delete a Name Tree Entry if this entry is empty. |
| 126 | * \param entry The entry to be deleted if empty. |
| 127 | * \note This function must be called after a table entry is detached from Name Tree |
| 128 | * entry. The function deletes a Name Tree entry if nothing is attached to it and |
| 129 | * it has no children, then repeats the same process on its ancestors. |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 130 | * \note Existing iterators, except those pointing to deleted entries, are unaffected. |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 131 | */ |
| 132 | bool |
| 133 | eraseEntryIfEmpty(shared_ptr<name_tree::Entry> entry); |
| 134 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 135 | public: // shortcut access |
| 136 | /// get NameTree entry from attached FIB entry |
| 137 | shared_ptr<name_tree::Entry> |
| 138 | get(const fib::Entry& fibEntry) const; |
| 139 | |
| 140 | /// get NameTree entry from attached PIT entry |
| 141 | shared_ptr<name_tree::Entry> |
| 142 | get(const pit::Entry& pitEntry) const; |
| 143 | |
| 144 | /// get NameTree entry from attached Measurements entry |
| 145 | shared_ptr<name_tree::Entry> |
| 146 | get(const measurements::Entry& measurementsEntry) const; |
| 147 | |
| 148 | /// get NameTree entry from attached StrategyChoice entry |
| 149 | shared_ptr<name_tree::Entry> |
| 150 | get(const strategy_choice::Entry& strategyChoiceEntry) const; |
| 151 | |
| 152 | public: // matching |
| 153 | /** |
| 154 | * \brief Exact match lookup for the given name prefix. |
| 155 | * \return a null shared_ptr if this prefix is not found; |
| 156 | * otherwise return the Name Tree Entry address |
| 157 | */ |
| 158 | shared_ptr<name_tree::Entry> |
| 159 | findExactMatch(const Name& prefix) const; |
| 160 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 161 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 162 | * \brief Longest prefix matching for the given name |
| 163 | * \details Starts from the full name string, reduce the number of name component |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 164 | * by one each time, until an Entry is found. |
| 165 | */ |
| 166 | shared_ptr<name_tree::Entry> |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 167 | findLongestPrefixMatch(const Name& prefix, |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 168 | const name_tree::EntrySelector& entrySelector = |
| 169 | name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 170 | |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 171 | shared_ptr<name_tree::Entry> |
| 172 | findLongestPrefixMatch(shared_ptr<name_tree::Entry> entry, |
| 173 | const name_tree::EntrySelector& entrySelector = |
| 174 | name_tree::AnyEntry()) const; |
| 175 | |
Junxiao Shi | 2b73ca3 | 2014-11-17 19:16:08 -0700 | [diff] [blame] | 176 | /** \brief Enumerate all the name prefixes that satisfy the prefix and entrySelector |
| 177 | * \return an unspecified type that have .begin() and .end() methods |
| 178 | * and is usable with range-based for |
| 179 | * |
| 180 | * Example: |
| 181 | * \code{.cpp} |
| 182 | * auto&& allMatches = nt.findAllMatches(Name("/A/B/C")); |
| 183 | * for (const name_tree::Entry& nte : allMatches) { |
| 184 | * ... |
| 185 | * } |
| 186 | * \endcode |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 187 | * \note Iteration order is implementation-specific and is undefined |
| 188 | * \note The returned iterator may get invalidated when NameTree is modified |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 189 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 190 | boost::iterator_range<const_iterator> |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 191 | findAllMatches(const Name& prefix, |
| 192 | const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 193 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 194 | public: // enumeration |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 195 | /** \brief Enumerate all entries, optionally filtered by an EntrySelector. |
| 196 | * \return an unspecified type that have .begin() and .end() methods |
| 197 | * and is usable with range-based for |
| 198 | * |
| 199 | * Example: |
| 200 | * \code{.cpp} |
| 201 | * auto&& enumerable = nt.fullEnumerate(); |
| 202 | * for (const name_tree::Entry& nte : enumerable) { |
| 203 | * ... |
| 204 | * } |
| 205 | * \endcode |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 206 | * \note Iteration order is implementation-specific and is undefined |
| 207 | * \note The returned iterator may get invalidated when NameTree is modified |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 208 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 209 | boost::iterator_range<const_iterator> |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 210 | fullEnumerate(const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 211 | |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 212 | /** \brief Enumerate all entries under a prefix, optionally filtered by an EntrySubTreeSelector. |
| 213 | * \return an unspecified type that have .begin() and .end() methods |
| 214 | * and is usable with range-based for |
| 215 | * |
| 216 | * Example: |
| 217 | * \code{.cpp} |
| 218 | * auto&& enumerable = nt.partialEnumerate(Name("/A/B/C")); |
| 219 | * for (const name_tree::Entry& nte : enumerable) { |
| 220 | * ... |
| 221 | * } |
| 222 | * \endcode |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 223 | * \note Iteration order is implementation-specific and is undefined |
| 224 | * \note The returned iterator may get invalidated when NameTree is modified |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 225 | */ |
Junxiao Shi | 5ccd0c2 | 2014-12-02 23:54:42 -0700 | [diff] [blame] | 226 | boost::iterator_range<const_iterator> |
Junxiao Shi | 4063184 | 2014-03-01 13:52:37 -0700 | [diff] [blame] | 227 | partialEnumerate(const Name& prefix, |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 228 | const name_tree::EntrySubTreeSelector& entrySubTreeSelector = |
| 229 | name_tree::AnyEntrySubTree()) const; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 230 | |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 231 | /** \brief Get an iterator pointing to the first NameTree entry |
| 232 | * \note Iteration order is implementation-specific and is undefined |
| 233 | * \note The returned iterator may get invalidated when NameTree is modified |
| 234 | */ |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 235 | const_iterator |
| 236 | begin() const; |
| 237 | |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 238 | /** \brief Get an iterator referring to the past-the-end FIB entry |
| 239 | * \note Iteration order is implementation-specific and is undefined |
| 240 | * \note The returned iterator may get invalidated when NameTree is modified |
| 241 | */ |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 242 | const_iterator |
| 243 | end() const; |
| 244 | |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 245 | enum IteratorType { |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 246 | FULL_ENUMERATE_TYPE, |
| 247 | PARTIAL_ENUMERATE_TYPE, |
| 248 | FIND_ALL_MATCHES_TYPE |
| 249 | }; |
| 250 | |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 251 | class const_iterator : public std::iterator<std::forward_iterator_tag, const name_tree::Entry> |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 252 | { |
| 253 | public: |
| 254 | friend class NameTree; |
| 255 | |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 256 | const_iterator(); |
| 257 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 258 | const_iterator(NameTree::IteratorType type, |
| 259 | const NameTree& nameTree, |
| 260 | shared_ptr<name_tree::Entry> entry, |
| 261 | const name_tree::EntrySelector& entrySelector = name_tree::AnyEntry(), |
| 262 | const name_tree::EntrySubTreeSelector& entrySubTreeSelector = name_tree::AnyEntrySubTree()); |
| 263 | |
| 264 | ~const_iterator(); |
| 265 | |
| 266 | const name_tree::Entry& |
| 267 | operator*() const; |
| 268 | |
| 269 | shared_ptr<name_tree::Entry> |
| 270 | operator->() const; |
| 271 | |
| 272 | const_iterator |
| 273 | operator++(); |
| 274 | |
| 275 | const_iterator |
| 276 | operator++(int); |
| 277 | |
| 278 | bool |
| 279 | operator==(const const_iterator& other) const; |
| 280 | |
| 281 | bool |
| 282 | operator!=(const const_iterator& other) const; |
| 283 | |
| 284 | private: |
Alexander Afanasyev | 09fc3d9 | 2015-01-03 02:02:37 -0800 | [diff] [blame^] | 285 | const NameTree* m_nameTree; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 286 | shared_ptr<name_tree::Entry> m_entry; |
| 287 | shared_ptr<name_tree::Entry> m_subTreeRoot; |
| 288 | shared_ptr<name_tree::EntrySelector> m_entrySelector; |
| 289 | shared_ptr<name_tree::EntrySubTreeSelector> m_entrySubTreeSelector; |
| 290 | NameTree::IteratorType m_type; |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 291 | bool m_shouldVisitChildren; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 292 | }; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 293 | |
| 294 | private: |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 295 | /** |
| 296 | * \brief Resize the hash table size when its load factor reaches a threshold. |
| 297 | * \details As we are currently using a hand-written hash table implementation |
| 298 | * for the Name Tree, the hash table resize() function should be kept in the |
| 299 | * name-tree.hpp file. |
| 300 | * \param newNBuckets The number of buckets for the new hash table. |
| 301 | */ |
| 302 | void |
| 303 | resize(size_t newNBuckets); |
| 304 | |
| 305 | private: |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 306 | size_t m_nItems; // Number of items being stored |
| 307 | size_t m_nBuckets; // Number of hash buckets |
Haowei Yuan | f52dac7 | 2014-03-24 23:35:03 -0500 | [diff] [blame] | 308 | size_t m_minNBuckets; // Minimum number of hash buckets |
| 309 | double m_enlargeLoadFactor; |
| 310 | size_t m_enlargeThreshold; |
| 311 | int m_enlargeFactor; |
| 312 | double m_shrinkLoadFactor; |
| 313 | size_t m_shrinkThreshold; |
| 314 | double m_shrinkFactor; |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 315 | name_tree::Node** m_buckets; // Name Tree Buckets in the NPHT |
| 316 | shared_ptr<name_tree::Entry> m_end; |
| 317 | const_iterator m_endIterator; |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 318 | |
| 319 | /** |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 320 | * \brief Create a Name Tree Entry if it does not exist, or return the existing |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 321 | * Name Tree Entry address. |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 322 | * \details Called by lookup() only. |
| 323 | * \return The first item is the Name Tree Entry address, the second item is |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 324 | * a bool value indicates whether this is an old entry (false) or a new |
| 325 | * entry (true). |
| 326 | */ |
| 327 | std::pair<shared_ptr<name_tree::Entry>, bool> |
| 328 | insert(const Name& prefix); |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 329 | }; |
| 330 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 331 | inline NameTree::const_iterator::~const_iterator() |
| 332 | { |
| 333 | } |
| 334 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 335 | inline size_t |
| 336 | NameTree::size() const |
| 337 | { |
| 338 | return m_nItems; |
| 339 | } |
| 340 | |
| 341 | inline size_t |
| 342 | NameTree::getNBuckets() const |
| 343 | { |
| 344 | return m_nBuckets; |
| 345 | } |
| 346 | |
Junxiao Shi | efceadc | 2014-03-09 18:52:57 -0700 | [diff] [blame] | 347 | inline shared_ptr<name_tree::Entry> |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 348 | NameTree::get(const fib::Entry& fibEntry) const |
| 349 | { |
| 350 | return fibEntry.m_nameTreeEntry; |
| 351 | } |
| 352 | |
| 353 | inline shared_ptr<name_tree::Entry> |
| 354 | NameTree::get(const pit::Entry& pitEntry) const |
| 355 | { |
| 356 | return pitEntry.m_nameTreeEntry; |
| 357 | } |
| 358 | |
| 359 | inline shared_ptr<name_tree::Entry> |
| 360 | NameTree::get(const measurements::Entry& measurementsEntry) const |
| 361 | { |
| 362 | return measurementsEntry.m_nameTreeEntry; |
| 363 | } |
| 364 | |
| 365 | inline shared_ptr<name_tree::Entry> |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 366 | NameTree::get(const strategy_choice::Entry& strategyChoiceEntry) const |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 367 | { |
Alexander Afanasyev | b303324 | 2014-08-04 11:09:05 -0700 | [diff] [blame] | 368 | return strategyChoiceEntry.m_nameTreeEntry; |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 369 | } |
| 370 | |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 371 | inline NameTree::const_iterator |
| 372 | NameTree::begin() const |
| 373 | { |
Junxiao Shi | 60607c7 | 2014-11-26 22:40:36 -0700 | [diff] [blame] | 374 | return fullEnumerate().begin(); |
Haowei Yuan | e1079fc | 2014-03-08 14:41:25 -0600 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | inline NameTree::const_iterator |
| 378 | NameTree::end() const |
| 379 | { |
| 380 | return m_endIterator; |
| 381 | } |
| 382 | |
| 383 | inline const name_tree::Entry& |
| 384 | NameTree::const_iterator::operator*() const |
| 385 | { |
| 386 | return *m_entry; |
| 387 | } |
| 388 | |
| 389 | inline shared_ptr<name_tree::Entry> |
| 390 | NameTree::const_iterator::operator->() const |
| 391 | { |
| 392 | return m_entry; |
| 393 | } |
| 394 | |
| 395 | inline NameTree::const_iterator |
| 396 | NameTree::const_iterator::operator++(int) |
| 397 | { |
| 398 | NameTree::const_iterator temp(*this); |
| 399 | ++(*this); |
| 400 | return temp; |
| 401 | } |
| 402 | |
| 403 | inline bool |
| 404 | NameTree::const_iterator::operator==(const NameTree::const_iterator& other) const |
| 405 | { |
| 406 | return m_entry == other.m_entry; |
| 407 | } |
| 408 | |
| 409 | inline bool |
| 410 | NameTree::const_iterator::operator!=(const NameTree::const_iterator& other) const |
| 411 | { |
| 412 | return m_entry != other.m_entry; |
| 413 | } |
| 414 | |
HYuan | a9b8575 | 2014-02-26 02:32:30 -0600 | [diff] [blame] | 415 | } // namespace nfd |
| 416 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 417 | #endif // NFD_DAEMON_TABLE_NAME_TREE_HPP |