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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
MessageDeserializer.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 * MessageDeserializer.h
17 * Inflate a message from raw data.
18 * Copyright (C) 2011 Simon Newton
19 */
20
29
30#ifndef INCLUDE_OLA_RDM_MESSAGEDESERIALIZER_H_
31#define INCLUDE_OLA_RDM_MESSAGEDESERIALIZER_H_
32
33#include <ola/messaging/DescriptorVisitor.h>
34#include <ola/messaging/Message.h>
35#include <stack>
36#include <vector>
37
38namespace ola {
39namespace rdm {
40
41
45 class MessageDeserializer: public ola::messaging::FieldDescriptorVisitor {
46 public:
47 MessageDeserializer();
48 ~MessageDeserializer();
49
50 const ola::messaging::Message *InflateMessage(
51 const class ola::messaging::Descriptor *descriptor,
52 const uint8_t *data,
53 unsigned int length);
54
55 // we handle descending into groups ourself
56 bool Descend() const { return false; }
57
58 void Visit(const ola::messaging::BoolFieldDescriptor*);
59 void Visit(const ola::messaging::IPV4FieldDescriptor*);
60 void Visit(const ola::messaging::MACFieldDescriptor*);
61 void Visit(const ola::messaging::UIDFieldDescriptor*);
62 void Visit(const ola::messaging::StringFieldDescriptor*);
63 void Visit(const ola::messaging::IntegerFieldDescriptor<uint8_t>*);
64 void Visit(const ola::messaging::IntegerFieldDescriptor<uint16_t>*);
65 void Visit(const ola::messaging::IntegerFieldDescriptor<uint32_t>*);
66 void Visit(const ola::messaging::IntegerFieldDescriptor<int8_t>*);
67 void Visit(const ola::messaging::IntegerFieldDescriptor<int16_t>*);
68 void Visit(const ola::messaging::IntegerFieldDescriptor<int32_t>*);
69 void Visit(const ola::messaging::FieldDescriptorGroup*);
70 void PostVisit(const ola::messaging::FieldDescriptorGroup*) {}
71
72 private:
73 const uint8_t *m_data;
74 unsigned int m_length;
75 unsigned int m_offset;
76 unsigned int m_variable_field_size;
77 bool m_insufficient_data;
78
79 typedef std::vector<const ola::messaging::MessageFieldInterface*>
80 message_vector;
81 std::stack<message_vector> m_message_stack;
82
83 bool CheckForData(unsigned int required_size);
84 void CleanUpVector();
85
86 template <typename int_type>
87 void IntVisit(const ola::messaging::IntegerFieldDescriptor<int_type> *);
88};
89} // namespace rdm
90} // namespace ola
91#endif // INCLUDE_OLA_RDM_MESSAGEDESERIALIZER_H_
ola::messaging::BoolFieldDescriptor
Definition Descriptor.h:84
ola::messaging::Descriptor
Definition Descriptor.h:399
ola::messaging::FieldDescriptorGroup
Definition Descriptor.h:320
ola::messaging::FieldDescriptorVisitor
Definition DescriptorVisitor.h:43
ola::messaging::IPV4FieldDescriptor
Definition Descriptor.h:103
ola::messaging::IntegerFieldDescriptor
Definition Descriptor.h:190
ola::messaging::MACFieldDescriptor
Definition Descriptor.h:122
ola::messaging::Message
Definition Message.h:39
ola::messaging::StringFieldDescriptor
Definition Descriptor.h:160
ola::messaging::UIDFieldDescriptor
Definition Descriptor.h:141
ola::rdm::MessageDeserializer::InflateMessage
const ola::messaging::Message * InflateMessage(const class ola::messaging::Descriptor *descriptor, const uint8_t *data, unsigned int length)
Deserialize a memory location and return a message.
Definition MessageDeserializer.cpp:55
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44