BufferAnswer.hpp
Go to the documentation of this file.
1 
6 #pragma once
7 #include <etk/types.hpp>
8 #include <enet/WebSocket.hpp>
9 #include <zeus/ParamType.hpp>
10 #include <zeus/BufferParameter.hpp>
11 
12 namespace zeus {
13 
14  class BufferAnswer :
15  public BufferParameter {
16  friend class zeus::Buffer;
17  protected:
18  std::string m_errorType;
19  std::string m_errorHelp;
20  protected:
25  m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::answer);
26  };
27  void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
28  void appendBufferData(ememory::SharedPtr<zeus::BufferData> _obj) override;
29  bool writeOn(enet::WebSocket& _interface) override;
30  void generateDisplay(std::ostream& _os) const override;
31  public:
37  public:
38  enum zeus::Buffer::typeMessage getType() const override {
40  }
45  template<class ZEUS_TYPE_DATA>
46  void addAnswer(const ZEUS_TYPE_DATA& _value) {
47  addParameter(_value);
48  }
53  // TODO : Do it better check error ... ==> can be good ...
54  template<class ZEUS_TYPE_DATA>
55  ZEUS_TYPE_DATA getAnswer() const {
56  return getParameter<ZEUS_TYPE_DATA>(0);
57  }
63  void addError(const std::string& _value, const std::string& _comment);
68  bool hasError() const;
73  const std::string& getError() const;
78  const std::string& getErrorHelp() const;
79  };
80 }
bool writeOn(enet::WebSocket &_interface) override
Write the buffer on a specific interface.
const std::string & getErrorHelp() const
get the error help (if exist)
void addAnswer(const ZEUS_TYPE_DATA &_value)
set the answer of the call
Definition: BufferAnswer.hpp:46
static ememory::SharedPtr< zeus::BufferAnswer > create()
Create a shared pointer on the BufferAnswer.
enum zeus::Buffer::typeMessage getType() const override
Get the type of the buffer.
Definition: BufferAnswer.hpp:38
void composeWith(const uint8_t *_buffer, uint32_t _lenght) override
When receive new data form websocket, it might be added by this input (set all the frame ...
void addParameter()
Add parameter (or not.. this is the end of an auto resursive add parameter)
headerBin m_header
header of the protocol
Definition: Buffer.hpp:134
void addError(const std::string &_value, const std::string &_comment)
Ann an error on the message answer.
ZEUS_TYPE_DATA getAnswer() const
get the answer value
Definition: BufferAnswer.hpp:55
const std::string & getError() const
get the error value (if exist)
Answer from a previous call.
bool hasError() const
Check if the answer have an error.
Protocol buffer to transmit datas.
Definition: Buffer.hpp:110
Definition: BufferAnswer.hpp:14
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
BufferAnswer()
basic constructor (hidden to force the use of ememory::SharedPtr) zeus::BufferAnswer::create ...
Definition: BufferAnswer.hpp:24
Definition: BufferParameter.hpp:13
typeMessage
Type of the massage send or receive.
Definition: Buffer.hpp:216