Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MessageSerializer.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library 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 GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * MessageSerializer.h
17  * Serialize a message.
18  * Copyright (C) 2011 Simon Newton
19  */
20 
29 #ifndef INCLUDE_OLA_RDM_MESSAGESERIALIZER_H_
30 #define INCLUDE_OLA_RDM_MESSAGESERIALIZER_H_
31 
32 #include <ola/messaging/MessageVisitor.h>
33 
34 namespace ola {
35 namespace rdm {
36 
37 
42  public:
43  explicit MessageSerializer(unsigned int initial_size = INITIAL_BUFFER_SIZE);
45 
46  const uint8_t *SerializeMessage(const ola::messaging::Message *message,
47  unsigned int *length);
48 
49  void Visit(const ola::messaging::BoolMessageField*);
50  void Visit(const ola::messaging::IPV4MessageField*);
51  void Visit(const ola::messaging::MACMessageField*);
52  void Visit(const ola::messaging::UIDMessageField*);
53  void Visit(const ola::messaging::StringMessageField*);
60  void Visit(const ola::messaging::GroupMessageField*);
61  void PostVisit(const ola::messaging::GroupMessageField*);
62 
63  private:
64  uint8_t *m_data;
65  unsigned int m_offset, m_buffer_size, m_initial_buffer_size;
66 
67  static const unsigned int INITIAL_BUFFER_SIZE = 256;
68 
69  void CheckForFreeSpace(unsigned int required_size);
70 
71  template <typename int_type>
72  void IntVisit(const ola::messaging::BasicMessageField<int_type> *);
73 };
74 } // namespace rdm
75 } // namespace ola
76 #endif // INCLUDE_OLA_RDM_MESSAGESERIALIZER_H_
Definition: MessageVisitor.h:43
Definition: Message.h:99
Definition: Message.h:73
Definition: Message.h:131
Definition: MessageSerializer.h:41
Definition: Message.h:157
Definition: Message.h:183
Definition: Message.h:39
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
const uint8_t * SerializeMessage(const ola::messaging::Message *message, unsigned int *length)
Definition: MessageSerializer.cpp:47
Definition: Message.h:208
Definition: Message.h:242