selectors.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SELECTORS_HPP
23 #define NDN_SELECTORS_HPP
24 
25 #include "common.hpp"
26 #include "key-locator.hpp"
27 #include "exclude.hpp"
28 
29 namespace ndn {
30 
31 const int DEFAULT_CHILD_SELECTOR = 0;
32 
36 class Selectors
37 {
38 public:
39  class Error : public tlv::Error
40  {
41  public:
42  using tlv::Error::Error;
43  };
44 
45  Selectors();
46 
50  explicit
51  Selectors(const Block& wire);
52 
53  bool
54  empty() const;
55 
59  template<encoding::Tag TAG>
60  size_t
61  wireEncode(EncodingImpl<TAG>& encoder) const;
62 
66  const Block&
67  wireEncode() const;
68 
72  void
73  wireDecode(const Block& wire);
74 
75 public: // getters & setters
76  int
78  {
79  return m_minSuffixComponents;
80  }
81 
82  Selectors&
83  setMinSuffixComponents(int minSuffixComponents);
84 
85  int
87  {
88  return m_maxSuffixComponents;
89  }
90 
91  Selectors&
92  setMaxSuffixComponents(int maxSuffixComponents);
93 
94  const KeyLocator&
96  {
97  return m_publisherPublicKeyLocator;
98  }
99 
100  Selectors&
101  setPublisherPublicKeyLocator(const KeyLocator& keyLocator);
102 
103  const Exclude&
104  getExclude() const
105  {
106  return m_exclude;
107  }
108 
109  Selectors&
110  setExclude(const Exclude& exclude);
111 
112  int
114  {
115  return m_childSelector;
116  }
117 
122  Selectors&
123  setChildSelector(int childSelector);
124 
125  bool
127  {
128  return m_mustBeFresh;
129  }
130 
131  Selectors&
132  setMustBeFresh(bool mustBeFresh);
133 
134 public: // EqualityComparable concept
135  bool
136  operator==(const Selectors& other) const;
137 
138  bool
139  operator!=(const Selectors& other) const
140  {
141  return !this->operator==(other);
142  }
143 
144 private:
145  int m_minSuffixComponents;
146  int m_maxSuffixComponents;
147  KeyLocator m_publisherPublicKeyLocator;
148  Exclude m_exclude;
149  int m_childSelector;
150  bool m_mustBeFresh;
151 
152  mutable Block m_wire;
153 };
154 
156 
157 } // namespace ndn
158 
159 #endif // NDN_SELECTORS_HPP
void wireDecode(const Block &wire)
Decode the input from wire format.
Definition: selectors.cpp:131
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:65
Selectors & setMustBeFresh(bool mustBeFresh)
Definition: selectors.cpp:225
const int DEFAULT_CHILD_SELECTOR
Definition: selectors.hpp:31
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
import common constructs for ndn-cxx library internal use
Selectors & setMaxSuffixComponents(int maxSuffixComponents)
Definition: selectors.cpp:190
Selectors & setExclude(const Exclude &exclude)
Definition: selectors.cpp:206
const KeyLocator & getPublisherPublicKeyLocator() const
Definition: selectors.hpp:95
Selectors & setChildSelector(int childSelector)
set ChildSelector
Definition: selectors.cpp:214
Selectors & setMinSuffixComponents(int minSuffixComponents)
Definition: selectors.cpp:182
const Exclude & getExclude() const
Definition: selectors.hpp:104
int getChildSelector() const
Definition: selectors.hpp:113
bool empty() const
Definition: selectors.cpp:49
const Block & wireEncode() const
Encode to a wire format.
Definition: selectors.cpp:115
bool getMustBeFresh() const
Definition: selectors.hpp:126
Abstraction implementing Interest selectors.
Definition: selectors.hpp:36
bool operator==(const Selectors &other) const
Definition: selectors.cpp:233
int getMinSuffixComponents() const
Definition: selectors.hpp:77
bool operator!=(const Selectors &other) const
Definition: selectors.hpp:139
int getMaxSuffixComponents() const
Definition: selectors.hpp:86
represents an error in TLV encoding or decoding
Represents Exclude selector in NDN Interest.
Definition: exclude.hpp:43
Selectors & setPublisherPublicKeyLocator(const KeyLocator &keyLocator)
Definition: selectors.cpp:198