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: |
| 17 | void encode(std::vector<unsigned char> &output, WireFormat &wireFormat) |
| 18 | { |
| 19 | wireFormat.encodeInterest(*this, output); |
| 20 | } |
| 21 | void encode(std::vector<unsigned char> &output) |
| 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 | } |
| 41 | |
| 42 | Name &getName() { return name_; } |
| 43 | |
Jeff Thompson | 2255290 | 2013-07-07 21:26:20 -0700 | [diff] [blame] | 44 | int getInterestLifetime() { return interestLifetime_; } |
| 45 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Clear this interest, and set the values by copying from the interest struct. |
| 48 | * @param interestStruct a C ndn_Interest struct |
| 49 | */ |
| 50 | void set(struct ndn_Interest &interestStruct); |
| 51 | |
| 52 | private: |
| 53 | |
| 54 | Name name_; |
| 55 | int maxSuffixComponents_; |
| 56 | int minSuffixComponents_; |
| 57 | |
| 58 | std::vector<unsigned char> publisherPublicKeyDigest_; |
| 59 | // TODO: implement exclude |
| 60 | int childSelector_; |
| 61 | int answerOriginKind_; |
| 62 | int scope_; |
| 63 | int interestLifetime_; |
| 64 | std::vector<unsigned char> nonce_; |
| 65 | }; |
| 66 | |
| 67 | } |
| 68 | |
| 69 | #endif |