control-parameters-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_CONTROL_PARAMETERS_LITE_HPP
23 #define NDN_CONTROL_PARAMETERS_LITE_HPP
24 
25 #include "common-lite.hpp"
26 #include "name-lite.hpp"
27 #include "forwarding-flags-lite.hpp"
28 #include "../c/control-parameters-types.h"
29 
30 namespace ndn {
31 
38 public:
56  (struct ndn_NameComponent *nameComponents, size_t maxNameComponents,
57  struct ndn_NameComponent *strategyNameComponents,
58  size_t strategyMaxNameComponents);
59 
64  bool
65  getHasName() const { return hasName != 0; }
66 
71  NameLite&
73 
74  const NameLite&
75  getName() const { return NameLite::downCast(name); }
76 
77  int
78  getFaceId() const { return faceId; }
79 
80  const BlobLite&
81  getUri() const { return BlobLite::downCast(uri); }
82 
83  int
84  getLocalControlFeature() const { return localControlFeature; }
85 
86  int
87  getOrigin() const { return origin; }
88 
89  int
90  getCost() const { return cost; }
91 
92  ForwardingFlagsLite&
93  getForwardingFlags() { return ForwardingFlagsLite::downCast(flags); }
94 
95  const ForwardingFlagsLite&
96  getForwardingFlags() const { return ForwardingFlagsLite::downCast(flags); }
97 
98  NameLite&
99  getStrategy() { return NameLite::downCast(strategy); }
100 
101  const NameLite&
102  getStrategy() const { return NameLite::downCast(strategy); }
103 
105  getExpirationPeriod() const { return expirationPeriod; }
106 
112  void
113  setHasName(bool hasName) { this->hasName = hasName ? 1 : 0; }
114 
123  ndn_Error
125  {
126  hasName = 1;
127  return NameLite::downCast(this->name).set(name);
128  }
129 
138  {
139  this->faceId = faceId;
140  return *this;
141  }
142 
151  {
152  BlobLite::downCast(this->uri) = uri;
153  return *this;
154  }
155 
165  {
166  this->localControlFeature = localControlFeature;
167  return *this;
168  }
169 
178  {
179  this->origin = origin;
180  return *this;
181  }
182 
191  {
192  this->cost = cost;
193  return *this;
194  }
195 
205  {
206  ForwardingFlagsLite::downCast(this->flags) = flags;
207  return *this;
208  }
209 
216  ndn_Error
218  {
219  return NameLite::downCast(this->strategy).set(strategy);
220  }
221 
231  {
232  this->expirationPeriod = expirationPeriod;
233  return *this;
234  }
235 
243  ndn_Error
244  set(const ControlParametersLite& other);
245 
252  static ControlParametersLite&
253  downCast(ndn_ControlParameters& controlParameters)
254  {
255  return *(ControlParametersLite*)&controlParameters;
256  }
257 
258  static const ControlParametersLite&
259  downCast(const ndn_ControlParameters& controlParameters)
260  {
261  return *(ControlParametersLite*)&controlParameters;
262  }
263 
264 private:
265  // Declare friends who can downcast to the private base.
266  friend class Tlv0_1_1WireFormatLite;
267 };
268 
269 }
270 
271 #endif
NameLite & getName()
Get the name, if specified.
Definition: control-parameters-lite.hpp:72
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
ControlParametersLite(struct ndn_NameComponent *nameComponents, size_t maxNameComponents, struct ndn_NameComponent *strategyNameComponents, size_t strategyMaxNameComponents)
Create a ControlParametersLite to use the pre-allocated nameComponents and strategyNameComponents, and with default field values.
Definition: control-parameters-lite.cpp:28
ControlParametersLite & setUri(const BlobLite &uri)
Set the URI.
Definition: control-parameters-lite.hpp:150
int cost
-1 for none.
Definition: control-parameters-types.h:50
bool getHasName() const
Check if the name is specified.
Definition: control-parameters-lite.hpp:65
ControlParametersLite & setLocalControlFeature(int localControlFeature)
Set the local control feature value.
Definition: control-parameters-lite.hpp:164
ControlParametersLite & setOrigin(int origin)
Set the origin value.
Definition: control-parameters-lite.hpp:177
static ForwardingFlagsLite & downCast(ndn_ForwardingFlags &forwardingFlags)
Downcast the reference to the ndn_ForwardingFlags struct to a ForwardingFlagsLite.
Definition: forwarding-flags-lite.hpp:90
struct ndn_Name strategy
nComponents == 0 for none.
Definition: control-parameters-types.h:52
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
ndn_Error setStrategy(const NameLite &strategy)
Set the strategy to a copy of the given Name.
Definition: control-parameters-lite.hpp:217
void setHasName(bool hasName)
Set the flag for whether the name is specified.
Definition: control-parameters-lite.hpp:113
int localControlFeature
-1 for none.
Definition: control-parameters-types.h:48
struct ndn_Blob uri
A Blob whose value is a pointer to pre-allocated buffer.
Definition: control-parameters-types.h:46
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:76
ndn_Error set(const NameLite &other)
Set this name to have the values from the other name.
Definition: name-lite.cpp:216
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
static ControlParametersLite & downCast(ndn_ControlParameters &controlParameters)
Downcast the reference to the ndn_ControlParameters struct to a ControlParametersLite.
Definition: control-parameters-lite.hpp:253
ControlParametersLite & setExpirationPeriod(Milliseconds expirationPeriod)
Set the expiration period.
Definition: control-parameters-lite.hpp:230
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
int faceId
-1 for none.
Definition: control-parameters-types.h:45
A ControlParametersLite holds a Name and other fields for a ControlParameters which is used...
Definition: control-parameters-lite.hpp:37
ControlParametersLite & setForwardingFlags(const ForwardingFlagsLite &flags)
Set the ForwardingFlags object to a copy of forwardingFlags.
Definition: control-parameters-lite.hpp:204
ControlParametersLite & setFaceId(int faceId)
Set the Face ID.
Definition: control-parameters-lite.hpp:137
int origin
-1 for none.
Definition: control-parameters-types.h:49
ControlParametersLite & setCost(int cost)
Set the cost value.
Definition: control-parameters-lite.hpp:190
static NameLite & downCast(ndn_Name &name)
Downcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:429
ndn_Error set(const ControlParametersLite &other)
Set this control parameters to have the values from the other control parameters. ...
Definition: control-parameters-lite.cpp:38
An ndn_ControlParameters holds fields for a ControlParameters which is used in the command interest s...
Definition: control-parameters-types.h:42
struct ndn_Name name
Only used if hasName.
Definition: control-parameters-types.h:44
ndn_Error setName(const NameLite &name)
Set the name to have the values from the given name.
Definition: control-parameters-lite.hpp:124
A ForwardingFlagsLite holds the flags which specify how the forwarding daemon should forward an inter...
Definition: forwarding-flags-lite.hpp:35
ndn_Milliseconds expirationPeriod
-1 for none.
Definition: control-parameters-types.h:53