Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RootPDU.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * RootPDU.h
17  * Interface for the RootPDU class
18  * Copyright (C) 2007 Simon Newton
19  */
20 
21 #ifndef PLUGINS_E131_E131_ROOTPDU_H_
22 #define PLUGINS_E131_E131_ROOTPDU_H_
23 
24 #include <stdint.h>
25 
26 #include "ola/acn/CID.h"
27 #include "ola/io/IOStack.h"
28 
29 #include "plugins/e131/e131/PDU.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace e131 {
34 
35 class RootPDU: public PDU {
36  public:
37  explicit RootPDU(unsigned int vector):
38  PDU(vector),
39  m_block(NULL),
40  m_block_size(0) {}
41  RootPDU(unsigned int vector,
42  const ola::acn::CID &cid,
43  const PDUBlock<PDU> *block):
44  PDU(vector),
45  m_cid(cid),
46  m_block(block) {
47  m_block_size = block ? block->Size() : 0;
48  }
49  ~RootPDU() {}
50 
51  unsigned int HeaderSize() const { return ola::acn::CID::CID_LENGTH; }
52  unsigned int DataSize() const { return m_block_size; }
53  bool PackHeader(uint8_t *data, unsigned int *length) const;
54  bool PackData(uint8_t *data, unsigned int *length) const;
55 
56  void PackHeader(ola::io::OutputStream *stream) const;
57  void PackData(ola::io::OutputStream *stream) const;
58 
59  const ola::acn::CID &Cid() const { return m_cid; }
60  const ola::acn::CID &Cid(const ola::acn::CID &cid) { return m_cid = cid; }
61  void SetBlock(const PDUBlock<PDU> *block);
62 
63  static void PrependPDU(ola::io::IOStack *stack, uint32_t vector,
64  const ola::acn::CID &cid);
65 
66  private:
67  ola::acn::CID m_cid;
68  const PDUBlock<PDU> *m_block;
69  unsigned int m_block_size;
70 };
71 } // namespace e131
72 } // namespace plugin
73 } // namespace ola
74 #endif // PLUGINS_E131_E131_ROOTPDU_H_