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 "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  explicit
43  Error(const std::string& what)
44  : tlv::Error(what)
45  {
46  }
47  };
48 
49  Selectors();
50 
54  explicit
55  Selectors(const Block& wire);
56 
57  bool
58  empty() const;
59 
63  template<encoding::Tag TAG>
64  size_t
65  wireEncode(EncodingImpl<TAG>& encoder) const;
66 
70  const Block&
71  wireEncode() const;
72 
76  void
77  wireDecode(const Block& wire);
78 
79 public: // getters & setters
80  int
82  {
83  return m_minSuffixComponents;
84  }
85 
86  Selectors&
87  setMinSuffixComponents(int minSuffixComponents);
88 
89  int
91  {
92  return m_maxSuffixComponents;
93  }
94 
95  Selectors&
96  setMaxSuffixComponents(int maxSuffixComponents);
97 
98  const KeyLocator&
100  {
101  return m_publisherPublicKeyLocator;
102  }
103 
104  Selectors&
105  setPublisherPublicKeyLocator(const KeyLocator& keyLocator);
106 
107  const Exclude&
108  getExclude() const
109  {
110  return m_exclude;
111  }
112 
113  Selectors&
114  setExclude(const Exclude& exclude);
115 
116  int
118  {
119  return m_childSelector;
120  }
121 
126  Selectors&
127  setChildSelector(int childSelector);
128 
129  bool
131  {
132  return m_mustBeFresh;
133  }
134 
135  Selectors&
136  setMustBeFresh(bool mustBeFresh);
137 
138 public: // EqualityComparable concept
139  bool
140  operator==(const Selectors& other) const;
141 
142  bool
143  operator!=(const Selectors& other) const
144  {
145  return !this->operator==(other);
146  }
147 
148 private:
149  int m_minSuffixComponents;
150  int m_maxSuffixComponents;
151  KeyLocator m_publisherPublicKeyLocator;
152  Exclude m_exclude;
153  int m_childSelector;
154  bool m_mustBeFresh;
155 
156  mutable Block m_wire;
157 };
158 
160 
161 } // namespace ndn
162 
163 #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:81
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:31
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
import common constructs for ndn-cxx library internal use
bool getMustBeFresh() const
Definition: selectors.hpp:130
int getChildSelector() const
Definition: selectors.hpp:117
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
Error(const std::string &what)
Definition: selectors.hpp:43
Selectors & setMinSuffixComponents(int minSuffixComponents)
Definition: selectors.cpp:182
const KeyLocator & getPublisherPublicKeyLocator() const
Definition: selectors.hpp:99
bool operator!=(const Selectors &other) const
Definition: selectors.hpp:143
const Block & wireEncode() const
Encode to a wire format.
Definition: selectors.cpp:115
Abstraction implementing Interest selectors.
Definition: selectors.hpp:36
bool operator==(const Selectors &other) const
Definition: selectors.cpp:233
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude)
int getMaxSuffixComponents() const
Definition: selectors.hpp:90
const Exclude & getExclude() const
Definition: selectors.hpp:108
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
Represents Exclude selector in NDN Interest.
Definition: exclude.hpp:42
Selectors & setPublisherPublicKeyLocator(const KeyLocator &keyLocator)
Definition: selectors.cpp:198