Open Lighting Architecture  Latest Git
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 
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 
38 namespace ola {
39 namespace rdm {
40 
41 
46  public:
49 
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*);
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>
88 };
89 } // namespace rdm
90 } // namespace ola
91 #endif // INCLUDE_OLA_RDM_MESSAGEDESERIALIZER_H_
Definition: Descriptor.h:84
Definition: DescriptorVisitor.h:43
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
Definition: Descriptor.h:122
Definition: Descriptor.h:324
Definition: MessageDeserializer.h:45
Definition: Descriptor.h:141
Definition: Descriptor.h:103
Definition: Descriptor.h:160
Definition: Message.h:39
Definition: Descriptor.h:403
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: Descriptor.h:190