21 #ifndef LIBS_ACN_PDU_H_
22 #define LIBS_ACN_PDU_H_
25 #include <ola/io/OutputStream.h>
26 #include <ola/io/OutputBuffer.h>
44 explicit PDU(
unsigned int vector, vector_size size = FOUR_BYTES):
46 m_vector_size(size) {}
50 virtual unsigned int Size()
const;
51 virtual unsigned int VectorSize()
const {
return m_vector_size; }
52 virtual unsigned int HeaderSize()
const = 0;
53 virtual unsigned int DataSize()
const = 0;
56 void SetVector(
unsigned int vector) { m_vector = vector; }
62 virtual bool Pack(uint8_t *data,
unsigned int *length)
const;
63 virtual bool PackHeader(uint8_t *data,
unsigned int *length)
const = 0;
64 virtual bool PackData(uint8_t *data,
unsigned int *length)
const = 0;
75 uint8_t flags = VFLAG_MASK | HFLAG_MASK | DFLAG_MASK);
83 static const uint8_t VFLAG_MASK = 0x40;
85 static const uint8_t HFLAG_MASK = 0x20;
87 static const uint8_t DFLAG_MASK = 0x10;
90 unsigned int m_vector;
91 unsigned int m_vector_size;
95 static const unsigned int TWOB_LENGTH_LIMIT = 0x0FFF;
109 void AddPDU(
const C *msg) {
110 m_pdus.push_back(msg);
111 m_size += msg->Size();
120 unsigned int Size()
const {
return m_size; }
125 bool Pack(uint8_t *data,
unsigned int *length)
const;
133 std::vector<const C*> m_pdus;
148 typename std::vector<const C*>::const_iterator iter;
149 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
151 unsigned int remaining = i < *length ? *length - i : 0;
152 status &= (*iter)->Pack(data + i, &remaining);
167 typename std::vector<const C*>::const_iterator iter;
168 for (iter = m_pdus.begin(); iter != m_pdus.end(); ++iter) {
170 (*iter)->Write(stream);
175 #endif // LIBS_ACN_PDU_H_
virtual void Write(ola::io::OutputStream *stream) const
Definition: PDU.cpp:117
Definition: OutputBuffer.h:36
Definition: OutputStream.h:53
void Write(ola::io::OutputStream *stream) const
Definition: PDU.h:166
static void PrependFlagsAndLength(ola::io::OutputBufferInterface *output, uint8_t flags=VFLAG_MASK|HFLAG_MASK|DFLAG_MASK)
Definition: PDU.cpp:152
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44