blob: ef2b4470d5230d82b12b1c7462a1e66ce4d57781 [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:
Junxiao Shi68b53852018-07-25 13:56:38 -060046 using ndn::tlv::Error::Error;
Teng Liang5b323d12018-01-31 18:50:45 -070047 };
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
79private:
80 shared_ptr<const Data> m_data;
81};
82
83NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(PrefixAnnouncement);
Teng Liang8b6eda92018-01-25 20:41:54 -070084
85} // namespace lp
86} // namespace ndn
87
88#endif // NDN_CXX_LP_PREFIX_ANNOUNCEMENT_HPP