NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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 "ndn-cxx/exclude.hpp"
26 #include "ndn-cxx/key-locator.hpp"
27 
28 namespace ndn {
29 
30 const int DEFAULT_CHILD_SELECTOR = 0;
31 
35 class Selectors
36 {
37 public:
38  class Error : public tlv::Error
39  {
40  public:
41  using tlv::Error::Error;
42  };
43 
44  Selectors();
45 
49  explicit
50  Selectors(const Block& wire);
51 
52  bool
53  empty() const;
54 
58  template<encoding::Tag TAG>
59  size_t
60  wireEncode(EncodingImpl<TAG>& encoder) const;
61 
65  const Block&
66  wireEncode() const;
67 
71  void
72  wireDecode(const Block& wire);
73 
74 public: // getters & setters
75  int
77  {
78  return m_minSuffixComponents;
79  }
80 
81  Selectors&
82  setMinSuffixComponents(int minSuffixComponents);
83 
84  int
86  {
87  return m_maxSuffixComponents;
88  }
89 
90  Selectors&
91  setMaxSuffixComponents(int maxSuffixComponents);
92 
93  const KeyLocator&
95  {
96  return m_publisherPublicKeyLocator;
97  }
98 
99  Selectors&
100  setPublisherPublicKeyLocator(const KeyLocator& keyLocator);
101 
102  const Exclude&
103  getExclude() const
104  {
105  return m_exclude;
106  }
107 
108  Selectors&
109  setExclude(const Exclude& exclude);
110 
111  int
113  {
114  return m_childSelector;
115  }
116 
121  Selectors&
122  setChildSelector(int childSelector);
123 
124  bool
126  {
127  return m_mustBeFresh;
128  }
129 
130  Selectors&
131  setMustBeFresh(bool mustBeFresh);
132 
133 public: // EqualityComparable concept
134  bool
135  operator==(const Selectors& other) const;
136 
137  bool
138  operator!=(const Selectors& other) const
139  {
140  return !this->operator==(other);
141  }
142 
143 private:
144  int m_minSuffixComponents;
145  int m_maxSuffixComponents;
146  KeyLocator m_publisherPublicKeyLocator;
147  Exclude m_exclude;
148  int m_childSelector;
149  bool m_mustBeFresh;
150 
151  mutable Block m_wire;
152 };
153 
155 
156 } // namespace ndn
157 
158 #endif // NDN_SELECTORS_HPP
void wireDecode(const Block &wire)
Decode the input from wire format.
Definition: selectors.cpp:131
int getMinSuffixComponents() const
Definition: selectors.hpp:76
Copyright (c) 2011-2015 Regents of the University of California.
Selectors & setMustBeFresh(bool mustBeFresh)
Definition: selectors.cpp:225
bool empty() const
Definition: selectors.cpp:49
const int DEFAULT_CHILD_SELECTOR
Definition: selectors.hpp:30
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
bool getMustBeFresh() const
Definition: selectors.hpp:125
int getChildSelector() const
Definition: selectors.hpp:112
Selectors & setMaxSuffixComponents(int maxSuffixComponents)
Definition: selectors.cpp:190
Selectors & setExclude(const Exclude &exclude)
Definition: selectors.cpp:206
Selectors & setChildSelector(int childSelector)
set ChildSelector
Definition: selectors.cpp:214
Selectors & setMinSuffixComponents(int minSuffixComponents)
Definition: selectors.cpp:182
const KeyLocator & getPublisherPublicKeyLocator() const
Definition: selectors.hpp:94
bool operator!=(const Selectors &other) const
Definition: selectors.hpp:138
const Block & wireEncode() const
Encode to a wire format.
Definition: selectors.cpp:115
Abstraction implementing Interest selectors.
Definition: selectors.hpp:35
bool operator==(const Selectors &other) const
Definition: selectors.cpp:233
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
int getMaxSuffixComponents() const
Definition: selectors.hpp:85
const Exclude & getExclude() const
Definition: selectors.hpp:103
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52
Represents Exclude selector in NDN Interest.
Definition: exclude.hpp:43
Selectors & setPublisherPublicKeyLocator(const KeyLocator &keyLocator)
Definition: selectors.cpp:198