Open Lighting Architecture  Latest Git
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 LIBS_ACN_ROOTPDU_H_
22 #define LIBS_ACN_ROOTPDU_H_
23 
24 #include <stdint.h>
25 
26 #include "ola/acn/CID.h"
27 #include "ola/io/IOStack.h"
28 
29 #include "libs/acn/PDU.h"
30 
31 namespace ola {
32 namespace acn {
33 
34 class RootPDU: public PDU {
35  public:
36  explicit RootPDU(unsigned int vector):
37  PDU(vector),
38  m_block(NULL),
39  m_block_size(0) {}
40  RootPDU(unsigned int vector,
41  const ola::acn::CID &cid,
42  const PDUBlock<PDU> *block):
43  PDU(vector),
44  m_cid(cid),
45  m_block(block) {
46  m_block_size = block ? block->Size() : 0;
47  }
48  ~RootPDU() {}
49 
50  unsigned int HeaderSize() const { return ola::acn::CID::CID_LENGTH; }
51  unsigned int DataSize() const { return m_block_size; }
52  bool PackHeader(uint8_t *data, unsigned int *length) const;
53  bool PackData(uint8_t *data, unsigned int *length) const;
54 
55  void PackHeader(ola::io::OutputStream *stream) const;
56  void PackData(ola::io::OutputStream *stream) const;
57 
58  const ola::acn::CID &Cid() const { return m_cid; }
59  const ola::acn::CID &Cid(const ola::acn::CID &cid) { return m_cid = cid; }
60  void SetBlock(const PDUBlock<PDU> *block);
61 
62  static void PrependPDU(ola::io::IOStack *stack, uint32_t vector,
63  const ola::acn::CID &cid);
64 
65  private:
66  ola::acn::CID m_cid;
67  const PDUBlock<PDU> *m_block;
68  unsigned int m_block_size;
69 };
70 } // namespace acn
71 } // namespace ola
72 #endif // LIBS_ACN_ROOTPDU_H_
Definition: CID.h:53
The ACN component identifier.
The ACN component identifier.
Definition: CID.h:47
Definition: OutputStream.h:54
Definition: RootPDU.h:34
Definition: PDU.h:36
Definition: IOStack.h:40
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: PDU.h:103