Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MessageBuilder.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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * MessageBuilder.h
17  * Copyright (C) 2013 Simon Newton
18  *
19  * A class to simplify some of the E1.33 packet building operations.
20  */
21 
22 #ifndef INCLUDE_OLA_E133_MESSAGEBUILDER_H_
23 #define INCLUDE_OLA_E133_MESSAGEBUILDER_H_
24 
25 #include <ola/acn/CID.h>
26 #include <ola/base/Macro.h>
27 #include <ola/e133/E133Enums.h>
28 #include <ola/io/IOStack.h>
29 #include <ola/io/MemoryBlockPool.h>
30 #include <string>
31 
32 namespace ola {
33 namespace e133 {
34 
35 using ola::acn::CID;
36 using ola::io::IOStack;
37 using std::string;
38 
43  public:
44  MessageBuilder(const CID &cid, const string &source_name);
45  ~MessageBuilder() {}
46 
47  void PrependRDMHeader(IOStack *packet);
48 
49  void BuildNullTCPPacket(IOStack *packet);
50 
51  void BuildTCPE133StatusPDU(IOStack *packet,
52  uint32_t sequence_number, uint16_t endpoint_id,
53  ola::e133::E133StatusCode status_code,
54  const string &description);
55  void BuildUDPE133StatusPDU(IOStack *packet,
56  uint32_t sequence_number, uint16_t endpoint_id,
57  ola::e133::E133StatusCode status_code,
58  const string &description);
59 
60  void BuildTCPRootE133(IOStack *packet, uint32_t vector,
61  uint32_t sequence_number, uint16_t endpoint_id);
62  void BuildUDPRootE133(IOStack *packet, uint32_t vector,
63  uint32_t sequence_number, uint16_t endpoint_id);
64 
65  ola::io::MemoryBlockPool *pool() { return &m_memory_pool; }
66 
67  private:
68  const CID m_cid;
69  const string m_source_name;
70  ola::io::MemoryBlockPool m_memory_pool;
71 
72  DISALLOW_COPY_AND_ASSIGN(MessageBuilder);
73 };
74 } // namespace e133
75 } // namespace ola
76 #endif // INCLUDE_OLA_E133_MESSAGEBUILDER_H_