blob: f94732e543655c105c238bb79ca4b8690e94fdc3 [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- 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
23#ifndef NDN_PIB_LIST_PARAM_HPP
24#define NDN_PIB_LIST_PARAM_HPP
25
26#include "pib-common.hpp"
27#include <ndn-cxx/name.hpp>
28
29namespace ndn {
30namespace pib {
31
32/**
33 * @brief ListParam is the abstraction of PIB List parameter.
34 *
35 * PibListParam := PIB-LIST-PARAM-TYPE TLV-LENGTH
36 * PibType // origin type
37 * Name? // origin name
38 *
39 * @sa http://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base#List-Parameters
40 */
41
42class ListParam : noncopyable
43{
44public:
45 class Error : public tlv::Error
46 {
47 public:
48 explicit
49 Error(const std::string& what)
50 : tlv::Error(what)
51 {
52 }
53 };
54
55 ListParam();
56
57 ListParam(const pib::Type originType, const Name& originName);
58
59 explicit
60 ListParam(const Block& wire);
61
62 tlv::pib::ParamType
63 getParamType() const
64 {
65 return tlv::pib::ListParam;
66 }
67
68 pib::Type
69 getOriginType() const
70 {
71 return m_originType;
72 }
73
74 /**
75 * @brief Get target name
76 *
77 * @throws Error if origin name does not exist
78 */
79 const Name&
80 getOriginName() const;
81
82 /// @brief Encode to a wire format or estimate wire format
83 template<bool T>
84 size_t
85 wireEncode(EncodingImpl<T>& block) const;
86
87 /**
88 * @brief Encode to a wire format
89 *
90 * @throws Error if encoding fails
91 */
92 const Block&
93 wireEncode() const;
94
95 /**
96 * @brief Decode GetParam from a wire encoded block
97 *
98 * @throws Error if decoding fails
99 */
100 void
101 wireDecode(const Block& wire);
102
103public:
104 static const std::string VERB;
105
106private:
107 pib::Type m_originType;
108 Name m_originName;
109
110 mutable Block m_wire;
111};
112
113} // namespace pib
114} // namespace ndn
115
116
117
118#endif // NDN_PIB_LIST_PARAM_HPP