blob: 1d63db8b5bdceaea56512de2fd8e4ab9d2a9b00b [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompsonb7f95562013-07-03 18:36:42 -07004 */
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
13namespace ndn {
14
15class Interest {
16public:
Jeff Thompsond345a5b2013-07-08 16:18:23 -070017 void encode(std::vector<unsigned char> &output, WireFormat &wireFormat) const
Jeff Thompsonb7f95562013-07-03 18:36:42 -070018 {
19 wireFormat.encodeInterest(*this, output);
20 }
Jeff Thompsond345a5b2013-07-08 16:18:23 -070021 void encode(std::vector<unsigned char> &output) const
Jeff Thompsonb7f95562013-07-03 18:36:42 -070022 {
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 Thompsond9e278c2013-07-08 15:20:13 -070041
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 Thompsond345a5b2013-07-08 16:18:23 -070047 void get(struct ndn_Interest &interestStruct) const;
Jeff Thompsonb7f95562013-07-03 18:36:42 -070048
Jeff Thompsond345a5b2013-07-08 16:18:23 -070049 const Name &getName() const { return name_; }
Jeff Thompsonb7f95562013-07-03 18:36:42 -070050
Jeff Thompsond345a5b2013-07-08 16:18:23 -070051 int getMinSuffixComponents() const { return minSuffixComponents_; }
52
53 int getMaxSuffixComponents() const { return maxSuffixComponents_; }
54
55 int getInterestLifetime() const { return interestLifetime_; }
Jeff Thompson22552902013-07-07 21:26:20 -070056
Jeff Thompsonb7f95562013-07-03 18:36:42 -070057 /**
58 * Clear this interest, and set the values by copying from the interest struct.
59 * @param interestStruct a C ndn_Interest struct
60 */
61 void set(struct ndn_Interest &interestStruct);
62
63private:
64
65 Name name_;
Jeff Thompsonb7f95562013-07-03 18:36:42 -070066 int minSuffixComponents_;
Jeff Thompsonf2e5e282013-07-08 15:26:16 -070067 int maxSuffixComponents_;
Jeff Thompsonb7f95562013-07-03 18:36:42 -070068 std::vector<unsigned char> publisherPublicKeyDigest_;
69 // TODO: implement exclude
70 int childSelector_;
71 int answerOriginKind_;
72 int scope_;
73 int interestLifetime_;
74 std::vector<unsigned char> nonce_;
75};
76
77}
78
79#endif