Open Lighting Architecture: include/ola/rdm/MessageSerializer.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
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
28
29#ifndef INCLUDE_OLA_RDM_MESSAGESERIALIZER_H_
30#define INCLUDE_OLA_RDM_MESSAGESERIALIZER_H_
31
32#include <ola/messaging/MessageVisitor.h>
33
34namespace ola {
35namespace rdm {
36
37
41 class MessageSerializer: public ola::messaging::MessageVisitor {
42 public:
43 explicit MessageSerializer(unsigned int initial_size = INITIAL_BUFFER_SIZE);
44 ~MessageSerializer();
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*);
54 void Visit(const ola::messaging::BasicMessageField<uint8_t>*);
55 void Visit(const ola::messaging::BasicMessageField<uint16_t>*);
56 void Visit(const ola::messaging::BasicMessageField<uint32_t>*);
57 void Visit(const ola::messaging::BasicMessageField<int8_t>*);
58 void Visit(const ola::messaging::BasicMessageField<int16_t>*);
59 void Visit(const ola::messaging::BasicMessageField<int32_t>*);
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_
ola::messaging::BasicMessageField
Definition Message.h:208
ola::messaging::BoolMessageField
Definition Message.h:73
ola::messaging::GroupMessageField
Definition Message.h:242
ola::messaging::IPV4MessageField
Definition Message.h:99
ola::messaging::MACMessageField
Definition Message.h:131
ola::messaging::Message
Definition Message.h:39
ola::messaging::MessageVisitor
Definition MessageVisitor.h:43
ola::messaging::StringMessageField
Definition Message.h:183
ola::messaging::UIDMessageField
Definition Message.h:157
ola::rdm::MessageSerializer::SerializeMessage
const uint8_t * SerializeMessage(const ola::messaging::Message *message, unsigned int *length)
Definition MessageSerializer.cpp:47
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44