Open Lighting Architecture
 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/e133/E133Enums.h>
27 #include <ola/io/IOStack.h>
28 #include <ola/io/MemoryBlockPool.h>
29 #include <string>
30 
31 namespace ola {
32 namespace e133 {
33 
34 using ola::acn::CID;
35 using ola::io::IOStack;
36 using std::string;
37 
42  public:
43  MessageBuilder(const CID &cid, const string &source_name);
44  ~MessageBuilder() {}
45 
46  void PrependRDMHeader(IOStack *packet);
47 
48  void BuildNullTCPPacket(IOStack *packet);
49 
50  void BuildTCPE133StatusPDU(IOStack *packet,
51  uint32_t sequence_number, uint16_t endpoint_id,
52  ola::e133::E133StatusCode status_code,
53  const string &description);
54  void BuildUDPE133StatusPDU(IOStack *packet,
55  uint32_t sequence_number, uint16_t endpoint_id,
56  ola::e133::E133StatusCode status_code,
57  const string &description);
58 
59  void BuildTCPRootE133(IOStack *packet, uint32_t vector,
60  uint32_t sequence_number, uint16_t endpoint_id);
61  void BuildUDPRootE133(IOStack *packet, uint32_t vector,
62  uint32_t sequence_number, uint16_t endpoint_id);
63 
64  ola::io::MemoryBlockPool *pool() { return &m_memory_pool; }
65 
66  private:
67  const CID m_cid;
68  const string m_source_name;
69  ola::io::MemoryBlockPool m_memory_pool;
70 };
71 } // namespace e133
72 } // namespace ola
73 #endif // INCLUDE_OLA_E133_MESSAGEBUILDER_H_