BufferParameter.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 
11 namespace zeus {
12 
14  public Buffer {
15  protected:
16  mutable std::vector<std::pair<int32_t,std::vector<uint8_t>>> m_parameter;
17  public:
23  template<class ZEUS_TYPE_DATA>
24  ZEUS_TYPE_DATA getParameter(int32_t _id) const;
30  zeus::ParamType getParameterType(int32_t _id) const;
36  const uint8_t* getParameterPointer(int32_t _id) const;
42  uint32_t getParameterSize(int32_t _id) const;
47  uint16_t getNumberParameter() const;
55  void addParameter();
61  std::string simpleStringParam(uint32_t _id) const;
62  void composeWith(const uint8_t* _buffer, uint32_t _lenght) override;
63  bool writeOn(enet::WebSocket& _interface) override;
64  protected:
70  template<class ZEUS_TYPE_DATA>
71  void addParameter(uint16_t _paramId, const ZEUS_TYPE_DATA& _value);
72  public:
73  template<class ZEUS_TYPE_DATA>
74  void addParameter(const ZEUS_TYPE_DATA& _value) {
75  addParameter(m_parameter.size(), _value);
76  }
77  void parameterAppendBufferData(ememory::SharedPtr<zeus::BufferData> _obj);
78  };
79 }
const uint8_t * getParameterPointer(int32_t _id) const
Get the start pointer of the parameter.
void addParameter()
Add parameter (or not.. this is the end of an auto resursive add parameter)
bool writeOn(enet::WebSocket &_interface) override
Write the buffer on a specific interface.
ZEUS_TYPE_DATA getParameter(int32_t _id) const
Template to get a parameter with a specific type.
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 ...
uint16_t getNumberParameter() const
Get the number of parameter availlable.
Protocol buffer to transmit datas.
Definition: Buffer.hpp:110
Main zeus library namespace.
Definition: AbstractFunction.hpp:15
uint32_t getParameterSize(int32_t _id) const
Get the size of the parameter availlable in the parameter pointer.
std::string simpleStringParam(uint32_t _id) const
Convert the parameter in a simple human readable string.
zeus::ParamType getParameterType(int32_t _id) const
Get the type of a parameter.
Definition: BufferParameter.hpp:13
generisation of type of the type of the parameter
Definition: ParamType.hpp:14
void addParameterEmptyVector()
Add an empty vector with no type.
std::vector< std::pair< int32_t, std::vector< uint8_t > > > m_parameter
list of the parameter (offset of start data and buffer of data (subprotocol...)
Definition: BufferParameter.hpp:16