control-parameters.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_CONTROL_PARAMETERS_HPP
23 #define NDN_CONTROL_PARAMETERS_HPP
24 
25 #include "name.hpp"
26 #include "forwarding-flags.hpp"
27 #include "encoding/wire-format.hpp"
28 #include "lite/control-parameters-lite.hpp"
29 
30 namespace ndn {
31 
38 public:
40  : hasName_(false), faceId_(-1), localControlFeature_(-1), origin_(-1), cost_(-1),
41  expirationPeriod_(-1.0)
42  {
43  }
44 
45  Blob
46  wireEncode(WireFormat& wireFormat = *WireFormat::getDefaultWireFormat()) const
47  {
48  return wireFormat.encodeControlParameters(*this);
49  }
50 
51  void
52  wireDecode(const uint8_t *input, size_t inputLength, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
53  {
54  wireFormat.decodeControlParameters(*this, input, inputLength);
55  }
56 
57  void
58  wireDecode(const std::vector<uint8_t>& input, WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
59  {
60  wireDecode(&input[0], input.size(), wireFormat);
61  }
62 
63  void
64  wireDecode
65  (const Blob& input,
67  {
68  wireDecode(input.buf(), input.size(), wireFormat);
69  }
70 
79  void
80  get(ControlParametersLite& controlParametersLite) const;
81 
87  void
88  set(const ControlParametersLite& controlParametersLite);
89 
94  bool
95  getHasName() const { return hasName_; }
96 
101  const Name&
102  getName() const { return name_; }
103 
104  int
105  getFaceId() const { return faceId_; }
106 
107  const std::string&
108  getUri() const { return uri_; }
109 
110  int
111  getLocalControlFeature() const { return localControlFeature_; }
112 
113  int
114  getOrigin() const { return origin_; }
115 
116  int
117  getCost() const { return cost_; }
118 
119  ForwardingFlags&
120  getForwardingFlags() { return flags_; }
121 
122  const ForwardingFlags&
123  getForwardingFlags() const { return flags_; }
124 
125  Name&
126  getStrategy() { return strategy_; }
127 
128  const Name&
129  getStrategy() const { return strategy_; }
130 
132  getExpirationPeriod() const { return expirationPeriod_; }
133 
139  void
140  setHasName(bool hasName) { hasName_ = hasName; }
141 
149  setName(const Name& name)
150  {
151  hasName_ = true;
152  name_ = name;
153  return *this;
154  }
155 
162  setFaceId(int faceId)
163  {
164  faceId_ = faceId;
165  return *this;
166  }
167 
174  setUri(const std::string& uri)
175  {
176  uri_ = uri;
177  return *this;
178  }
179 
187  setLocalControlFeature(int localControlFeature)
188  {
189  localControlFeature_ = localControlFeature;
190  return *this;
191  }
192 
199  setOrigin(int origin)
200  {
201  origin_ = origin;
202  return *this;
203  }
204 
211  setCost(int cost)
212  {
213  cost_ = cost;
214  return *this;
215  }
216 
225  {
226  flags_ = flags;
227  return *this;
228  }
229 
236  setStrategy(const Name& strategy)
237  {
238  strategy_ = strategy;
239  return *this;
240  }
241 
250  {
251  expirationPeriod_ = expirationPeriod;
252  return *this;
253  }
254 
255 private:
256  bool hasName_;
257  Name name_;
258  int faceId_;
259  std::string uri_;
260  int localControlFeature_;
261  int origin_;
262  int cost_;
263  ForwardingFlags flags_;
264  Name strategy_;
265  Milliseconds expirationPeriod_;
266 };
267 
268 }
269 
270 #endif
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
const Name & getName() const
Get the name, if specified.
Definition: control-parameters.hpp:102
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
ControlParameters & setLocalControlFeature(int localControlFeature)
Set the local control feature value.
Definition: control-parameters.hpp:187
A ForwardingFlags object holds the flags which specify how the forwarding daemon should forward an in...
Definition: forwarding-flags.hpp:35
ControlParameters & setForwardingFlags(const ForwardingFlags &flags)
Set the ForwardingFlags object to a copy of forwardingFlags.
Definition: control-parameters.hpp:224
ControlParameters & setName(const Name &name)
Set the name.
Definition: control-parameters.hpp:149
ControlParameters & setOrigin(int origin)
Set the origin value.
Definition: control-parameters.hpp:199
ControlParameters & setStrategy(const Name &strategy)
Set the strategy to a copy of the given Name.
Definition: control-parameters.hpp:236
A ControlParameters holds a Name and other fields for a ControlParameters which is used...
Definition: control-parameters.hpp:37
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:159
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:147
A ControlParametersLite holds a Name and other fields for a ControlParameters which is used...
Definition: control-parameters-lite.hpp:37
ControlParameters & setCost(int cost)
Set the cost value.
Definition: control-parameters.hpp:211
ControlParameters & setFaceId(int faceId)
Set the Face ID.
Definition: control-parameters.hpp:162
static WireFormat * getDefaultWireFormat()
Return the default WireFormat used by default encoding and decoding methods which was set with setDef...
Definition: wire-format.cpp:34
ControlParameters & setUri(const std::string &uri)
Set the URI.
Definition: control-parameters.hpp:174
void setHasName(bool hasName)
Set the flag for whether the name is specified.
Definition: control-parameters.hpp:140
Definition: wire-format.hpp:39
ControlParameters & setExpirationPeriod(Milliseconds expirationPeriod)
Set the expiration period.
Definition: control-parameters.hpp:249
void set(const ControlParametersLite &controlParametersLite)
Clear this ControlParameters, and set the values by copying from controlParametersLite.
Definition: control-parameters.cpp:49
bool getHasName() const
Check if the name is specified.
Definition: control-parameters.hpp:95