Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef NDN_SELECTORS_HPP |
| 23 | #define NDN_SELECTORS_HPP |
| 24 | |
| 25 | #include "common.hpp" |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 26 | #include "key-locator.hpp" |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 27 | #include "exclude.hpp" |
| 28 | #include "encoding/encoding-buffer.hpp" |
| 29 | |
| 30 | namespace ndn { |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 31 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 32 | /** |
| 33 | * @brief Abstraction implementing Interest selectors |
| 34 | */ |
| 35 | class Selectors |
| 36 | { |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 37 | public: |
| 38 | Selectors() |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 39 | : m_minSuffixComponents(-1) |
| 40 | , m_maxSuffixComponents(-1) |
| 41 | , m_childSelector(-1) |
| 42 | , m_mustBeFresh(false) |
| 43 | { |
| 44 | } |
| 45 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 46 | /** @deprecated Selectors().setX(...).setY(...) |
| 47 | */ |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 48 | DEPRECATED( |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 49 | Selectors(int minSuffixComponents, int maxSuffixComponents, |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 50 | const Exclude& exclude, |
| 51 | int childSelector, |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 52 | bool mustBeFresh)) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 53 | : m_minSuffixComponents(minSuffixComponents) |
| 54 | , m_maxSuffixComponents(maxSuffixComponents) |
| 55 | , m_exclude(exclude) |
| 56 | , m_childSelector(childSelector) |
| 57 | , m_mustBeFresh(mustBeFresh) |
| 58 | { |
| 59 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 60 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 61 | /** |
| 62 | * @brief Create from wire encoding |
| 63 | */ |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 64 | Selectors(const Block& wire) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 65 | { |
| 66 | wireDecode(wire); |
| 67 | } |
| 68 | |
| 69 | bool |
| 70 | empty() const; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 71 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 72 | /** |
| 73 | * @brief Fast encoding or block size estimation |
| 74 | */ |
| 75 | template<bool T> |
| 76 | size_t |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 77 | wireEncode(EncodingImpl<T>& block) const; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 78 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 79 | /** |
| 80 | * @brief Encode to a wire format |
| 81 | */ |
| 82 | const Block& |
| 83 | wireEncode() const; |
| 84 | |
| 85 | /** |
| 86 | * @brief Decode the input from wire format |
| 87 | */ |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 88 | void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 89 | wireDecode(const Block& wire); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 90 | |
| 91 | /////////////////////////////////////////////////////////////////////////////// |
| 92 | /////////////////////////////////////////////////////////////////////////////// |
| 93 | /////////////////////////////////////////////////////////////////////////////// |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 94 | |
| 95 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 96 | getMinSuffixComponents() const |
| 97 | { |
| 98 | return m_minSuffixComponents; |
| 99 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 100 | |
| 101 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 102 | setMinSuffixComponents(int minSuffixComponents) |
| 103 | { |
| 104 | m_minSuffixComponents = minSuffixComponents; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 105 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 106 | return *this; |
| 107 | } |
| 108 | |
| 109 | // |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 110 | |
| 111 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 112 | getMaxSuffixComponents() const |
| 113 | { |
| 114 | return m_maxSuffixComponents; |
| 115 | } |
| 116 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 117 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 118 | setMaxSuffixComponents(int maxSuffixComponents) |
| 119 | { |
| 120 | m_maxSuffixComponents = maxSuffixComponents; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 121 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 122 | return *this; |
| 123 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 124 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 125 | // |
| 126 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 127 | const KeyLocator& |
| 128 | getPublisherPublicKeyLocator() const |
| 129 | { |
| 130 | return m_publisherPublicKeyLocator; |
| 131 | } |
| 132 | |
| 133 | Selectors& |
| 134 | setPublisherPublicKeyLocator(const KeyLocator& keyLocator) |
| 135 | { |
| 136 | m_publisherPublicKeyLocator = keyLocator; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 137 | m_wire.reset(); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 138 | return *this; |
| 139 | } |
| 140 | |
| 141 | // |
| 142 | |
| 143 | const Exclude& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 144 | getExclude() const |
| 145 | { |
| 146 | return m_exclude; |
| 147 | } |
| 148 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 149 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 150 | setExclude(const Exclude& exclude) |
| 151 | { |
| 152 | m_exclude = exclude; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 153 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 154 | return *this; |
| 155 | } |
| 156 | |
| 157 | // |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 158 | |
| 159 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 160 | getChildSelector() const |
| 161 | { |
| 162 | return m_childSelector; |
| 163 | } |
| 164 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 165 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 166 | setChildSelector(int childSelector) |
| 167 | { |
| 168 | m_childSelector = childSelector; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 169 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 170 | return *this; |
| 171 | } |
| 172 | |
| 173 | // |
| 174 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 175 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 176 | getMustBeFresh() const |
| 177 | { |
| 178 | return m_mustBeFresh; |
| 179 | } |
| 180 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 181 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 182 | setMustBeFresh(bool mustBeFresh) |
| 183 | { |
| 184 | m_mustBeFresh = mustBeFresh; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 185 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 186 | return *this; |
| 187 | } |
| 188 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 189 | public: // EqualityComparable concept |
| 190 | bool |
| 191 | operator==(const Selectors& other) const |
| 192 | { |
| 193 | return wireEncode() == other.wireEncode(); |
| 194 | } |
| 195 | |
| 196 | bool |
| 197 | operator!=(const Selectors& other) const |
| 198 | { |
| 199 | return !(*this == other); |
| 200 | } |
| 201 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 202 | private: |
| 203 | int m_minSuffixComponents; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 204 | int m_maxSuffixComponents; |
| 205 | KeyLocator m_publisherPublicKeyLocator; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 206 | Exclude m_exclude; |
| 207 | int m_childSelector; |
| 208 | bool m_mustBeFresh; |
| 209 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 210 | mutable Block m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | inline bool |
| 214 | Selectors::empty() const |
| 215 | { |
| 216 | return |
| 217 | (m_minSuffixComponents < 0 && |
| 218 | m_maxSuffixComponents < 0 && |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 219 | m_publisherPublicKeyLocator.empty() && |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 220 | m_exclude.empty() && |
| 221 | m_childSelector < 0 && |
| 222 | !m_mustBeFresh); |
| 223 | } |
| 224 | |
| 225 | template<bool T> |
| 226 | inline size_t |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 227 | Selectors::wireEncode(EncodingImpl<T>& block) const |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 228 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 229 | size_t totalLength = 0; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 230 | |
| 231 | // Selectors ::= SELECTORS-TYPE TLV-LENGTH |
| 232 | // MinSuffixComponents? |
| 233 | // MaxSuffixComponents? |
| 234 | // PublisherPublicKeyLocator? |
| 235 | // Exclude? |
| 236 | // ChildSelector? |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 237 | // MustBeFresh? |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 238 | |
| 239 | // (reverse encoding) |
| 240 | |
| 241 | // MustBeFresh |
| 242 | if (getMustBeFresh()) |
| 243 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 244 | totalLength += prependBooleanBlock(block, Tlv::MustBeFresh); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | // ChildSelector |
| 248 | if (getChildSelector() >= 0) |
| 249 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 250 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::ChildSelector, getChildSelector()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | // Exclude |
| 254 | if (!getExclude().empty()) |
| 255 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 256 | totalLength += getExclude().wireEncode(block); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 257 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 258 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 259 | // PublisherPublicKeyLocator |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 260 | if (!getPublisherPublicKeyLocator().empty()) |
| 261 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 262 | totalLength += getPublisherPublicKeyLocator().wireEncode(block); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 265 | // MaxSuffixComponents |
| 266 | if (getMaxSuffixComponents() >= 0) |
| 267 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 268 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::MaxSuffixComponents, |
| 269 | getMaxSuffixComponents()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | // MinSuffixComponents |
| 273 | if (getMinSuffixComponents() >= 0) |
| 274 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 275 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::MinSuffixComponents, |
| 276 | getMinSuffixComponents()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 277 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 278 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 279 | totalLength += block.prependVarNumber(totalLength); |
| 280 | totalLength += block.prependVarNumber(Tlv::Selectors); |
| 281 | return totalLength; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 282 | } |
| 283 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 284 | inline const Block& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 285 | Selectors::wireEncode() const |
| 286 | { |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 287 | if (m_wire.hasWire()) |
| 288 | return m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 289 | |
| 290 | EncodingEstimator estimator; |
| 291 | size_t estimatedSize = wireEncode(estimator); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 292 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 293 | EncodingBuffer buffer(estimatedSize, 0); |
| 294 | wireEncode(buffer); |
| 295 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 296 | m_wire = buffer.block(); |
| 297 | return m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | inline void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 301 | Selectors::wireDecode(const Block& wire) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 302 | { |
| 303 | if (wire.type() != Tlv::Selectors) |
| 304 | throw Tlv::Error("Unexpected TLV type when decoding Selectors"); |
| 305 | |
| 306 | *this = Selectors(); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 307 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 308 | m_wire = wire; |
| 309 | m_wire.parse(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 310 | |
| 311 | // MinSuffixComponents |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 312 | Block::element_const_iterator val = m_wire.find(Tlv::MinSuffixComponents); |
| 313 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 314 | { |
| 315 | m_minSuffixComponents = readNonNegativeInteger(*val); |
| 316 | } |
| 317 | |
| 318 | // MaxSuffixComponents |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 319 | val = m_wire.find(Tlv::MaxSuffixComponents); |
| 320 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 321 | { |
| 322 | m_maxSuffixComponents = readNonNegativeInteger(*val); |
| 323 | } |
| 324 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 325 | // PublisherPublicKeyLocator |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 326 | val = m_wire.find(Tlv::KeyLocator); |
| 327 | if (val != m_wire.elements_end()) |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 328 | { |
| 329 | m_publisherPublicKeyLocator.wireDecode(*val); |
| 330 | } |
| 331 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 332 | // Exclude |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 333 | val = m_wire.find(Tlv::Exclude); |
| 334 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 335 | { |
| 336 | m_exclude.wireDecode(*val); |
| 337 | } |
| 338 | |
| 339 | // ChildSelector |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 340 | val = m_wire.find(Tlv::ChildSelector); |
| 341 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 342 | { |
| 343 | m_childSelector = readNonNegativeInteger(*val); |
| 344 | } |
| 345 | |
| 346 | //MustBeFresh aka AnswerOriginKind |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 347 | val = m_wire.find(Tlv::MustBeFresh); |
| 348 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 349 | { |
| 350 | m_mustBeFresh = true; |
| 351 | } |
| 352 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 353 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 354 | } // namespace ndn |
| 355 | |
| 356 | #endif // NDN_SELECTORS_HPP |