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