All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
interest-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_INTEREST_LITE_HPP
23 #define NDN_INTEREST_LITE_HPP
24 
25 #include "common-lite.hpp"
26 #include "exclude-lite.hpp"
27 #include "key-locator-lite.hpp"
28 #include "../c/interest-types.h"
29 
30 namespace ndn {
31 
35 class InterestLite : private ndn_Interest {
36 public:
60  (ndn_NameComponent *nameComponents, size_t maxNameComponents,
61  ndn_ExcludeEntry *excludeEntries, size_t maxExcludeEntries,
62  ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents);
63 
64  NameLite&
65  getName() { return NameLite::downCast(name); }
66 
67  const NameLite&
68  getName() const { return NameLite::downCast(name); }
69 
70  int
71  getMinSuffixComponents() const { return minSuffixComponents; }
72 
73  int
74  getMaxSuffixComponents() const { return maxSuffixComponents; }
75 
80  bool
81  getCanBePrefix() const;
82 
83  const KeyLocatorLite&
84  getKeyLocator() const { return KeyLocatorLite::downCast(keyLocator); }
85 
87  getKeyLocator() { return KeyLocatorLite::downCast(keyLocator); }
88 
90  getExclude() { return ExcludeLite::downCast(exclude); }
91 
92  const ExcludeLite&
93  getExclude() const { return ExcludeLite::downCast(exclude); }
94 
95  int
96  getChildSelector() const { return childSelector; }
97 
102  bool
103  getMustBeFresh() const;
104 
106  getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds; }
107 
108  const BlobLite&
109  getNonce() const { return BlobLite::downCast(nonce); }
110 
116  const BlobLite&
118  {
120  }
121 
122  const BlobLite&
123  getLinkWireEncoding() const { return BlobLite::downCast(linkWireEncoding); }
124 
125  int
126  getSelectedDelegationIndex() const { return selectedDelegationIndex; }
127 
134  ndn_Error
135  setName(const NameLite& name)
136  {
137  return NameLite::downCast(this->name).set(name);
138  }
139 
146  InterestLite&
148  {
149  this->minSuffixComponents = minSuffixComponents;
150  return *this;
151  }
152 
159  InterestLite&
161  {
162  this->maxSuffixComponents = maxSuffixComponents;
163  return *this;
164  }
165 
172  InterestLite&
173  setCanBePrefix(bool canBePrefix);
174 
180  InterestLite&
182  {
183  this->childSelector = childSelector;
184  return *this;
185  }
186 
193  InterestLite&
195 
202  InterestLite&
204  {
205  this->interestLifetimeMilliseconds = interestLifetimeMilliseconds;
206  return *this;
207  }
208 
214  InterestLite&
216  {
217  BlobLite::downCast(this->nonce) = nonce;
218  return *this;
219  }
220 
228  InterestLite&
230  {
231  BlobLite::downCast(this->forwardingHintWireEncoding) =
233  return *this;
234  }
235 
242  InterestLite&
244  {
245  BlobLite::downCast(this->linkWireEncoding) = linkWireEncoding;
246  return *this;
247  }
248 
255  InterestLite&
257  {
258  this->selectedDelegationIndex = selectedDelegationIndex;
259  return *this;
260  }
261 
268  ndn_Error
269  set(const InterestLite& other);
270 
276  static InterestLite&
277  downCast(ndn_Interest& interest) { return *(InterestLite*)&interest; }
278 
279  static const InterestLite&
280  downCast(const ndn_Interest& interest) { return *(InterestLite*)&interest; }
281 
282 private:
283  // Declare friends who can downcast to the private base.
284  friend class Tlv0_2WireFormatLite;
285 
291  InterestLite(const InterestLite& other);
292 
298  InterestLite& operator=(const InterestLite& other);
299 };
300 
301 }
302 
303 #endif
An ndn_ExcludeEntry holds an ndn_ExcludeType, and if it is a COMPONENT, it holds a pointer to the com...
Definition: interest-types.h:39
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:114
InterestLite & setMustBeFresh(bool mustBeFresh)
Set the MustBeFresh flag.
Definition: interest-lite.cpp:57
InterestLite & setCanBePrefix(bool canBePrefix)
Set the CanBePrefix flag.
Definition: interest-lite.cpp:50
InterestLite(ndn_NameComponent *nameComponents, size_t maxNameComponents, ndn_ExcludeEntry *excludeEntries, size_t maxExcludeEntries, ndn_NameComponent *keyNameComponents, size_t maxKeyNameComponents)
Create an InterestLite with the pre-allocated nameComponents and excludeEntries, and defaults for all...
Definition: interest-lite.cpp:28
int mustBeFresh
bool.
Definition: interest-types.h:68
int childSelector
-1 for none
Definition: interest-types.h:67
InterestLite & setLinkWireEncoding(const BlobLite &linkWireEncoding)
Set the link wire encoding.
Definition: interest-lite.hpp:243
struct ndn_Blob forwardingHintWireEncoding
The blob whose value is a pointer to a pre-allocated buffer of the encoded sequence of delegation set...
Definition: interest-types.h:71
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:36
InterestLite & setForwardingHintWireEncoding(const BlobLite &forwardingHintWireEncoding)
Set the forwarding hint, encoded as a sequence of delegations without the outer TLV type and length (...
Definition: interest-lite.hpp:229
static KeyLocatorLite & downCast(ndn_KeyLocator &keyLocator)
Downcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:100
int selectedDelegationIndex
-1 for none
Definition: interest-types.h:74
An InterestLite holds a NameLite and other fields for an interest.
Definition: interest-lite.hpp:35
struct ndn_Blob nonce
The blob whose value is a pointer to a pre-allocated buffer.
Definition: interest-types.h:70
ndn_Error set(const InterestLite &other)
Set this interest object to have the values from the other interest.
Definition: interest-lite.cpp:64
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest-lite.cpp:44
ndn_Milliseconds interestLifetimeMilliseconds
-1.0 for none
Definition: interest-types.h:69
InterestLite & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest-lite.hpp:160
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:86
static ExcludeLite & downCast(ndn_Exclude &exclude)
Downcast the reference to the ndn_Exclude struct to an ExcludeLite.
Definition: exclude-lite.hpp:155
An ndn_Interest holds an ndn_Name and other fields for an interest.
Definition: interest-types.h:61
InterestLite & setNonce(const BlobLite &nonce)
Set the interest nonce.
Definition: interest-lite.hpp:215
bool getCanBePrefix() const
Get the CanBePrefix flag.
Definition: interest-lite.cpp:38
A KeyLocatorLite holds a type and other info to represent the key which signs a Data packet...
Definition: key-locator-lite.hpp:34
ndn_Error set(const NameLite &other)
Set this name to have the values from the other name.
Definition: name-lite.cpp:359
int minSuffixComponents
-1 for none
Definition: interest-types.h:63
An ExcludeLite holds an array of ExcludeLite::Entry.
Definition: exclude-lite.hpp:33
An ndn_NameComponent holds a pointer to the component value.
Definition: name-types.h:47
InterestLite & setSelectedDelegationIndex(int selectedDelegationIndex)
Set the selected delegation index.
Definition: interest-lite.hpp:256
struct ndn_Blob linkWireEncoding
The link whose value is a pointer to a pre-allocated buffer.
Definition: interest-types.h:73
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
static InterestLite & downCast(ndn_Interest &interest)
Downcast the reference to the ndn_Interest struct to a InterestLite.
Definition: interest-lite.hpp:277
ndn_Error setName(const NameLite &name)
Set this interest's name to have the values from the given name.
Definition: interest-lite.hpp:135
InterestLite & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest-lite.hpp:147
InterestLite & setChildSelector(int childSelector)
Set the child selector.
Definition: interest-lite.hpp:181
const BlobLite & getForwardingHintWireEncoding() const
Get the forwarding hint, encoded as a sequence of delegations without the outer TLV type and length (...
Definition: interest-lite.hpp:117
static NameLite & downCast(ndn_Name &name)
Downcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:802
int maxSuffixComponents
-1 for none
Definition: interest-types.h:64
InterestLite & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest-lite.hpp:203