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 
76  const KeyLocatorLite&
77  getKeyLocator() const { return KeyLocatorLite::downCast(keyLocator); }
78 
80  getKeyLocator() { return KeyLocatorLite::downCast(keyLocator); }
81 
83  getExclude() { return ExcludeLite::downCast(exclude); }
84 
85  const ExcludeLite&
86  getExclude() const { return ExcludeLite::downCast(exclude); }
87 
88  int
89  getChildSelector() const { return childSelector; }
90 
95  bool
96  getMustBeFresh() const;
97 
99  getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds; }
100 
101  const BlobLite&
102  getNonce() const { return BlobLite::downCast(nonce); }
103 
104  const BlobLite&
105  getLinkWireEncoding() const { return BlobLite::downCast(linkWireEncoding); }
106 
107  int
108  getSelectedDelegationIndex() const { return selectedDelegationIndex; }
109 
116  ndn_Error
117  setName(const NameLite& name)
118  {
119  return NameLite::downCast(this->name).set(name);
120  }
121 
128  InterestLite&
130  {
131  this->minSuffixComponents = minSuffixComponents;
132  return *this;
133  }
134 
141  InterestLite&
143  {
144  this->maxSuffixComponents = maxSuffixComponents;
145  return *this;
146  }
147 
153  InterestLite&
155  {
156  this->childSelector = childSelector;
157  return *this;
158  }
159 
166  InterestLite&
168 
175  InterestLite&
177  {
178  this->interestLifetimeMilliseconds = interestLifetimeMilliseconds;
179  return *this;
180  }
181 
187  InterestLite&
189  {
190  BlobLite::downCast(this->nonce) = nonce;
191  return *this;
192  }
193 
200  InterestLite&
202  {
203  BlobLite::downCast(this->linkWireEncoding) = linkWireEncoding;
204  return *this;
205  }
206 
213  InterestLite&
215  {
216  this->selectedDelegationIndex = selectedDelegationIndex;
217  return *this;
218  }
219 
226  ndn_Error
227  set(const InterestLite& other);
228 
234  static InterestLite&
235  downCast(ndn_Interest& interest) { return *(InterestLite*)&interest; }
236 
237  static const InterestLite&
238  downCast(const ndn_Interest& interest) { return *(InterestLite*)&interest; }
239 
240 private:
241  // Declare friends who can downcast to the private base.
242  friend class Tlv0_1_1WireFormatLite;
243 
249  InterestLite(const InterestLite& other);
250 
256  InterestLite& operator=(const InterestLite& other);
257 };
258 
259 }
260 
261 #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:111
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
InterestLite & setMustBeFresh(bool mustBeFresh)
Set the MustBeFresh flag.
Definition: interest-lite.cpp:44
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:201
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
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:72
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:51
bool getMustBeFresh() const
Return true if the content must be fresh.
Definition: interest-lite.cpp:38
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:142
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:76
static ExcludeLite & downCast(ndn_Exclude &exclude)
Downcast the reference to the ndn_Exclude struct to an ExcludeLite.
Definition: exclude-lite.hpp:159
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:188
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:216
int minSuffixComponents
-1 for none
Definition: interest-types.h:63
An ExcludeLite holds an array of ExcludeLite::Entry.
Definition: exclude-lite.hpp:33
Copyright (C) 2015-2016 Regents of the University of California.
Definition: name-types.h:33
InterestLite & setSelectedDelegationIndex(int selectedDelegationIndex)
Set the selected delegation index.
Definition: interest-lite.hpp:214
struct ndn_Blob linkWireEncoding
The link whose value is a pointer to a pre-allocated buffer.
Definition: interest-types.h:71
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:235
ndn_Error setName(const NameLite &name)
Set this interest's name to have the values from the given name.
Definition: interest-lite.hpp:117
InterestLite & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest-lite.hpp:129
InterestLite & setChildSelector(int childSelector)
Set the child selector.
Definition: interest-lite.hpp:154
static NameLite & downCast(ndn_Name &name)
Downcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:429
int maxSuffixComponents
-1 for none
Definition: interest-types.h:64
InterestLite & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest-lite.hpp:176