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