Jeff Thompson | 47eecfc | 2013-07-07 22:56:46 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @author: Jeff Thompson |
| 3 | * See COPYING for copyright and distribution information. |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef NDN_INTEREST_HPP |
| 7 | #define NDN_INTEREST_HPP |
| 8 | |
| 9 | #include <vector> |
| 10 | #include "Name.hpp" |
| 11 | #include "c/Interest.h" |
| 12 | |
| 13 | namespace ndn { |
| 14 | |
| 15 | class Interest { |
| 16 | public: |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 17 | void encode(std::vector<unsigned char> &output, WireFormat &wireFormat) const |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 18 | { |
| 19 | wireFormat.encodeInterest(*this, output); |
| 20 | } |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 21 | void encode(std::vector<unsigned char> &output) const |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 22 | { |
| 23 | encode(output, BinaryXMLWireFormat::instance()); |
| 24 | } |
| 25 | void decode(const unsigned char *input, unsigned int inputLength, WireFormat &wireFormat) |
| 26 | { |
| 27 | wireFormat.decodeInterest(*this, input, inputLength); |
| 28 | } |
| 29 | void decode(const unsigned char *input, unsigned int inputLength) |
| 30 | { |
| 31 | decode(input, inputLength, BinaryXMLWireFormat::instance()); |
| 32 | } |
| 33 | void decode(const std::vector<unsigned char> &input, WireFormat &wireFormat) |
| 34 | { |
| 35 | decode(&input[0], input.size(), wireFormat); |
| 36 | } |
| 37 | void decode(const std::vector<unsigned char> &input) |
| 38 | { |
| 39 | decode(&input[0], input.size()); |
| 40 | } |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Set the interestStruct to point to the components in this interest, without copying any memory. |
| 44 | * WARNING: The resulting pointers in interestStruct are invalid after a further use of this object which could reallocate memory. |
| 45 | * @param interestStruct a C ndn_Interest struct where the name components array is already allocated. |
| 46 | */ |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 47 | void get(struct ndn_Interest &interestStruct) const; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 48 | |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 49 | const Name &getName() const { return name_; } |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 50 | |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 51 | int getMinSuffixComponents() const { return minSuffixComponents_; } |
| 52 | |
| 53 | int getMaxSuffixComponents() const { return maxSuffixComponents_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 54 | |
| 55 | const std::vector<unsigned char> getPublisherPublicKeyDigest() const { return publisherPublicKeyDigest_; } |
| 56 | |
| 57 | // TODO: Implement getExclude().) |
| 58 | |
| 59 | int getChildSelector() const { return childSelector_; } |
| 60 | |
| 61 | int getAnswerOriginKind() const { return answerOriginKind_; } |
| 62 | |
| 63 | int getScope() const { return scope_; } |
Jeff Thompson | d345a5b | 2013-07-08 16:18:23 -0700 | [diff] [blame] | 64 | |
| 65 | int getInterestLifetime() const { return interestLifetime_; } |
Jeff Thompson | 0a68172 | 2013-07-08 16:21:54 -0700 | [diff] [blame] | 66 | |
| 67 | const std::vector<unsigned char> getNonce() const { return nonce_; } |
Jeff Thompson | 2255290 | 2013-07-07 21:26:20 -0700 | [diff] [blame] | 68 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Clear this interest, and set the values by copying from the interest struct. |
| 71 | * @param interestStruct a C ndn_Interest struct |
| 72 | */ |
| 73 | void set(struct ndn_Interest &interestStruct); |
| 74 | |
| 75 | private: |
| 76 | |
| 77 | Name name_; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 78 | int minSuffixComponents_; |
Jeff Thompson | f2e5e28 | 2013-07-08 15:26:16 -0700 | [diff] [blame] | 79 | int maxSuffixComponents_; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 80 | std::vector<unsigned char> publisherPublicKeyDigest_; |
| 81 | // TODO: implement exclude |
| 82 | int childSelector_; |
| 83 | int answerOriginKind_; |
| 84 | int scope_; |
| 85 | int interestLifetime_; |
| 86 | std::vector<unsigned char> nonce_; |
| 87 | }; |
| 88 | |
| 89 | } |
| 90 | |
| 91 | #endif |