NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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-2017 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_MGMT_NFD_FACE_QUERY_FILTER_HPP
23 #define NDN_MGMT_NFD_FACE_QUERY_FILTER_HPP
24 
25 #include "../../encoding/block.hpp"
26 #include "../../encoding/nfd-constants.hpp"
27 
28 namespace ndn {
29 namespace nfd {
30 
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 
50 
51  explicit
52  FaceQueryFilter(const Block& block);
53 
56  template<encoding::Tag TAG>
57  size_t
58  wireEncode(EncodingImpl<TAG>& encoder) const;
59 
62  const Block&
63  wireEncode() const;
64 
67  void
68  wireDecode(const Block& wire);
69 
72  bool
73  empty() const;
74 
75 public: // getters & setters
76  bool
77  hasFaceId() const
78  {
79  return !!m_faceId;
80  }
81 
82  uint64_t
83  getFaceId() const
84  {
85  BOOST_ASSERT(this->hasFaceId());
86  return *m_faceId;
87  }
88 
90  setFaceId(uint64_t faceId);
91 
93  unsetFaceId();
94 
95  bool
96  hasUriScheme() const
97  {
98  return !m_uriScheme.empty();
99  }
100 
101  const std::string&
102  getUriScheme() const
103  {
104  BOOST_ASSERT(this->hasUriScheme());
105  return m_uriScheme;
106  }
107 
109  setUriScheme(const std::string& uriScheme);
110 
112  unsetUriScheme();
113 
114  bool
115  hasRemoteUri() const
116  {
117  return !m_remoteUri.empty();
118  }
119 
120  const std::string&
121  getRemoteUri() const
122  {
123  BOOST_ASSERT(this->hasRemoteUri());
124  return m_remoteUri;
125  }
126 
128  setRemoteUri(const std::string& remoteUri);
129 
131  unsetRemoteUri();
132 
133  bool
134  hasLocalUri() const
135  {
136  return !m_localUri.empty();
137  }
138 
139  const std::string&
140  getLocalUri() const
141  {
142  BOOST_ASSERT(this->hasLocalUri());
143  return m_localUri;
144  }
145 
147  setLocalUri(const std::string& localUri);
148 
150  unsetLocalUri();
151 
152  bool
153  hasFaceScope() const
154  {
155  return !!m_faceScope;
156  }
157 
158  FaceScope
159  getFaceScope() const
160  {
161  BOOST_ASSERT(this->hasFaceScope());
162  return *m_faceScope;
163  }
164 
166  setFaceScope(FaceScope faceScope);
167 
169  unsetFaceScope();
170 
171  bool
173  {
174  return !!m_facePersistency;
175  }
176 
179  {
180  BOOST_ASSERT(this->hasFacePersistency());
181  return *m_facePersistency;
182  }
183 
185  setFacePersistency(FacePersistency facePersistency);
186 
189 
190  bool
191  hasLinkType() const
192  {
193  return !!m_linkType;
194  }
195 
196  LinkType
197  getLinkType() const
198  {
199  BOOST_ASSERT(this->hasLinkType());
200  return *m_linkType;
201  }
202 
204  setLinkType(LinkType linkType);
205 
207  unsetLinkType();
208 
209 private:
210  optional<uint64_t> m_faceId;
211  std::string m_uriScheme;
212  std::string m_remoteUri;
213  std::string m_localUri;
214  optional<FaceScope> m_faceScope;
215  optional<FacePersistency> m_facePersistency;
216  optional<LinkType> m_linkType;
217 
218  mutable Block m_wire;
219 };
220 
222 
223 bool
224 operator==(const FaceQueryFilter& a, const FaceQueryFilter& b);
225 
226 inline bool
228 {
229  return !(a == b);
230 }
231 
232 std::ostream&
233 operator<<(std::ostream& os, const FaceQueryFilter& filter);
234 
235 } // namespace nfd
236 } // namespace ndn
237 
238 #endif // NDN_MGMT_NFD_FACE_QUERY_FILTER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
FaceQueryFilter & unsetLocalUri()
const std::string & getLocalUri() const
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
const std::string & getRemoteUri() const
FaceQueryFilter & unsetFaceScope()
FaceQueryFilter & setLocalUri(const std::string &localUri)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
const Block & wireEncode() const
encode FaceQueryFilter
FaceQueryFilter & setFaceScope(FaceScope faceScope)
FaceQueryFilter & unsetFaceId()
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
FaceQueryFilter & setUriScheme(const std::string &uriScheme)
FaceQueryFilter & unsetFacePersistency()
represents Face Query Filter
FaceQueryFilter & unsetUriScheme()
FaceQueryFilter & unsetRemoteUri()
FaceQueryFilter & setRemoteUri(const std::string &remoteUri)
Error(const std::string &what)
FaceQueryFilter & setFaceId(uint64_t faceId)
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
const std::string & getUriScheme() const
FaceQueryFilter & setLinkType(LinkType linkType)
FaceQueryFilter & setFacePersistency(FacePersistency facePersistency)
FacePersistency getFacePersistency() const
void wireDecode(const Block &wire)
decode FaceQueryFilter
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
FaceQueryFilter & unsetLinkType()