Chengyu Fan | fc8aebb | 2014-10-22 16:35:23 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 Regents of the University of California. |
Chengyu Fan | fc8aebb | 2014-10-22 16:35:23 -0600 | [diff] [blame] | 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_MANAGEMENT_NFD_FACE_QUERY_FILTER_HPP |
| 23 | #define NDN_MANAGEMENT_NFD_FACE_QUERY_FILTER_HPP |
| 24 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 25 | #include "../encoding/block.hpp" |
| 26 | #include "../encoding/nfd-constants.hpp" |
Chengyu Fan | fc8aebb | 2014-10-22 16:35:23 -0600 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
| 31 | /** |
| 32 | * \ingroup management |
| 33 | * \brief represents Face Query Filter |
| 34 | * \sa http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation |
| 35 | */ |
| 36 | class FaceQueryFilter |
| 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 | FaceQueryFilter(); |
| 50 | |
| 51 | explicit |
| 52 | FaceQueryFilter(const Block& block); |
| 53 | |
| 54 | /** \brief prepend FaceQueryFilter to the encoder |
| 55 | */ |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 56 | template<encoding::Tag TAG> |
Chengyu Fan | fc8aebb | 2014-10-22 16:35:23 -0600 | [diff] [blame] | 57 | size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 58 | wireEncode(EncodingImpl<TAG>& encoder) const; |
Chengyu Fan | fc8aebb | 2014-10-22 16:35:23 -0600 | [diff] [blame] | 59 | |
| 60 | /** \brief encode FaceQueryFilter |
| 61 | */ |
| 62 | const Block& |
| 63 | wireEncode() const; |
| 64 | |
| 65 | /** \brief decode FaceQueryFilter |
| 66 | */ |
| 67 | void |
| 68 | wireDecode(const Block& wire); |
| 69 | |
| 70 | public: // getters & setters |
| 71 | |
| 72 | bool |
| 73 | hasFaceId() const |
| 74 | { |
| 75 | return m_hasFaceId; |
| 76 | } |
| 77 | |
| 78 | uint64_t |
| 79 | getFaceId() const |
| 80 | { |
| 81 | BOOST_ASSERT(this->hasFaceId()); |
| 82 | return m_faceId; |
| 83 | } |
| 84 | |
| 85 | FaceQueryFilter& |
| 86 | setFaceId(uint64_t faceId); |
| 87 | |
| 88 | FaceQueryFilter& |
| 89 | unsetFaceId(); |
| 90 | |
| 91 | bool |
| 92 | hasUriScheme() const |
| 93 | { |
| 94 | return m_hasUriScheme; |
| 95 | } |
| 96 | |
| 97 | const std::string& |
| 98 | getUriScheme() const |
| 99 | { |
| 100 | BOOST_ASSERT(this->hasUriScheme()); |
| 101 | return m_uriScheme; |
| 102 | } |
| 103 | |
| 104 | FaceQueryFilter& |
| 105 | setUriScheme(const std::string& uriScheme); |
| 106 | |
| 107 | FaceQueryFilter& |
| 108 | unsetUriScheme(); |
| 109 | |
| 110 | bool |
| 111 | hasRemoteUri() const |
| 112 | { |
| 113 | return m_hasRemoteUri; |
| 114 | } |
| 115 | |
| 116 | const std::string& |
| 117 | getRemoteUri() const |
| 118 | { |
| 119 | BOOST_ASSERT(this->hasRemoteUri()); |
| 120 | return m_remoteUri; |
| 121 | } |
| 122 | |
| 123 | FaceQueryFilter& |
| 124 | setRemoteUri(const std::string& remoteUri); |
| 125 | |
| 126 | FaceQueryFilter& |
| 127 | unsetRemoteUri(); |
| 128 | |
| 129 | bool |
| 130 | hasLocalUri() const |
| 131 | { |
| 132 | return m_hasLocalUri; |
| 133 | } |
| 134 | |
| 135 | const std::string& |
| 136 | getLocalUri() const |
| 137 | { |
| 138 | BOOST_ASSERT(this->hasLocalUri()); |
| 139 | return m_localUri; |
| 140 | } |
| 141 | |
| 142 | FaceQueryFilter& |
| 143 | setLocalUri(const std::string& localUri); |
| 144 | |
| 145 | FaceQueryFilter& |
| 146 | unsetLocalUri(); |
| 147 | |
| 148 | bool |
| 149 | hasFaceScope() const |
| 150 | { |
| 151 | return m_hasFaceScope; |
| 152 | } |
| 153 | |
| 154 | FaceScope |
| 155 | getFaceScope() const |
| 156 | { |
| 157 | BOOST_ASSERT(this->hasFaceScope()); |
| 158 | return m_faceScope; |
| 159 | } |
| 160 | |
| 161 | FaceQueryFilter& |
| 162 | setFaceScope(FaceScope faceScope); |
| 163 | |
| 164 | FaceQueryFilter& |
| 165 | unsetFaceScope(); |
| 166 | |
| 167 | bool |
| 168 | hasFacePersistency() const |
| 169 | { |
| 170 | return m_hasFacePersistency; |
| 171 | } |
| 172 | |
| 173 | FacePersistency |
| 174 | getFacePersistency() const |
| 175 | { |
| 176 | BOOST_ASSERT(this->hasFacePersistency()); |
| 177 | return m_facePersistency; |
| 178 | } |
| 179 | |
| 180 | FaceQueryFilter& |
| 181 | setFacePersistency(FacePersistency facePersistency); |
| 182 | |
| 183 | FaceQueryFilter& |
| 184 | unsetFacePersistency(); |
| 185 | |
| 186 | bool |
| 187 | hasLinkType() const |
| 188 | { |
| 189 | return m_hasLinkType; |
| 190 | } |
| 191 | |
| 192 | LinkType |
| 193 | getLinkType() const |
| 194 | { |
| 195 | BOOST_ASSERT(this->hasLinkType()); |
| 196 | return m_linkType; |
| 197 | } |
| 198 | |
| 199 | FaceQueryFilter& |
| 200 | setLinkType(LinkType linkType); |
| 201 | |
| 202 | FaceQueryFilter& |
| 203 | unsetLinkType(); |
| 204 | |
| 205 | private: |
| 206 | uint64_t m_faceId; |
| 207 | std::string m_uriScheme; |
| 208 | std::string m_remoteUri; |
| 209 | std::string m_localUri; |
| 210 | FaceScope m_faceScope; |
| 211 | FacePersistency m_facePersistency; |
| 212 | LinkType m_linkType; |
| 213 | |
| 214 | bool m_hasFaceId; |
| 215 | bool m_hasUriScheme; |
| 216 | bool m_hasRemoteUri; |
| 217 | bool m_hasLocalUri; |
| 218 | bool m_hasFaceScope; |
| 219 | bool m_hasFacePersistency; |
| 220 | bool m_hasLinkType; |
| 221 | |
| 222 | mutable Block m_wire; |
| 223 | }; |
| 224 | |
| 225 | std::ostream& |
| 226 | operator<<(std::ostream& os, const FaceQueryFilter& filter); |
| 227 | |
| 228 | } // namespace nfd |
| 229 | } // namespace ndn |
| 230 | |
| 231 | #endif // NDN_MANAGEMENT_NFD_FACE_QUERY_FILTER_HPP |