blob: 135cc21e30e36ba5cb7ffa847efa9497a3f5ee2b [file] [log] [blame]
Teng Liang8b6eda92018-01-25 20:41:54 -07001/* -*- 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 Liang5b323d12018-01-31 18:50:45 -070028#include "../name.hpp"
Teng Liang8b6eda92018-01-25 20:41:54 -070029
30namespace ndn {
31namespace lp {
32
Teng Liang5b323d12018-01-31 18:50:45 -070033/** \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 Liang8b6eda92018-01-25 20:41:54 -070039 */
Teng Liang5b323d12018-01-31 18:50:45 -070040class PrefixAnnouncement
41{
42public:
43 class Error : public ndn::tlv::Error
44 {
45 public:
46 explicit
47 Error(const std::string& what)
48 : ndn::tlv::Error(what)
49 {
50 }
51 };
52
53 PrefixAnnouncement();
54
55 explicit
56 PrefixAnnouncement(const Block& block);
57
58 explicit
59 PrefixAnnouncement(shared_ptr<const Data> data);
60
61 template<encoding::Tag TAG>
62 size_t
63 wireEncode(EncodingImpl<TAG>& encoder) const;
64
65 void
66 wireDecode(const Block& wire);
67
68 /** \brief Get announced name.
69 * \throw Error PrefixAnnouncement is empty
70 */
71 Name
72 getAnnouncedName() const;
73
74 shared_ptr<const Data>
75 getData() const
76 {
77 return m_data;
78 }
79
80 PrefixAnnouncement&
81 setData(shared_ptr<const Data> data);
82
83private:
84 shared_ptr<const Data> m_data;
85};
86
87NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncement);
Teng Liang8b6eda92018-01-25 20:41:54 -070088
89} // namespace lp
90} // namespace ndn
91
92#endif // NDN_CXX_LP_PREFIX_ANNOUNCEMENT_HPP