blob: 39a6c0e15c62192692fc4e9a25c382c0c00315c5 [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#ifndef NDN_PIB_GET_PARAM_HPP
23#define NDN_PIB_GET_PARAM_HPP
24
25#include "pib-common.hpp"
26#include <ndn-cxx/name.hpp>
27
28namespace ndn {
29namespace pib {
30
31/**
32 * @brief GetParam is the abstraction of PIB Get parameter.
33 *
34 * PibGetParam := PIB-GET-PARAM-TYPE TLV-LENGTH
35 * PibType
36 * Name?
37 *
38 * @sa http://redmine.named-data.net/projects/ndn-cxx/wiki/PublicKey_Info_Base#Get-Parameters
39 */
40
41class GetParam : 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 GetParam();
55
56 GetParam(const pib::Type targetType, const Name& targetName);
57
58 explicit
59 GetParam(const Block& wire);
60
61 tlv::pib::ParamType
62 getParamType() const
63 {
64 return tlv::pib::GetParam;
65 }
66
67 pib::Type
68 getTargetType() const
69 {
70 return m_targetType;
71 }
72
73 /**
74 * @brief Get target name
75 *
76 * @throws Error if target name does not exist
77 */
78 const Name&
79 getTargetName() 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_targetType;
107 Name m_targetName;
108
109 mutable Block m_wire;
110};
111
112} // namespace pib
113} // namespace ndn
114
115#endif // NDN_PIB_GET_PARAM_HPP