Open Lighting Architecture
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
common
rdm
VariableFieldSizeCalculator.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
* VariableFieldSizeCalculator.h
17
* Calculate the number of items in a group, given a fixed number of tokens.
18
* Copyright (C) 2011 Simon Newton
19
*/
20
21
#ifndef COMMON_RDM_VARIABLEFIELDSIZECALCULATOR_H_
22
#define COMMON_RDM_VARIABLEFIELDSIZECALCULATOR_H_
23
24
#include <ola/messaging/DescriptorVisitor.h>
25
#include <stack>
26
#include <vector>
27
28
namespace
ola {
29
30
namespace
messaging {
31
class
Descriptor;
32
}
33
34
namespace
rdm {
35
36
using
std::vector;
37
using
ola::messaging::FieldDescriptorInterface
;
38
using
ola::messaging::StringFieldDescriptor
;
39
using
ola::messaging::FieldDescriptorGroup
;
40
41
46
class
VariableFieldSizeCalculator
47
:
public
ola::messaging::FieldDescriptorVisitor
{
48
public
:
49
typedef
enum
{
50
TOO_SMALL,
51
TOO_LARGE,
52
FIXED_SIZE,
53
VARIABLE_STRING,
54
VARIABLE_GROUP,
55
MULTIPLE_VARIABLE_FIELDS,
56
NESTED_VARIABLE_GROUPS,
57
MISMATCHED_SIZE,
58
} calculator_state;
59
60
VariableFieldSizeCalculator
() {}
61
~
VariableFieldSizeCalculator
() {}
62
63
bool
Descend()
const
{
return
false
; }
64
calculator_state
CalculateFieldSize
(
65
unsigned
int
data_size,
66
const
class
ola::messaging::Descriptor
*,
67
unsigned
int
*variable_field_repeat_count);
68
69
void
Visit(
const
ola::messaging::BoolFieldDescriptor
*);
70
void
Visit(
const
ola::messaging::IPV4FieldDescriptor
*);
71
void
Visit(
const
ola::messaging::UIDFieldDescriptor
*);
72
void
Visit(
const
ola::messaging::StringFieldDescriptor
*);
73
void
Visit(
const
ola::messaging::UInt8FieldDescriptor
*);
74
void
Visit(
const
ola::messaging::UInt16FieldDescriptor
*);
75
void
Visit(
const
ola::messaging::UInt32FieldDescriptor
*);
76
void
Visit(
const
ola::messaging::Int8FieldDescriptor
*);
77
void
Visit(
const
ola::messaging::Int16FieldDescriptor
*);
78
void
Visit(
const
ola::messaging::Int32FieldDescriptor
*);
79
void
Visit(
const
ola::messaging::FieldDescriptorGroup
*);
80
void
PostVisit(
const
ola::messaging::FieldDescriptorGroup
*) {}
81
82
private
:
83
unsigned
int
m_fixed_size_sum;
84
vector<const StringFieldDescriptor*> m_variable_string_fields;
85
vector<const FieldDescriptorGroup*> m_variable_group_fields;
86
87
unsigned
int
DetermineGroupSize(
const
88
ola::messaging::FieldDescriptorGroup
*);
89
};
90
}
// namespace rdm
91
}
// namespace ola
92
#endif // COMMON_RDM_VARIABLEFIELDSIZECALCULATOR_H_
Generated on Fri Apr 4 2014 11:54:22 for Open Lighting Architecture by
1.8.1.2