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 
99  getInterestLifetimeMilliseconds() const { return interestLifetimeMilliseconds; }
100 
101  const BlobLite&
102  getNonce() const { return BlobLite::upCast(nonce); }
103 
110  ndn_Error
111  setName(const NameLite& name)
112  {
113  return NameLite::upCast(this->name).set(name);
114  }
115 
122  InterestLite&
124  {
125  this->minSuffixComponents = minSuffixComponents;
126  return *this;
127  }
128 
135  InterestLite&
137  {
138  this->maxSuffixComponents = maxSuffixComponents;
139  return *this;
140  }
141 
147  InterestLite&
149  {
150  this->childSelector = childSelector;
151  return *this;
152  }
153 
160  InterestLite&
162 
169  InterestLite&
171  {
172  this->interestLifetimeMilliseconds = interestLifetimeMilliseconds;
173  return *this;
174  }
175 
181  InterestLite&
183  {
184  BlobLite::upCast(this->nonce) = nonce;
185  return *this;
186  }
187 
194  ndn_Error
195  set(const InterestLite& other);
196 
202  static InterestLite&
203  upCast(ndn_Interest& interest) { return *(InterestLite*)&interest; }
204 
205  static const InterestLite&
206  upCast(const ndn_Interest& interest) { return *(InterestLite*)&interest; }
207 
208 private:
209  // Declare friends who can downcast to the private base.
210  friend class Tlv0_1_1WireFormatLite;
211 
217  InterestLite(InterestLite& other);
218  InterestLite(const InterestLite& other);
219 
225  InterestLite& operator=(const InterestLite& other);
226 };
227 
228 }
229 
230 #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
static KeyLocatorLite & upCast(ndn_KeyLocator &keyLocator)
Upcast the reference to the ndn_KeyLocator struct to a KeyLocatorLite.
Definition: key-locator-lite.hpp:100
int mustBeFresh
bool.
Definition: interest-types.h:68
int childSelector
-1 for none
Definition: interest-types.h:67
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: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:136
An ndn_Interest holds an ndn_Name and other fields for an interest.
Definition: interest-types.h:61
static BlobLite & upCast(ndn_Blob &blob)
Upcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:69
InterestLite & setNonce(const BlobLite &nonce)
Set the interest nonce.
Definition: interest-lite.hpp:182
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:186
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
static ExcludeLite & upCast(ndn_Exclude &exclude)
Upcast the reference to the ndn_Exclude struct to an ExcludeLite.
Definition: exclude-lite.hpp:159
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:111
InterestLite & setMinSuffixComponents(int minSuffixComponents)
Set the min suffix components count.
Definition: interest-lite.hpp:123
InterestLite & setChildSelector(int childSelector)
Set the child selector.
Definition: interest-lite.hpp:148
static NameLite & upCast(ndn_Name &name)
Upcast the reference to the ndn_Name struct to a NameLite.
Definition: name-lite.hpp:384
int maxSuffixComponents
-1 for none
Definition: interest-types.h:64
InterestLite & setInterestLifetimeMilliseconds(Milliseconds interestLifetimeMilliseconds)
Set the interest lifetime.
Definition: interest-lite.hpp:170
static InterestLite & upCast(ndn_Interest &interest)
Upcast the reference to the ndn_Interest struct to a InterestLite.
Definition: interest-lite.hpp:203