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 
47 };
48 
50  "Name",
51  "FaceId",
52  "Uri",
53  "LocalControlFeature",
54  "Origin",
55  "Cost",
56  "Flags",
57  "Strategy",
58  "ExpirationPeriod",
59 };
60 
67 };
68 
76 {
77 public:
78  class Error : public tlv::Error
79  {
80  public:
81  explicit
82  Error(const std::string& what)
83  : tlv::Error(what)
84  {
85  }
86  };
87 
89 
90  explicit
91  ControlParameters(const Block& block);
92 
93  template<encoding::Tag TAG>
94  size_t
95  wireEncode(EncodingImpl<TAG>& encoder) const;
96 
97  virtual Block
99 
100  virtual void
101  wireDecode(const Block& wire) NDN_CXX_DECL_FINAL;
102 
103 public: // getters & setters
104 
105  bool
106  hasName() const
107  {
108  return m_hasFields[CONTROL_PARAMETER_NAME];
109  }
110 
111  const Name&
112  getName() const
113  {
114  BOOST_ASSERT(this->hasName());
115  return m_name;
116  }
117 
119  setName(const Name& name)
120  {
121  m_wire.reset();
122  m_name = name;
123  m_hasFields[CONTROL_PARAMETER_NAME] = true;
124  return *this;
125  }
126 
129  {
130  m_wire.reset();
131  m_hasFields[CONTROL_PARAMETER_NAME] = false;
132  return *this;
133  }
134 
135  bool
136  hasFaceId() const
137  {
138  return m_hasFields[CONTROL_PARAMETER_FACE_ID];
139  }
140 
141  uint64_t
142  getFaceId() const
143  {
144  BOOST_ASSERT(this->hasFaceId());
145  return m_faceId;
146  }
147 
149  setFaceId(uint64_t faceId)
150  {
151  m_wire.reset();
152  m_faceId = faceId;
153  m_hasFields[CONTROL_PARAMETER_FACE_ID] = true;
154  return *this;
155  }
156 
159  {
160  m_wire.reset();
161  m_hasFields[CONTROL_PARAMETER_FACE_ID] = false;
162  return *this;
163  }
164 
165  bool
166  hasUri() const
167  {
168  return m_hasFields[CONTROL_PARAMETER_URI];
169  }
170 
171  const std::string&
172  getUri() const
173  {
174  BOOST_ASSERT(this->hasUri());
175  return m_uri;
176  }
177 
179  setUri(const std::string& uri)
180  {
181  m_wire.reset();
182  m_uri = uri;
183  m_hasFields[CONTROL_PARAMETER_URI] = true;
184  return *this;
185  }
186 
189  {
190  m_wire.reset();
191  m_hasFields[CONTROL_PARAMETER_URI] = false;
192  return *this;
193  }
194 
195  bool
197  {
198  return m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE];
199  }
200 
203  {
204  BOOST_ASSERT(this->hasLocalControlFeature());
205  return m_localControlFeature;
206  }
207 
210  {
211  m_wire.reset();
212  m_localControlFeature = localControlFeature;
213  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = true;
214  return *this;
215  }
216 
219  {
220  m_wire.reset();
221  m_hasFields[CONTROL_PARAMETER_LOCAL_CONTROL_FEATURE] = false;
222  return *this;
223  }
224 
225  bool
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 
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 
249  {
250  m_wire.reset();
251  m_hasFields[CONTROL_PARAMETER_ORIGIN] = false;
252  return *this;
253  }
254 
255  bool
256  hasCost() const
257  {
258  return m_hasFields[CONTROL_PARAMETER_COST];
259  }
260 
261  uint64_t
262  getCost() const
263  {
264  BOOST_ASSERT(this->hasCost());
265  return m_cost;
266  }
267 
269  setCost(uint64_t cost)
270  {
271  m_wire.reset();
272  m_cost = cost;
273  m_hasFields[CONTROL_PARAMETER_COST] = true;
274  return *this;
275  }
276 
279  {
280  m_wire.reset();
281  m_hasFields[CONTROL_PARAMETER_COST] = false;
282  return *this;
283  }
284 
285  bool
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 
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 
309  {
310  m_wire.reset();
311  m_hasFields[CONTROL_PARAMETER_FLAGS] = false;
312  return *this;
313  }
314 
315  bool
316  hasStrategy() const
317  {
318  return m_hasFields[CONTROL_PARAMETER_STRATEGY];
319  }
320 
321  const Name&
322  getStrategy() const
323  {
324  BOOST_ASSERT(this->hasStrategy());
325  return m_strategy;
326  }
327 
329  setStrategy(const Name& strategy)
330  {
331  m_wire.reset();
332  m_strategy = strategy;
333  m_hasFields[CONTROL_PARAMETER_STRATEGY] = true;
334  return *this;
335  }
336 
339  {
340  m_wire.reset();
341  m_hasFields[CONTROL_PARAMETER_STRATEGY] = false;
342  return *this;
343  }
344 
345  bool
347  {
348  return m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD];
349  }
350 
351  const time::milliseconds&
353  {
354  BOOST_ASSERT(this->hasExpirationPeriod());
355  return m_expirationPeriod;
356  }
357 
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 
369  {
370  m_wire.reset();
371  m_hasFields[CONTROL_PARAMETER_EXPIRATION_PERIOD] = false;
372  return *this;
373  }
374 
375  const std::vector<bool>&
377  {
378  return m_hasFields;
379  }
380 
381 private: // fields
382  std::vector<bool> m_hasFields;
383 
384  Name m_name;
385  uint64_t m_faceId;
386  std::string m_uri;
387  LocalControlFeature m_localControlFeature;
388  uint64_t m_origin;
389  uint64_t m_cost;
390  uint64_t m_flags;
391  Name m_strategy;
392  time::milliseconds m_expirationPeriod;
393 
394 private:
395  mutable Block m_wire;
396 };
397 
398 std::ostream&
399 operator<<(std::ostream& os, const ControlParameters& parameters);
400 
401 } // namespace nfd
402 } // namespace ndn
403 
404 #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
virtual Block wireEncode() const final
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)
const std::vector< bool > & getPresentFields() const
ControlParameters & setLocalControlFeature(LocalControlFeature localControlFeature)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
ControlParameters & unsetExpirationPeriod()
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]
base class for a struct that contains ControlCommand parameters
#define NDN_CXX_DECL_FINAL
expands to &#39;final&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:58
LocalControlFeature getLocalControlFeature() const
ControlParameters & setCost(uint64_t cost)
const time::milliseconds & getExpirationPeriod() const
ControlParameters & setOrigin(uint64_t origin)
ControlParameters & setName(const Name &name)
const std::string & getUri() const
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
ControlParameters & unsetLocalControlFeature()