face-query-filter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2023 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_CXX_MGMT_NFD_FACE_QUERY_FILTER_HPP
23 #define NDN_CXX_MGMT_NFD_FACE_QUERY_FILTER_HPP
24 
27 
28 #include <optional>
29 
30 namespace ndn::nfd {
31 
38 {
39 public:
40  class Error : public tlv::Error
41  {
42  public:
43  using tlv::Error::Error;
44  };
45 
47 
48  explicit
49  FaceQueryFilter(const Block& block);
50 
53  template<encoding::Tag TAG>
54  size_t
55  wireEncode(EncodingImpl<TAG>& encoder) const;
56 
59  const Block&
60  wireEncode() const;
61 
64  void
65  wireDecode(const Block& wire);
66 
69  bool
70  empty() const;
71 
72 public: // getters & setters
73  bool
74  hasFaceId() const
75  {
76  return !!m_faceId;
77  }
78 
79  uint64_t
80  getFaceId() const
81  {
82  BOOST_ASSERT(this->hasFaceId());
83  return *m_faceId;
84  }
85 
87  setFaceId(uint64_t faceId);
88 
90  unsetFaceId();
91 
92  bool
93  hasUriScheme() const
94  {
95  return !m_uriScheme.empty();
96  }
97 
98  const std::string&
99  getUriScheme() const
100  {
101  BOOST_ASSERT(this->hasUriScheme());
102  return m_uriScheme;
103  }
104 
106  setUriScheme(const std::string& uriScheme);
107 
109  unsetUriScheme();
110 
111  bool
112  hasRemoteUri() const
113  {
114  return !m_remoteUri.empty();
115  }
116 
117  const std::string&
118  getRemoteUri() const
119  {
120  BOOST_ASSERT(this->hasRemoteUri());
121  return m_remoteUri;
122  }
123 
125  setRemoteUri(const std::string& remoteUri);
126 
128  unsetRemoteUri();
129 
130  bool
131  hasLocalUri() const
132  {
133  return !m_localUri.empty();
134  }
135 
136  const std::string&
137  getLocalUri() const
138  {
139  BOOST_ASSERT(this->hasLocalUri());
140  return m_localUri;
141  }
142 
144  setLocalUri(const std::string& localUri);
145 
147  unsetLocalUri();
148 
149  bool
150  hasFaceScope() const
151  {
152  return !!m_faceScope;
153  }
154 
155  FaceScope
156  getFaceScope() const
157  {
158  BOOST_ASSERT(this->hasFaceScope());
159  return *m_faceScope;
160  }
161 
163  setFaceScope(FaceScope faceScope);
164 
166  unsetFaceScope();
167 
168  bool
170  {
171  return !!m_facePersistency;
172  }
173 
176  {
177  BOOST_ASSERT(this->hasFacePersistency());
178  return *m_facePersistency;
179  }
180 
182  setFacePersistency(FacePersistency facePersistency);
183 
186 
187  bool
188  hasLinkType() const
189  {
190  return !!m_linkType;
191  }
192 
193  LinkType
194  getLinkType() const
195  {
196  BOOST_ASSERT(this->hasLinkType());
197  return *m_linkType;
198  }
199 
201  setLinkType(LinkType linkType);
202 
204  unsetLinkType();
205 
206 private:
207  std::optional<uint64_t> m_faceId;
208  std::string m_uriScheme;
209  std::string m_remoteUri;
210  std::string m_localUri;
211  std::optional<FaceScope> m_faceScope;
212  std::optional<FacePersistency> m_facePersistency;
213  std::optional<LinkType> m_linkType;
214 
215  mutable Block m_wire;
216 };
217 
219 
220 bool
221 operator==(const FaceQueryFilter& a, const FaceQueryFilter& b);
222 
223 inline bool
225 {
226  return !(a == b);
227 }
228 
229 std::ostream&
230 operator<<(std::ostream& os, const FaceQueryFilter& filter);
231 
232 } // namespace ndn::nfd
233 
234 #endif // NDN_CXX_MGMT_NFD_FACE_QUERY_FILTER_HPP
Represents a TLV element of the NDN packet format.
Definition: block.hpp:45
Represents Face Query Filter.
const std::string & getLocalUri() const
const Block & wireEncode() const
Encode FaceQueryFilter.
FaceQueryFilter & unsetUriScheme()
const std::string & getUriScheme() const
FaceQueryFilter & unsetRemoteUri()
FaceQueryFilter & unsetFaceScope()
FaceQueryFilter & setRemoteUri(const std::string &remoteUri)
FaceQueryFilter & unsetLinkType()
FaceQueryFilter & unsetFaceId()
FaceQueryFilter & unsetFacePersistency()
FaceQueryFilter & setFaceScope(FaceScope faceScope)
FacePersistency getFacePersistency() const
FaceQueryFilter & setFaceId(uint64_t faceId)
FaceQueryFilter & setFacePersistency(FacePersistency facePersistency)
FaceQueryFilter & setLocalUri(const std::string &localUri)
void wireDecode(const Block &wire)
Decode FaceQueryFilter.
FaceQueryFilter & setLinkType(LinkType linkType)
FaceQueryFilter & unsetLocalUri()
FaceQueryFilter & setUriScheme(const std::string &uriScheme)
const std::string & getRemoteUri() const
Represents an error in TLV encoding or decoding.
Definition: tlv.hpp:54
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:28
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
Contains classes and functions related to the NFD Management protocol.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
bool operator==(const ChannelStatus &a, const ChannelStatus &b)