NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
control-response.hpp
Go to the documentation of this file.
1 /* -*- 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 
22 #ifndef NDN_MGMT_CONTROL_RESPONSE_HPP
23 #define NDN_MGMT_CONTROL_RESPONSE_HPP
24 
26 
27 namespace ndn {
28 namespace mgmt {
29 
33 {
34 public:
35  class Error : public tlv::Error
36  {
37  public:
38  using tlv::Error::Error;
39  };
40 
42 
43  ControlResponse(uint32_t code, const std::string& text);
44 
45  explicit
46  ControlResponse(const Block& block);
47 
48  uint32_t
49  getCode() const;
50 
52  setCode(uint32_t code);
53 
54  const std::string&
55  getText() const;
56 
58  setText(const std::string& text);
59 
60  const Block&
61  getBody() const;
62 
64  setBody(const Block& body);
65 
66  const Block&
67  wireEncode() const;
68 
69  void
70  wireDecode(const Block& block);
71 
72 protected:
73  uint32_t m_code;
74  std::string m_text;
76 
77  mutable Block m_wire;
78 };
79 
80 inline uint32_t
82 {
83  return m_code;
84 }
85 
86 inline ControlResponse&
88 {
89  m_code = code;
90  m_wire.reset();
91  return *this;
92 }
93 
94 inline const std::string&
96 {
97  return m_text;
98 }
99 
100 inline ControlResponse&
101 ControlResponse::setText(const std::string& text)
102 {
103  m_text = text;
104  m_wire.reset();
105  return *this;
106 }
107 
108 inline const Block&
110 {
111  return m_body;
112 }
113 
114 inline ControlResponse&
116 {
117  m_body = body;
118  m_body.encode(); // will do nothing if already encoded
119  m_wire.reset();
120  return *this;
121 }
122 
123 std::ostream&
124 operator<<(std::ostream& os, const ControlResponse& response);
125 
126 } // namespace mgmt
127 } // namespace ndn
128 
129 #endif // NDN_MGMT_CONTROL_RESPONSE_HPP
ndn::mgmt::ControlResponse::m_text
std::string m_text
Definition: control-response.hpp:74
ndn::mgmt::ControlResponse::wireEncode
const Block & wireEncode() const
Definition: control-response.cpp:52
ndn::mgmt::ControlResponse::wireDecode
void wireDecode(const Block &block)
Definition: control-response.cpp:70
block.hpp
ndn::mgmt::ControlResponse::setText
ControlResponse & setText(const std::string &text)
Definition: control-response.hpp:101
ndn::mgmt::ControlResponse::getCode
uint32_t getCode() const
Definition: control-response.hpp:81
ndn::mgmt::ControlResponse::getBody
const Block & getBody() const
Definition: control-response.hpp:109
ndn::Block::reset
void reset() noexcept
Reset the Block to a default-constructed state.
Definition: block.cpp:250
ndn::mgmt::ControlResponse::setCode
ControlResponse & setCode(uint32_t code)
Definition: control-response.hpp:87
ndn::mgmt::ControlResponse::m_body
Block m_body
Definition: control-response.hpp:75
ndn::mgmt::ControlResponse::m_code
uint32_t m_code
Definition: control-response.hpp:73
ndn::mgmt::ControlResponse::getText
const std::string & getText() const
Definition: control-response.hpp:95
ndn::mgmt::ControlResponse::setBody
ControlResponse & setBody(const Block &body)
Definition: control-response.hpp:115
ndn::mgmt::ControlResponse::m_wire
Block m_wire
Definition: control-response.hpp:77
ndn::mgmt::ControlResponse
ControlCommand response.
Definition: control-response.hpp:33
ndn::mgmt::operator<<
std::ostream & operator<<(std::ostream &os, const ControlResponse &response)
Definition: control-response.cpp:98
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition: tlv.hpp:53
ndn::mgmt::ControlResponse::ControlResponse
ControlResponse()
Definition: control-response.cpp:35
ndn::mgmt::ControlResponse::Error
Definition: control-response.hpp:36
ndn::Block::encode
void encode()
Encode sub-elements into TLV-VALUE.
Definition: block.cpp:353
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34