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>
49 PDU(
unsigned int vector, vector_size size = FOUR_BYTES):
51 m_vector_size(size) {}
55 virtual unsigned int Size()
const;
56 virtual unsigned int VectorSize()
const {
return m_vector_size; }
57 virtual unsigned int HeaderSize()
const = 0;
58 virtual unsigned int DataSize()
const = 0;
61 void SetVector(
unsigned int vector) { m_vector = vector; }
67 virtual bool Pack(uint8_t *data,
unsigned int *length)
const;
68 virtual bool PackHeader(uint8_t *data,
unsigned int *length)
const = 0;
69 virtual bool PackData(uint8_t *data,
unsigned int *length)
const = 0;
80 uint8_t flags = VFLAG_MASK | HFLAG_MASK | DFLAG_MASK);
88 static const uint8_t VFLAG_MASK = 0x40;
90 static const uint8_t HFLAG_MASK = 0x20;
92 static const uint8_t DFLAG_MASK = 0x10;
95 unsigned int m_vector;
96 unsigned int m_vector_size;
100 static const unsigned int TWOB_LENGTH_LIMIT = 0x0FFF;
114 void AddPDU(
const C *msg) {
115 m_pdus.push_back(msg);
116 m_size += msg->Size();
125 unsigned int Size()
const {
return m_size; }
130 bool Pack(uint8_t *data,
unsigned int *length)
const;
138 std::vector<const C*> m_pdus;
153 typename std::vector<const C*>::const_iterator iter;
154 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
156 unsigned int remaining = i < *length ? *length - i : 0;
157 status &= (*iter)->Pack(data + i, &remaining);
172 typename std::vector<const C*>::const_iterator iter;
173 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
175 (*iter)->Write(stream);
181 #endif // PLUGINS_E131_E131_PDU_H_