NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
nfd-control-parameters.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP
23 #define NDN_MANAGEMENT_NFD_CONTROL_PARAMETERS_HPP
24 
25 #include "../encoding/nfd-constants.hpp"
26 #include "../name.hpp"
27 #include "../util/time.hpp"
28 #include "../mgmt/control-parameters.hpp"
29 
30 namespace ndn {
31 namespace nfd {
32 
48 };
49 
51  "Name",
52  "FaceId",
53  "Uri",
54  "LocalControlFeature",
55  "Origin",
56  "Cost",
57  "Flags",
58  "Strategy",
59  "ExpirationPeriod",
60  "FacePersistency",
61 };
62 
69 };
70 
78 {
79 public:
80  class Error : public tlv::Error
81  {
82  public:
83  explicit
84  Error(const std::string& what)
85  : tlv::Error(what)
86  {
87  }
88  };
89 
91 
92  explicit
93  ControlParameters(const Block& block);
94 
95  template<encoding::Tag TAG>
96  size_t
97  wireEncode(EncodingImpl<TAG>& encoder) const;
98 
99  virtual Block
101 
102  virtual void
103  wireDecode(const Block& wire) NDN_CXX_DECL_FINAL;
104 
105 public: // getters & setters
106 
107  bool
108  hasName() const
109  {
110  return m_hasFields[CONTROL_PARAMETER_NAME];
111  }
112 
113  const Name&
114  getName() const
115  {
116  BOOST_ASSERT(this->hasName());
117  return m_name;
118  }
119 
121  setName(const Name& name)
122  {
123  m_wire.reset();
124  m_name = name;
125  m_hasFields[CONTROL_PARAMETER_NAME] = true;
126  return *this;
127  }
128 
131  {
132  m_wire.reset();
133  m_hasFields[CONTROL_PARAMETER_NAME] = false;
134  return *this;
135  }
136 
137  bool
138  hasFaceId() const
139  {
140  return m_hasFields[CONTROL_PARAMETER_FACE_ID];
141  }
142 
143  uint64_t
144  getFaceId() const
145  {
146  BOOST_ASSERT(this->hasFaceId());
147  return m_faceId;
148  }
149 
151  setFaceId(uint64_t faceId)
152  {
153  m_wire.reset();
154  m_faceId = faceId;
155  m_hasFields[CONTROL_PARAMETER_FACE_ID] = true;
156  return *this;
157  }
158 
161  {
162  m_wire.reset();
163  m_hasFields[CONTROL_PARAMETER_FACE_ID] = false;
164  return *this;
165  }
166 
167  bool
168  hasUri() const
169  {
170  return m_hasFields[CONTROL_PARAMETER_URI];
171  }
172 
173  const std::string&
174  getUri() const
175  {
176  BOOST_ASSERT(this->hasUri());
177  return m_uri;
178  }
179 
181  setUri(const std::string& uri)
182  {
183  m_wire.reset();
184  m_uri = uri;
185  m_hasFields[CONTROL_PARAMETER_URI] = true;
186  return *this;
187  }
188 
191  {
192  m_wire.reset();
193  m_hasFields[CONTROL_PARAMETER_URI] = false;
194  return *this;
195  }
196 
197  bool
199  {
200  return m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE];
201  }
202 
205  {
206  BOOST_ASSERT(this->hasLocalControlFeature());
207  return m_localControlFeature;
208  }
209 
212  {
213  m_wire.reset();
214  m_localControlFeature = localControlFeature;
215  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = true;
216  return *this;
217  }
218 
221  {
222  m_wire.reset();
223  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = false;
224  return *this;
225  }
226 
227  bool
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 
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 
251  {
252  m_wire.reset();
253  m_hasFields[CONTROL_PARAMETER_ORIGIN] = false;
254  return *this;
255  }
256 
257  bool
258  hasCost() const
259  {
260  return m_hasFields[CONTROL_PARAMETER_COST];
261  }
262 
263  uint64_t
264  getCost() const
265  {
266  BOOST_ASSERT(this->hasCost());
267  return m_cost;
268  }
269 
271  setCost(uint64_t cost)
272  {
273  m_wire.reset();
274  m_cost = cost;
275  m_hasFields[CONTROL_PARAMETER_COST] = true;
276  return *this;
277  }
278 
281  {
282  m_wire.reset();
283  m_hasFields[CONTROL_PARAMETER_COST] = false;
284  return *this;
285  }
286 
287  bool
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 
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 
311  {
312  m_wire.reset();
313  m_hasFields[CONTROL_PARAMETER_FLAGS] = false;
314  return *this;
315  }
316 
317  bool
318  hasStrategy() const
319  {
320  return m_hasFields[CONTROL_PARAMETER_STRATEGY];
321  }
322 
323  const Name&
324  getStrategy() const
325  {
326  BOOST_ASSERT(this->hasStrategy());
327  return m_strategy;
328  }
329 
331  setStrategy(const Name& strategy)
332  {
333  m_wire.reset();
334  m_strategy = strategy;
335  m_hasFields[CONTROL_PARAMETER_STRATEGY] = true;
336  return *this;
337  }
338 
341  {
342  m_wire.reset();
343  m_hasFields[CONTROL_PARAMETER_STRATEGY] = false;
344  return *this;
345  }
346 
347  bool
349  {
350  return m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD];
351  }
352 
353  const time::milliseconds&
355  {
356  BOOST_ASSERT(this->hasExpirationPeriod());
357  return m_expirationPeriod;
358  }
359 
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 
371  {
372  m_wire.reset();
373  m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = false;
374  return *this;
375  }
376 
377  bool
379  {
380  return m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY];
381  }
382 
385  {
386  BOOST_ASSERT(this->hasFacePersistency());
387  return m_facePersistency;
388  }
389 
392  {
393  m_wire.reset();
394  m_facePersistency = persistency;
395  m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = true;
396  return *this;
397  }
398 
401  {
402  m_wire.reset();
403  m_hasFields[CONTROL_PARAMETER_FACE_PERSISTENCY] = false;
404  return *this;
405  }
406 
407  const std::vector<bool>&
409  {
410  return m_hasFields;
411  }
412 
413 private: // fields
414  std::vector<bool> m_hasFields;
415 
416  Name m_name;
417  uint64_t m_faceId;
418  std::string m_uri;
419  LocalControlFeature m_localControlFeature;
420  uint64_t m_origin;
421  uint64_t m_cost;
422  uint64_t m_flags;
423  Name m_strategy;
424  time::milliseconds m_expirationPeriod;
425  FacePersistency m_facePersistency;
426 
427 private:
428  mutable Block m_wire;
429 };
430 
431 std::ostream&
432 operator<<(std::ostream& os, const ControlParameters& parameters);
433 
434 } // namespace nfd
435 } // namespace ndn
436 
437 #endif // NDN_MANAGEMENT_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.
represents parameters in a ControlCommand request or response
ControlParameters & setFlags(uint64_t flags)
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
ControlParameters & setUri(const std::string &uri)
ControlParameters & setStrategy(const Name &strategy)
ControlParameters & setExpirationPeriod(const time::milliseconds &expirationPeriod)
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]
const std::vector< bool > & getPresentFields() const
base class for a struct that contains ControlCommand parameters
const std::string & getUri() const
#define NDN_CXX_DECL_FINAL
expands to &#39;final&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:58
ControlParameters & setCost(uint64_t cost)
const time::milliseconds & getExpirationPeriod() const
ControlParameters & setOrigin(uint64_t origin)
ControlParameters & setName(const Name &name)
ControlParameters & setFacePersistency(FacePersistency persistency)
LocalControlFeature getLocalControlFeature() const
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
ControlParameters & unsetLocalControlFeature()