NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
control-parameters.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MGMT_NFD_CONTROL_PARAMETERS_HPP
23 #define NDN_MGMT_NFD_CONTROL_PARAMETERS_HPP
24 
25 #include "../../encoding/nfd-constants.hpp"
26 #include "../../name.hpp"
27 #include "../../util/time.hpp"
28 #include "../control-parameters.hpp"
29 
30 namespace ndn {
31 namespace nfd {
32 
49 };
50 
52  "Name",
53  "FaceId",
54  "Uri",
55  "LocalControlFeature",
56  "Origin",
57  "Cost",
58  "Flags",
59  "Mask",
60  "Strategy",
61  "ExpirationPeriod",
62  "FacePersistency"
63 };
64 
72 };
73 
81 {
82 public:
83  class Error : public tlv::Error
84  {
85  public:
86  explicit
87  Error(const std::string& what)
88  : tlv::Error(what)
89  {
90  }
91  };
92 
94 
95  explicit
96  ControlParameters(const Block& block);
97 
98  template<encoding::Tag TAG>
99  size_t
100  wireEncode(EncodingImpl<TAG>& encoder) const;
101 
102  virtual Block
103  wireEncode() const final;
104 
105  virtual void
106  wireDecode(const Block& wire) final;
107 
108 public: // getters & setters
109  bool
110  hasName() const
111  {
112  return m_hasFields[CONTROL_PARAMETER_NAME];
113  }
114 
115  const Name&
116  getName() const
117  {
118  BOOST_ASSERT(this->hasName());
119  return m_name;
120  }
121 
123  setName(const Name& name)
124  {
125  m_wire.reset();
126  m_name = name;
127  m_hasFields[CONTROL_PARAMETER_NAME] = true;
128  return *this;
129  }
130 
133  {
134  m_wire.reset();
135  m_hasFields[CONTROL_PARAMETER_NAME] = false;
136  return *this;
137  }
138 
139  bool
140  hasFaceId() const
141  {
142  return m_hasFields[CONTROL_PARAMETER_FACE_ID];
143  }
144 
145  uint64_t
146  getFaceId() const
147  {
148  BOOST_ASSERT(this->hasFaceId());
149  return m_faceId;
150  }
151 
153  setFaceId(uint64_t faceId)
154  {
155  m_wire.reset();
156  m_faceId = faceId;
157  m_hasFields[CONTROL_PARAMETER_FACE_ID] = true;
158  return *this;
159  }
160 
163  {
164  m_wire.reset();
165  m_hasFields[CONTROL_PARAMETER_FACE_ID] = false;
166  return *this;
167  }
168 
169  bool
170  hasUri() const
171  {
172  return m_hasFields[CONTROL_PARAMETER_URI];
173  }
174 
175  const std::string&
176  getUri() const
177  {
178  BOOST_ASSERT(this->hasUri());
179  return m_uri;
180  }
181 
183  setUri(const std::string& uri)
184  {
185  m_wire.reset();
186  m_uri = uri;
187  m_hasFields[CONTROL_PARAMETER_URI] = true;
188  return *this;
189  }
190 
193  {
194  m_wire.reset();
195  m_hasFields[CONTROL_PARAMETER_URI] = false;
196  return *this;
197  }
198 
202  bool
204  {
205  return m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE];
206  }
207 
213  {
214  BOOST_ASSERT(this->hasLocalControlFeature());
215  return m_localControlFeature;
216  }
217 
223  {
224  m_wire.reset();
225  m_localControlFeature = localControlFeature;
226  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = true;
227  return *this;
228  }
229 
235  {
236  m_wire.reset();
237  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = false;
238  return *this;
239  }
240 
241  bool
242  hasOrigin() const
243  {
244  return m_hasFields[CONTROL_PARAMETER_ORIGIN];
245  }
246 
247  uint64_t
248  getOrigin() const
249  {
250  BOOST_ASSERT(this->hasOrigin());
251  return m_origin;
252  }
253 
255  setOrigin(uint64_t origin)
256  {
257  m_wire.reset();
258  m_origin = origin;
259  m_hasFields[CONTROL_PARAMETER_ORIGIN] = true;
260  return *this;
261  }
262 
265  {
266  m_wire.reset();
267  m_hasFields[CONTROL_PARAMETER_ORIGIN] = false;
268  return *this;
269  }
270 
271  bool
272  hasCost() const
273  {
274  return m_hasFields[CONTROL_PARAMETER_COST];
275  }
276 
277  uint64_t
278  getCost() const
279  {
280  BOOST_ASSERT(this->hasCost());
281  return m_cost;
282  }
283 
285  setCost(uint64_t cost)
286  {
287  m_wire.reset();
288  m_cost = cost;
289  m_hasFields[CONTROL_PARAMETER_COST] = true;
290  return *this;
291  }
292 
295  {
296  m_wire.reset();
297  m_hasFields[CONTROL_PARAMETER_COST] = false;
298  return *this;
299  }
300 
301  bool
302  hasFlags() const
303  {
304  return m_hasFields[CONTROL_PARAMETER_FLAGS];
305  }
306 
307  uint64_t
308  getFlags() const
309  {
310  BOOST_ASSERT(this->hasFlags());
311  return m_flags;
312  }
313 
315  setFlags(uint64_t flags)
316  {
317  m_wire.reset();
318  m_flags = flags;
319  m_hasFields[CONTROL_PARAMETER_FLAGS] = true;
320  return *this;
321  }
322 
325  {
326  m_wire.reset();
327  m_hasFields[CONTROL_PARAMETER_FLAGS] = false;
328  return *this;
329  }
330 
331  bool
332  hasMask() const
333  {
334  return m_hasFields[CONTROL_PARAMETER_MASK];
335  }
336 
337  uint64_t
338  getMask() const
339  {
340  BOOST_ASSERT(this->hasMask());
341  return m_mask;
342  }
343 
345  setMask(uint64_t mask)
346  {
347  m_wire.reset();
348  m_mask = mask;
349  m_hasFields[CONTROL_PARAMETER_MASK] = true;
350  return *this;
351  }
352 
355  {
356  m_wire.reset();
357  m_hasFields[CONTROL_PARAMETER_MASK] = false;
358  return *this;
359  }
360 
361  bool
362  hasStrategy() const
363  {
364  return m_hasFields[CONTROL_PARAMETER_STRATEGY];
365  }
366 
367  const Name&
368  getStrategy() const
369  {
370  BOOST_ASSERT(this->hasStrategy());
371  return m_strategy;
372  }
373 
375  setStrategy(const Name& strategy)
376  {
377  m_wire.reset();
378  m_strategy = strategy;
379  m_hasFields[CONTROL_PARAMETER_STRATEGY] = true;
380  return *this;
381  }
382 
385  {
386  m_wire.reset();
387  m_hasFields[CONTROL_PARAMETER_STRATEGY] = false;
388  return *this;
389  }
390 
391  bool
393  {
394  return m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD];
395  }
396 
397  const time::milliseconds&
399  {
400  BOOST_ASSERT(this->hasExpirationPeriod());
401  return m_expirationPeriod;
402  }
403 
405  setExpirationPeriod(const time::milliseconds& expirationPeriod)
406  {
407  m_wire.reset();
408  m_expirationPeriod = expirationPeriod;
409  m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = true;
410  return *this;
411  }
412 
415  {
416  m_wire.reset();
417  m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = false;
418  return *this;
419  }
420 
421  bool
423  {
424  return m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY];
425  }
426 
429  {
430  BOOST_ASSERT(this->hasFacePersistency());
431  return m_facePersistency;
432  }
433 
436  {
437  m_wire.reset();
438  m_facePersistency = persistency;
439  m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = true;
440  return *this;
441  }
442 
445  {
446  m_wire.reset();
447  m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = false;
448  return *this;
449  }
450 
451  const std::vector<bool>&
453  {
454  return m_hasFields;
455  }
456 
457 public: // Flags and Mask helpers
462  bool
463  hasFlagBit(size_t bit) const;
464 
469  bool
470  getFlagBit(size_t bit) const;
471 
479  setFlagBit(size_t bit, bool value, bool wantMask = true);
480 
487  unsetFlagBit(size_t bit);
488 
489 private: // fields
490  std::vector<bool> m_hasFields;
491 
492  Name m_name;
493  uint64_t m_faceId;
494  std::string m_uri;
495  LocalControlFeature m_localControlFeature;
496  uint64_t m_origin;
497  uint64_t m_cost;
498  uint64_t m_flags;
499  uint64_t m_mask;
500  Name m_strategy;
501  time::milliseconds m_expirationPeriod;
502  FacePersistency m_facePersistency;
503 
504 private:
505  mutable Block m_wire;
506 };
507 
508 std::ostream&
509 operator<<(std::ostream& os, const ControlParameters& parameters);
510 
511 } // namespace nfd
512 } // namespace ndn
513 
514 #endif // NDN_MGMT_NFD_CONTROL_PARAMETERS_HPP
ControlParameters & setFaceId(uint64_t faceId)
virtual void wireDecode(const Block &wire) final
Copyright (c) 2011-2015 Regents of the University of California.
ControlParameters & unsetStrategy()
represents parameters in a ControlCommand request or response
ControlParameters & setFlags(uint64_t flags)
ControlParameters & unsetFaceId()
ControlParameters & unsetMask()
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
ControlParameters & unsetCost()
ControlParameters & unsetFlags()
ControlParameters & setUri(const std::string &uri)
ControlParameters & unsetOrigin()
ControlParameters & setStrategy(const Name &strategy)
ControlParameters & setExpirationPeriod(const time::milliseconds &expirationPeriod)
ControlParameters & unsetFlagBit(size_t bit)
disable a bit in Mask
FacePersistency getFacePersistency() const
ControlParameters & setLocalControlFeature(LocalControlFeature localControlFeature)
virtual Block wireEncode() const final
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ControlParameters & unsetExpirationPeriod()
ControlParameters & unsetFacePersistency()
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
Name abstraction to represent an absolute name.
Definition: name.hpp:46
const std::string CONTROL_PARAMETER_FIELD[CONTROL_PARAMETER_UBOUND]
bool hasFlagBit(size_t bit) const
const std::vector< bool > & getPresentFields() const
base class for a struct that contains ControlCommand parameters
const std::string & getUri() const
ControlParameters & setCost(uint64_t cost)
const time::milliseconds & getExpirationPeriod() const
ControlParameters & setOrigin(uint64_t origin)
ControlParameters & setName(const Name &name)
ControlParameters & setFacePersistency(FacePersistency persistency)
bool getFlagBit(size_t bit) const
ControlParameters & unsetName()
ControlParameters & unsetUri()
LocalControlFeature getLocalControlFeature() const
const Name & getStrategy() const
ControlParameters & setMask(uint64_t mask)
ControlParameters & setFlagBit(size_t bit, bool value, bool wantMask=true)
set a bit in Flags
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
ControlParameters & unsetLocalControlFeature()