Teng Liang | 8b6eda9 | 2018-01-25 20:41:54 -0700 | [diff] [blame] | 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 | * @author Teng Liang <philoliang@email.arizona.edu> |
| 22 | */ |
| 23 | |
| 24 | #ifndef NDN_CXX_LP_PREFIX_ANNOUNCEMENT_HPP |
| 25 | #define NDN_CXX_LP_PREFIX_ANNOUNCEMENT_HPP |
| 26 | |
| 27 | #include "../data.hpp" |
Teng Liang | 5b323d1 | 2018-01-31 18:50:45 -0700 | [diff] [blame] | 28 | #include "../name.hpp" |
Teng Liang | 8b6eda9 | 2018-01-25 20:41:54 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ndn { |
| 31 | namespace lp { |
| 32 | |
Teng Liang | 5b323d1 | 2018-01-31 18:50:45 -0700 | [diff] [blame] | 33 | /** \brief represents a Prefix Announcement |
| 34 | * |
| 35 | * This type wraps a Data, and is intended for self-learning. The Name of Data |
| 36 | * starts with /self-learning prefix, ends with a version component, and the |
| 37 | * components in the middle refer to the announced name prefix. The MetaInfo |
| 38 | * and Content of the Data must be empty. |
Teng Liang | 8b6eda9 | 2018-01-25 20:41:54 -0700 | [diff] [blame] | 39 | */ |
Teng Liang | 5b323d1 | 2018-01-31 18:50:45 -0700 | [diff] [blame] | 40 | class PrefixAnnouncement |
| 41 | { |
| 42 | public: |
| 43 | class Error : public ndn::tlv::Error |
| 44 | { |
| 45 | public: |
Junxiao Shi | 68b5385 | 2018-07-25 13:56:38 -0600 | [diff] [blame] | 46 | using ndn::tlv::Error::Error; |
Teng Liang | 5b323d1 | 2018-01-31 18:50:45 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | PrefixAnnouncement(); |
| 50 | |
| 51 | explicit |
| 52 | PrefixAnnouncement(const Block& block); |
| 53 | |
| 54 | explicit |
| 55 | PrefixAnnouncement(shared_ptr<const Data> data); |
| 56 | |
| 57 | template<encoding::Tag TAG> |
| 58 | size_t |
| 59 | wireEncode(EncodingImpl<TAG>& encoder) const; |
| 60 | |
| 61 | void |
| 62 | wireDecode(const Block& wire); |
| 63 | |
| 64 | /** \brief Get announced name. |
| 65 | * \throw Error PrefixAnnouncement is empty |
| 66 | */ |
| 67 | Name |
| 68 | getAnnouncedName() const; |
| 69 | |
| 70 | shared_ptr<const Data> |
| 71 | getData() const |
| 72 | { |
| 73 | return m_data; |
| 74 | } |
| 75 | |
| 76 | PrefixAnnouncement& |
| 77 | setData(shared_ptr<const Data> data); |
| 78 | |
| 79 | private: |
| 80 | shared_ptr<const Data> m_data; |
| 81 | }; |
| 82 | |
| 83 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncement); |
Teng Liang | 8b6eda9 | 2018-01-25 20:41:54 -0700 | [diff] [blame] | 84 | |
| 85 | } // namespace lp |
| 86 | } // namespace ndn |
| 87 | |
| 88 | #endif // NDN_CXX_LP_PREFIX_ANNOUNCEMENT_HPP |