blob: 0e7cce108dd4840a9e7c69863fc58d7ec47b76af [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yingdi Yu0a312e52015-07-22 13:14:53 -07003 * Copyright (c) 2014-2015, Regents of the University of California.
Yingdi Yu77627ab2015-07-21 16:13:49 -07004 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07005 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
Yingdi Yu77627ab2015-07-21 16:13:49 -07007 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07008 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Yingdi Yu77627ab2015-07-21 16:13:49 -070011 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070012 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Yingdi Yu77627ab2015-07-21 16:13:49 -070015 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070016 * You should have received a copy of the GNU General Public License along with
17 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Yingdi Yu77627ab2015-07-21 16:13:49 -070018 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070019 * @author Yingdi Yu <yingdi@cs.ucla.edu>
Yingdi Yu77627ab2015-07-21 16:13:49 -070020 */
21
Yingdi Yu0a312e52015-07-22 13:14:53 -070022#ifndef NDN_TOOLS_PIB_LIST_PARAM_HPP
23#define NDN_TOOLS_PIB_LIST_PARAM_HPP
Yingdi Yu77627ab2015-07-21 16:13:49 -070024
25#include "pib-common.hpp"
26#include <ndn-cxx/name.hpp>
27
28namespace ndn {
29namespace pib {
30
31/**
32 * @brief ListParam is the abstraction of PIB List parameter.
33 *
34 * PibListParam := PIB-LIST-PARAM-TYPE TLV-LENGTH
35 * PibType // origin type
36 * Name? // origin name
37 *
38 * @sa http://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base#List-Parameters
39 */
40
41class ListParam : noncopyable
42{
43public:
44 class Error : public tlv::Error
45 {
46 public:
47 explicit
48 Error(const std::string& what)
49 : tlv::Error(what)
50 {
51 }
52 };
53
54 ListParam();
55
56 ListParam(const pib::Type originType, const Name& originName);
57
58 explicit
59 ListParam(const Block& wire);
60
61 tlv::pib::ParamType
62 getParamType() const
63 {
64 return tlv::pib::ListParam;
65 }
66
67 pib::Type
68 getOriginType() const
69 {
70 return m_originType;
71 }
72
73 /**
74 * @brief Get target name
75 *
76 * @throws Error if origin name does not exist
77 */
78 const Name&
79 getOriginName() const;
80
81 /// @brief Encode to a wire format or estimate wire format
82 template<bool T>
83 size_t
84 wireEncode(EncodingImpl<T>& block) const;
85
86 /**
87 * @brief Encode to a wire format
88 *
89 * @throws Error if encoding fails
90 */
91 const Block&
92 wireEncode() const;
93
94 /**
95 * @brief Decode GetParam from a wire encoded block
96 *
97 * @throws Error if decoding fails
98 */
99 void
100 wireDecode(const Block& wire);
101
102public:
103 static const std::string VERB;
104
105private:
106 pib::Type m_originType;
107 Name m_originName;
108
109 mutable Block m_wire;
110};
111
112} // namespace pib
113} // namespace ndn
114
115
116
Yingdi Yu0a312e52015-07-22 13:14:53 -0700117#endif // NDN_TOOLS_PIB_LIST_PARAM_HPP