Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
E133Header.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  * E133Header.h
17  * The E1.33 Header
18  * Copyright (C) 2011 Simon Newton
19  */
20 
21 #ifndef PLUGINS_E131_E131_E133HEADER_H_
22 #define PLUGINS_E131_E131_E133HEADER_H_
23 
24 #include <ola/base/Macro.h>
25 
26 #include <stdint.h>
27 #include <string>
28 
29 namespace ola {
30 namespace plugin {
31 namespace e131 {
32 
33 /*
34  * Header for the E133 layer
35  */
36 class E133Header {
37  public:
38  E133Header() {}
39  E133Header(const std::string &source,
40  uint32_t sequence,
41  uint16_t endpoint)
42  : m_source(source),
43  m_sequence(sequence),
44  m_endpoint(endpoint) {
45  }
46  ~E133Header() {}
47 
48  const std::string Source() const { return m_source; }
49  uint32_t Sequence() const { return m_sequence; }
50  uint16_t Endpoint() const { return m_endpoint; }
51 
52  bool operator==(const E133Header &other) const {
53  return m_source == other.m_source &&
54  m_sequence == other.m_sequence &&
55  m_endpoint == other.m_endpoint;
56  }
57 
58  enum { SOURCE_NAME_LEN = 64 };
59 
60  PACK(
61  struct e133_pdu_header_s {
62  char source[SOURCE_NAME_LEN];
63  uint32_t sequence;
64  uint16_t endpoint;
65  uint8_t reserved;
66  });
67  typedef struct e133_pdu_header_s e133_pdu_header;
68 
69  private:
70  std::string m_source;
71  uint32_t m_sequence;
72  uint16_t m_endpoint;
73 };
74 } // namespace e131
75 } // namespace plugin
76 } // namespace ola
77 #endif // PLUGINS_E131_E131_E133HEADER_H_