21 #ifndef PLUGINS_E131_E131_PDU_H_
22 #define PLUGINS_E131_E131_PDU_H_
25 #include <ola/io/OutputStream.h>
26 #include <ola/io/OutputBuffer.h>
45 explicit PDU(
unsigned int vector, vector_size size = FOUR_BYTES):
47 m_vector_size(size) {}
51 virtual unsigned int Size()
const;
52 virtual unsigned int VectorSize()
const {
return m_vector_size; }
53 virtual unsigned int HeaderSize()
const = 0;
54 virtual unsigned int DataSize()
const = 0;
57 void SetVector(
unsigned int vector) { m_vector = vector; }
63 virtual bool Pack(uint8_t *data,
unsigned int *length)
const;
64 virtual bool PackHeader(uint8_t *data,
unsigned int *length)
const = 0;
65 virtual bool PackData(uint8_t *data,
unsigned int *length)
const = 0;
76 uint8_t flags = VFLAG_MASK | HFLAG_MASK | DFLAG_MASK);
84 static const uint8_t VFLAG_MASK = 0x40;
86 static const uint8_t HFLAG_MASK = 0x20;
88 static const uint8_t DFLAG_MASK = 0x10;
91 unsigned int m_vector;
92 unsigned int m_vector_size;
96 static const unsigned int TWOB_LENGTH_LIMIT = 0x0FFF;
110 void AddPDU(
const C *msg) {
111 m_pdus.push_back(msg);
112 m_size += msg->Size();
121 unsigned int Size()
const {
return m_size; }
126 bool Pack(uint8_t *data,
unsigned int *length)
const;
134 std::vector<const C*> m_pdus;
149 typename std::vector<const C*>::const_iterator iter;
150 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
152 unsigned int remaining = i < *length ? *length - i : 0;
153 status &= (*iter)->Pack(data + i, &remaining);
168 typename std::vector<const C*>::const_iterator iter;
169 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
171 (*iter)->Write(stream);
177 #endif // PLUGINS_E131_E131_PDU_H_