Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DescriptorConsistencyChecker.h
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * DescriptorConsistencyChecker.h
17  * Verify that we can determine the layout of a Descriptor.
18  *
19  * In order for the binary unpacker to work, we need to be able to determine
20  * the size and offset of every field within a descriptor, without consdering
21  * the data itself. This means the following are unsupported:
22  *
23  * - nested non-fixed sized groups
24  * - multiple variable-sized fields e.g multiple strings
25  * - variable-sized fields within groups
26  *
27  * Copyright (C) 2011 Simon Newton
28  */
29 
30 #ifndef COMMON_RDM_DESCRIPTORCONSISTENCYCHECKER_H_
31 #define COMMON_RDM_DESCRIPTORCONSISTENCYCHECKER_H_
32 
33 #include <ola/messaging/DescriptorVisitor.h>
34 #include <ola/messaging/Descriptor.h>
35 
36 namespace ola {
37 namespace rdm {
38 
39 
45  public:
47  : m_variable_sized_field_count(0) {
48  }
49 
50  bool Descend() const { return false; }
51  bool CheckConsistency(const ola::messaging::Descriptor *descriptor);
52 
53  void Visit(const ola::messaging::BoolFieldDescriptor*);
54  void Visit(const ola::messaging::IPV4FieldDescriptor*);
55  void Visit(const ola::messaging::UIDFieldDescriptor*);
56  void Visit(const ola::messaging::StringFieldDescriptor*);
57  void Visit(const ola::messaging::UInt8FieldDescriptor*);
58  void Visit(const ola::messaging::UInt16FieldDescriptor*);
59  void Visit(const ola::messaging::UInt32FieldDescriptor*);
60  void Visit(const ola::messaging::Int8FieldDescriptor*);
61  void Visit(const ola::messaging::Int16FieldDescriptor*);
62  void Visit(const ola::messaging::Int32FieldDescriptor*);
63  void Visit(const ola::messaging::FieldDescriptorGroup*);
64  void PostVisit(const ola::messaging::FieldDescriptorGroup*);
65 
66  private:
67  unsigned int m_variable_sized_field_count;
68 };
69 } // namespace rdm
70 } // namespace ola
71 #endif // COMMON_RDM_DESCRIPTORCONSISTENCYCHECKER_H_