BufferData.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/Buffer.hpp>
11 
12 namespace zeus {
13 
14  class BufferData:
15  public Buffer {
16  friend class zeus::Buffer;
17  protected:
18  uint32_t m_partId;
19  uint16_t m_parameterId;
20  std::vector<uint8_t> m_data;
21  protected:
26  m_partId(0) {
27  m_header.flags = ZEUS_BUFFER_FLAG_FINISH + uint8_t(zeus::Buffer::typeMessage::data);
28  };
29  void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
30  // TODO :... void appendBufferData(ememory::SharedPtr<zeus::BufferData> _obj) override;
31  bool writeOn(enet::WebSocket& _interface) override;
32  void generateDisplay(std::ostream& _os) const override;
33  public:
39  public:
40  enum zeus::Buffer::typeMessage getType() const override {
42  }
47  uint16_t getParameterId() const {
48  return m_parameterId;
49  }
54  uint32_t getPartId() const;
59  void setPartId(uint32_t _value);
66  void addData(uint16_t _parameterId, void* _data, uint32_t _size);
70  const std::vector<uint8_t>& getData() const {
71  return m_data;
72  }
73 
74  };
75 }
data message happend when partId > 0 it compleate the data of a parameter or an answer or an event ...
bool writeOn(enet::WebSocket &_interface) override
Write the buffer on a specific interface.
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 ...
headerBin m_header
header of the protocol
Definition: Buffer.hpp:134
uint16_t getParameterId() const
Get the parameter Id of the buffer.
Definition: BufferData.hpp:47
enum zeus::Buffer::typeMessage getType() const override
Get the type of the buffer.
Definition: BufferData.hpp:40
void addData(uint16_t _parameterId, void *_data, uint32_t _size)
add a raw data on the buffer
Protocol buffer to transmit datas.
Definition: Buffer.hpp:110
const std::vector< uint8_t > & getData() const
Get data reference.
Definition: BufferData.hpp:70
BufferData()
basic constructor (hidden to force the use of ememory::SharedPtr) zeus::BufferData::create ...
Definition: BufferData.hpp:25
uint32_t getPartId() const
Get the part Id of the buffer.
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
void setPartId(uint32_t _value)
Set the part Id of the buffer.
static ememory::SharedPtr< zeus::BufferData > create()
Create a shared pointer on the BufferData.
Definition: BufferData.hpp:14
typeMessage
Type of the massage send or receive.
Definition: Buffer.hpp:216