NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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; -*- */
26 #ifndef NDN_MGMT_CONTROL_RESPONSE_HPP
27 #define NDN_MGMT_CONTROL_RESPONSE_HPP
28 
29 #include "../encoding/block.hpp"
30 
31 namespace ndn {
32 namespace mgmt {
33 
37 {
38 public:
39  class Error : public tlv::Error
40  {
41  public:
42  explicit
43  Error(const std::string& what)
44  : tlv::Error(what)
45  {
46  }
47  };
48 
50 
51  ControlResponse(uint32_t code, const std::string& text);
52 
53  explicit
54  ControlResponse(const Block& block);
55 
56  uint32_t
57  getCode() const;
58 
60  setCode(uint32_t code);
61 
62  const std::string&
63  getText() const;
64 
66  setText(const std::string& text);
67 
68  const Block&
69  getBody() const;
70 
72  setBody(const Block& body);
73 
74  const Block&
75  wireEncode() const;
76 
77  void
78  wireDecode(const Block& block);
79 
80 protected:
81  uint32_t m_code;
82  std::string m_text;
84 
85  mutable Block m_wire;
86 };
87 
88 inline uint32_t
90 {
91  return m_code;
92 }
93 
94 inline ControlResponse&
96 {
97  m_code = code;
98  m_wire.reset();
99  return *this;
100 }
101 
102 inline const std::string&
104 {
105  return m_text;
106 }
107 
108 inline ControlResponse&
109 ControlResponse::setText(const std::string& text)
110 {
111  m_text = text;
112  m_wire.reset();
113  return *this;
114 }
115 
116 inline const Block&
118 {
119  return m_body;
120 }
121 
122 inline ControlResponse&
124 {
125  m_body = body;
126  m_body.encode(); // will do nothing if already encoded
127  m_wire.reset();
128  return *this;
129 }
130 
131 std::ostream&
132 operator<<(std::ostream& os, const ControlResponse& response);
133 
134 } // namespace mgmt
135 } // namespace ndn
136 
137 #endif // NDN_MGMT_CONTRO_RESPONSE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
const Block & getBody() const
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
const Block & wireEncode() const
const std::string & getText() const
void reset()
Reset wire buffer of the element.
Definition: block.cpp:302
std::ostream & operator<<(std::ostream &os, const ControlResponse &response)
Error(const std::string &what)
ControlResponse & setText(const std::string &text)
ControlResponse & setBody(const Block &body)
void wireDecode(const Block &block)
void encode()
Encode subblocks into wire buffer.
Definition: block.cpp:355
ControlCommand response.
ControlResponse & setCode(uint32_t code)
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50