Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 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. |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP |
| 23 | #define NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP |
| 24 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 25 | #include "../encoding/nfd-constants.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 26 | #include "../name.hpp" |
Alexander Afanasyev | 15f6731 | 2014-07-22 15:11:09 -0700 | [diff] [blame] | 27 | #include "../util/time.hpp" |
Yanbiao Li | 8ee37ed | 2015-05-19 12:44:04 -0700 | [diff] [blame] | 28 | #include "../mgmt/control-parameters.hpp" |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace nfd { |
| 32 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 33 | /** |
| 34 | * \ingroup management |
| 35 | */ |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 36 | enum ControlParameterField { |
| 37 | CONTROL_PARAMETER_NAME, |
| 38 | CONTROL_PARAMETER_FACE_ID, |
| 39 | CONTROL_PARAMETER_URI, |
| 40 | CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE, |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 41 | CONTROL_PARAMETER_ORIGIN, |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 42 | CONTROL_PARAMETER_COST, |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 43 | CONTROL_PARAMETER_FLAGS, |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 44 | CONTROL_PARAMETER_STRATEGY, |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 45 | CONTROL_PARAMETER_EXPIRATION_PERIOD, |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 46 | CONTROL_PARAMETER_UBOUND |
| 47 | }; |
| 48 | |
| 49 | const std::string CONTROL_PARAMETER_FIELD[CONTROL_PARAMETER_UBOUND] = { |
| 50 | "Name", |
| 51 | "FaceId", |
| 52 | "Uri", |
| 53 | "LocalControlFeature", |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 54 | "Origin", |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 55 | "Cost", |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 56 | "Flags", |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 57 | "Strategy", |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 58 | "ExpirationPeriod", |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 61 | /** |
| 62 | * \ingroup management |
| 63 | */ |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 64 | enum LocalControlFeature { |
| 65 | LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID = 1, |
| 66 | LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID = 2 |
| 67 | }; |
| 68 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 69 | /** |
Junxiao Shi | 7091165 | 2014-08-12 10:14:24 -0700 | [diff] [blame] | 70 | * @ingroup management |
| 71 | * @brief represents parameters in a ControlCommand request or response |
| 72 | * @sa http://redmine.named-data.net/projects/nfd/wiki/ControlCommand#ControlParameters |
| 73 | * @detail This type is copyable because it's an abstraction of a TLV type. |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 74 | */ |
Yanbiao Li | 8ee37ed | 2015-05-19 12:44:04 -0700 | [diff] [blame] | 75 | class ControlParameters : public ndn::mgmt::ControlParameters |
Junxiao Shi | 7b6b79d | 2014-03-26 20:59:35 -0700 | [diff] [blame] | 76 | { |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 77 | public: |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 78 | class Error : public tlv::Error |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 79 | { |
| 80 | public: |
| 81 | explicit |
| 82 | Error(const std::string& what) |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 83 | : tlv::Error(what) |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 84 | { |
| 85 | } |
| 86 | }; |
| 87 | |
Junxiao Shi | 7091165 | 2014-08-12 10:14:24 -0700 | [diff] [blame] | 88 | ControlParameters(); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 89 | |
| 90 | explicit |
Junxiao Shi | 7091165 | 2014-08-12 10:14:24 -0700 | [diff] [blame] | 91 | ControlParameters(const Block& block); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 92 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 93 | template<encoding::Tag TAG> |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 94 | size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 95 | wireEncode(EncodingImpl<TAG>& encoder) const; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 96 | |
Yanbiao Li | 8ee37ed | 2015-05-19 12:44:04 -0700 | [diff] [blame] | 97 | virtual Block |
| 98 | wireEncode() const NDN_CXX_DECL_FINAL; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 99 | |
Yanbiao Li | 8ee37ed | 2015-05-19 12:44:04 -0700 | [diff] [blame] | 100 | virtual void |
| 101 | wireDecode(const Block& wire) NDN_CXX_DECL_FINAL; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 102 | |
| 103 | public: // getters & setters |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 104 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 105 | bool |
| 106 | hasName() const |
| 107 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 108 | return m_hasFields[CONTROL_PARAMETER_NAME]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | const Name& |
| 112 | getName() const |
| 113 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 114 | BOOST_ASSERT(this->hasName()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 115 | return m_name; |
| 116 | } |
| 117 | |
| 118 | ControlParameters& |
| 119 | setName(const Name& name) |
| 120 | { |
| 121 | m_wire.reset(); |
| 122 | m_name = name; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 123 | m_hasFields[CONTROL_PARAMETER_NAME] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 124 | return *this; |
| 125 | } |
| 126 | |
| 127 | ControlParameters& |
| 128 | unsetName() |
| 129 | { |
| 130 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 131 | m_hasFields[CONTROL_PARAMETER_NAME] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 132 | return *this; |
| 133 | } |
| 134 | |
| 135 | bool |
| 136 | hasFaceId() const |
| 137 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 138 | return m_hasFields[CONTROL_PARAMETER_FACE_ID]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | uint64_t |
| 142 | getFaceId() const |
| 143 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 144 | BOOST_ASSERT(this->hasFaceId()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 145 | return m_faceId; |
| 146 | } |
| 147 | |
| 148 | ControlParameters& |
| 149 | setFaceId(uint64_t faceId) |
| 150 | { |
| 151 | m_wire.reset(); |
| 152 | m_faceId = faceId; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 153 | m_hasFields[CONTROL_PARAMETER_FACE_ID] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 154 | return *this; |
| 155 | } |
| 156 | |
| 157 | ControlParameters& |
| 158 | unsetFaceId() |
| 159 | { |
| 160 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 161 | m_hasFields[CONTROL_PARAMETER_FACE_ID] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 162 | return *this; |
| 163 | } |
| 164 | |
| 165 | bool |
| 166 | hasUri() const |
| 167 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 168 | return m_hasFields[CONTROL_PARAMETER_URI]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | const std::string& |
| 172 | getUri() const |
| 173 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 174 | BOOST_ASSERT(this->hasUri()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 175 | return m_uri; |
| 176 | } |
| 177 | |
| 178 | ControlParameters& |
| 179 | setUri(const std::string& uri) |
| 180 | { |
| 181 | m_wire.reset(); |
| 182 | m_uri = uri; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 183 | m_hasFields[CONTROL_PARAMETER_URI] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 184 | return *this; |
| 185 | } |
| 186 | |
| 187 | ControlParameters& |
| 188 | unsetUri() |
| 189 | { |
| 190 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 191 | m_hasFields[CONTROL_PARAMETER_URI] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 192 | return *this; |
| 193 | } |
| 194 | |
| 195 | bool |
| 196 | hasLocalControlFeature() const |
| 197 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 198 | return m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | LocalControlFeature |
| 202 | getLocalControlFeature() const |
| 203 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 204 | BOOST_ASSERT(this->hasLocalControlFeature()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 205 | return m_localControlFeature; |
| 206 | } |
| 207 | |
| 208 | ControlParameters& |
| 209 | setLocalControlFeature(LocalControlFeature localControlFeature) |
| 210 | { |
| 211 | m_wire.reset(); |
| 212 | m_localControlFeature = localControlFeature; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 213 | m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 214 | return *this; |
| 215 | } |
| 216 | |
| 217 | ControlParameters& |
| 218 | unsetLocalControlFeature() |
| 219 | { |
| 220 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 221 | m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 222 | return *this; |
| 223 | } |
| 224 | |
| 225 | bool |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 226 | hasOrigin() const |
| 227 | { |
| 228 | return m_hasFields[CONTROL_PARAMETER_ORIGIN]; |
| 229 | } |
| 230 | |
| 231 | uint64_t |
| 232 | getOrigin() const |
| 233 | { |
| 234 | BOOST_ASSERT(this->hasOrigin()); |
| 235 | return m_origin; |
| 236 | } |
| 237 | |
| 238 | ControlParameters& |
| 239 | setOrigin(uint64_t origin) |
| 240 | { |
| 241 | m_wire.reset(); |
| 242 | m_origin = origin; |
| 243 | m_hasFields[CONTROL_PARAMETER_ORIGIN] = true; |
| 244 | return *this; |
| 245 | } |
| 246 | |
| 247 | ControlParameters& |
| 248 | unsetOrigin() |
| 249 | { |
| 250 | m_wire.reset(); |
| 251 | m_hasFields[CONTROL_PARAMETER_ORIGIN] = false; |
| 252 | return *this; |
| 253 | } |
| 254 | |
| 255 | bool |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 256 | hasCost() const |
| 257 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 258 | return m_hasFields[CONTROL_PARAMETER_COST]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | uint64_t |
| 262 | getCost() const |
| 263 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 264 | BOOST_ASSERT(this->hasCost()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 265 | return m_cost; |
| 266 | } |
| 267 | |
| 268 | ControlParameters& |
| 269 | setCost(uint64_t cost) |
| 270 | { |
| 271 | m_wire.reset(); |
| 272 | m_cost = cost; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 273 | m_hasFields[CONTROL_PARAMETER_COST] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 274 | return *this; |
| 275 | } |
| 276 | |
| 277 | ControlParameters& |
| 278 | unsetCost() |
| 279 | { |
| 280 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 281 | m_hasFields[CONTROL_PARAMETER_COST] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 282 | return *this; |
| 283 | } |
| 284 | |
| 285 | bool |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 286 | hasFlags() const |
| 287 | { |
| 288 | return m_hasFields[CONTROL_PARAMETER_FLAGS]; |
| 289 | } |
| 290 | |
| 291 | uint64_t |
| 292 | getFlags() const |
| 293 | { |
| 294 | BOOST_ASSERT(this->hasFlags()); |
| 295 | return m_flags; |
| 296 | } |
| 297 | |
| 298 | ControlParameters& |
| 299 | setFlags(uint64_t flags) |
| 300 | { |
| 301 | m_wire.reset(); |
| 302 | m_flags = flags; |
| 303 | m_hasFields[CONTROL_PARAMETER_FLAGS] = true; |
| 304 | return *this; |
| 305 | } |
| 306 | |
| 307 | ControlParameters& |
| 308 | unsetFlags() |
| 309 | { |
| 310 | m_wire.reset(); |
| 311 | m_hasFields[CONTROL_PARAMETER_FLAGS] = false; |
| 312 | return *this; |
| 313 | } |
| 314 | |
| 315 | bool |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 316 | hasStrategy() const |
| 317 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 318 | return m_hasFields[CONTROL_PARAMETER_STRATEGY]; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | const Name& |
| 322 | getStrategy() const |
| 323 | { |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 324 | BOOST_ASSERT(this->hasStrategy()); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 325 | return m_strategy; |
| 326 | } |
| 327 | |
| 328 | ControlParameters& |
| 329 | setStrategy(const Name& strategy) |
| 330 | { |
| 331 | m_wire.reset(); |
| 332 | m_strategy = strategy; |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 333 | m_hasFields[CONTROL_PARAMETER_STRATEGY] = true; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 334 | return *this; |
| 335 | } |
| 336 | |
| 337 | ControlParameters& |
| 338 | unsetStrategy() |
| 339 | { |
| 340 | m_wire.reset(); |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 341 | m_hasFields[CONTROL_PARAMETER_STRATEGY] = false; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 342 | return *this; |
| 343 | } |
| 344 | |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 345 | bool |
| 346 | hasExpirationPeriod() const |
| 347 | { |
| 348 | return m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD]; |
| 349 | } |
| 350 | |
| 351 | const time::milliseconds& |
| 352 | getExpirationPeriod() const |
| 353 | { |
| 354 | BOOST_ASSERT(this->hasExpirationPeriod()); |
| 355 | return m_expirationPeriod; |
| 356 | } |
| 357 | |
| 358 | ControlParameters& |
| 359 | setExpirationPeriod(const time::milliseconds& expirationPeriod) |
| 360 | { |
| 361 | m_wire.reset(); |
| 362 | m_expirationPeriod = expirationPeriod; |
| 363 | m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = true; |
| 364 | return *this; |
| 365 | } |
| 366 | |
| 367 | ControlParameters& |
| 368 | unsetExpirationPeriod() |
| 369 | { |
| 370 | m_wire.reset(); |
| 371 | m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = false; |
| 372 | return *this; |
| 373 | } |
| 374 | |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 375 | const std::vector<bool>& |
| 376 | getPresentFields() const |
| 377 | { |
| 378 | return m_hasFields; |
| 379 | } |
| 380 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 381 | private: // fields |
Junxiao Shi | 5ec8022 | 2014-03-25 20:08:05 -0700 | [diff] [blame] | 382 | std::vector<bool> m_hasFields; |
| 383 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 384 | Name m_name; |
| 385 | uint64_t m_faceId; |
| 386 | std::string m_uri; |
| 387 | LocalControlFeature m_localControlFeature; |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 388 | uint64_t m_origin; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 389 | uint64_t m_cost; |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 390 | uint64_t m_flags; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 391 | Name m_strategy; |
Junxiao Shi | 5f6c74f | 2014-04-18 16:29:44 -0700 | [diff] [blame] | 392 | time::milliseconds m_expirationPeriod; |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 393 | |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 394 | private: |
| 395 | mutable Block m_wire; |
| 396 | }; |
| 397 | |
Junxiao Shi | 7091165 | 2014-08-12 10:14:24 -0700 | [diff] [blame] | 398 | std::ostream& |
| 399 | operator<<(std::ostream& os, const ControlParameters& parameters); |
Junxiao Shi | bc19b37 | 2014-03-23 16:59:25 -0700 | [diff] [blame] | 400 | |
| 401 | } // namespace nfd |
| 402 | } // namespace ndn |
| 403 | |
| 404 | #endif // NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP |