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::upCast(name); }
66 
67  const NameLite&
68  getName() const { return NameLite::upCast(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::upCast(keyLocator); }
78 
80  getKeyLocator() { return KeyLocatorLite::upCast(keyLocator); }
81 
83  getExclude() { return ExcludeLite::upCast(exclude); }
84 
85  const ExcludeLite&
86  getExclude() const { return ExcludeLite::upCast(exclude); }
87 
88  int
89  getChildSelector() const { return childSelector; }
90 
95  bool
96  getMustBeFresh() const;
97 
98  int
99  getScope() const { return scope; }
100 
102  getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds; }
103 
104  const BlobLite&
105  getNonce() const { return BlobLite::upCast(nonce); }
106 
113  ndn_Error
114  setName(const NameLite& name)
115  {
116  return NameLite::upCast(this->name).set(name);
117  }
118 
125  InterestLite&
127  {
128  this->minSuffixComponents = minSuffixComponents;
129  return *this;
130  }
131 
138  InterestLite&
140  {
141  this->maxSuffixComponents = maxSuffixComponents;
142  return *this;
143  }
144 
150  InterestLite&
152  {
153  this->childSelector = childSelector;
154  return *this;
155  }
156 
163  InterestLite&
164  setMustBeFresh(bool mustBeFresh);
165 
171  InterestLite&
173  {
174  this->scope = scope;
175  return *this;
176  }
177 
184  InterestLite&
186  {
187  this->interestLifetimeMilliseconds = interestLifetimeMilliseconds;
188  return *this;
189  }
190 
197  ndn_Error
198  set(const InterestLite& other);
199 
205  static InterestLite&
206  upCast(ndn_Interest& interest) { return *(InterestLite*)&interest; }
207 
208  static const InterestLite&
209  upCast(const ndn_Interest& interest) { return *(InterestLite*)&interest; }
210 
211 private:
212  // Declare friends who can downcast to the private base.
213  friend class Tlv0_1_1WireFormatLite;
214 
220  InterestLite(InterestLite& other);
221  InterestLite(const InterestLite& other);
222 
228  InterestLite& operator=(const InterestLite& other);
229 };
230 
231 }
232 
233 #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:40
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:111
Copyright (C) 2013-2015 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
static KeyLocatorLite & upCast(ndn_KeyLocator &keyLocator)
Upcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:106
int childSelector
-1 for none
Definition: interest-types.h:79
A NameLite holds an array of NameLite::Component.
Definition: name-lite.hpp:34
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:83
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:82
InterestLite & setMaxSuffixComponents(int maxSuffixComponents)
Set the max suffix components count.
Definition: interest-lite.hpp:139
An ndn_Interest holds an ndn_Name and other fields for an interest.
Definition: interest-types.h:70
static BlobLite & upCast(ndn_Blob &blob)
Upcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:69
int scope
-1 for none
Definition: interest-types.h:81
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:181
int minSuffixComponents
-1 for none
Definition: interest-types.h:72
An ExcludeLite holds an array of ExcludeLite::Entry.
Definition: exclude-lite.hpp:33
Copyright (C) 2015 Regents of the University of California.
Definition: name-types.h:33
static ExcludeLite & upCast(ndn_Exclude &exclude)
Upcast the reference to the ndn_Exclude struct to an ExcludeLite.
Definition: exclude-lite.hpp:152
InterestLite & setScope(int scope)
Set the interest scope.
Definition: interest-lite.hpp:172
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
ndn_Error setName(const NameLite &name)
Set this interest's name to have the values from the given name.
Definition: interest-lite.hpp:114
InterestLite & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest-lite.hpp:126
InterestLite & setChildSelector(int childSelector)
Set the child selector.
Definition: interest-lite.hpp:151
static NameLite & upCast(ndn_Name &name)
Upcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:377
int maxSuffixComponents
-1 for none
Definition: interest-types.h:73
InterestLite & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest-lite.hpp:185
static InterestLite & upCast(ndn_Interest &interest)
Upcast the reference to the ndn_Interest struct to a InterestLite.
Definition: interest-lite.hpp:206