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

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
StringMessageBuilder.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 * StringMessageBuilder.h
17 * Builds a Message object from a list of strings & a Descriptor.
18 * Copyright (C) 2011 Simon Newton
19 */
20
28
29#ifndef INCLUDE_OLA_RDM_STRINGMESSAGEBUILDER_H_
30#define INCLUDE_OLA_RDM_STRINGMESSAGEBUILDER_H_
31
32#include <ola/messaging/DescriptorVisitor.h>
33#include <stack>
34#include <string>
35#include <vector>
36
37namespace ola {
38
39namespace messaging {
40class Descriptor;
41class MessageFieldInterface;
42class Message;
43}
44
45namespace rdm {
46
51 class StringMessageBuilder: public ola::messaging::FieldDescriptorVisitor {
52 public:
53 StringMessageBuilder();
54 ~StringMessageBuilder();
55
56 // we handle descending into groups ourself
57 bool Descend() const { return false; }
58 const ola::messaging::Message *GetMessage(
59 const std::vector<std::string> &inputs,
60 const class ola::messaging::Descriptor *descriptor);
61 const std::string GetError() const { return m_error_string; }
62
63 void Visit(const ola::messaging::BoolFieldDescriptor*);
64 void Visit(const ola::messaging::IPV4FieldDescriptor*);
65 void Visit(const ola::messaging::MACFieldDescriptor*);
66 void Visit(const ola::messaging::UIDFieldDescriptor*);
67 void Visit(const ola::messaging::StringFieldDescriptor*);
68 void Visit(const ola::messaging::UInt8FieldDescriptor*);
69 void Visit(const ola::messaging::UInt16FieldDescriptor*);
70 void Visit(const ola::messaging::UInt32FieldDescriptor*);
71 void Visit(const ola::messaging::Int8FieldDescriptor*);
72 void Visit(const ola::messaging::Int16FieldDescriptor*);
73 void Visit(const ola::messaging::Int32FieldDescriptor*);
74 void Visit(const ola::messaging::FieldDescriptorGroup*);
75 void PostVisit(const ola::messaging::FieldDescriptorGroup*);
76
77 private:
78 std::vector<std::string> m_inputs;
79 std::stack<
80 std::vector<const ola::messaging::MessageFieldInterface*> > m_groups;
81 unsigned int m_offset, m_input_size, m_group_instance_count;
82 bool m_error;
83 std::string m_error_string;
84
85 bool StopParsing() const;
86 void SetError(const std::string &error);
87
88 template<typename type>
89 void VisitInt(const ola::messaging::IntegerFieldDescriptor<type> *);
90
91 void InitVars(const std::vector<std::string> &inputs);
92 void CleanUpVector();
93};
94} // namespace rdm
95} // namespace ola
96#endif // INCLUDE_OLA_RDM_STRINGMESSAGEBUILDER_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::MessageFieldInterface
Definition Message.h:60
ola::messaging::Message
Definition Message.h:39
ola::messaging::StringFieldDescriptor
Definition Descriptor.h:160
ola::messaging::UIDFieldDescriptor
Definition Descriptor.h:141
ola::rdm::StringMessageBuilder::GetMessage
const ola::messaging::Message * GetMessage(const std::vector< std::string > &inputs, const class ola::messaging::Descriptor *descriptor)
Get the Message object that this Builder created.
Definition StringMessageBuilder.cpp:70
ola::rdm::StringMessageBuilder::~StringMessageBuilder
~StringMessageBuilder()
Clean up.
Definition StringMessageBuilder.cpp:57
ola::rdm::StringMessageBuilder::PostVisit
void PostVisit(const ola::messaging::FieldDescriptorGroup *)
Definition StringMessageBuilder.cpp:318
ola::rdm::StringMessageBuilder::Visit
void Visit(const ola::messaging::BoolFieldDescriptor *)
Definition StringMessageBuilder.cpp:128
ola::messaging
A framework for serializing simple message structures.
Definition Descriptor.cpp:25
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44