Open Lighting Architecture
0.9.1
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
GroupSizeCalculator.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
*
16
* GroupSizeCalculator.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_GROUPSIZECALCULATOR_H_
22
#define COMMON_RDM_GROUPSIZECALCULATOR_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
41
class
StaticGroupTokenCalculator
42
:
public
ola::messaging::FieldDescriptorVisitor
{
43
public
:
44
StaticGroupTokenCalculator
() {}
45
~
StaticGroupTokenCalculator
() {}
46
47
bool
Descend()
const
{
return
true
; }
48
bool
CalculateTokensRequired
(
49
const
class
ola::messaging::FieldDescriptorGroup
*,
50
unsigned
int
*token_count);
51
52
void
Visit(
const
ola::messaging::BoolFieldDescriptor
*);
53
void
Visit(
const
ola::messaging::IPV4FieldDescriptor
*);
54
void
Visit(
const
ola::messaging::MACFieldDescriptor
*);
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
std::stack<unsigned int> m_token_count;
68
bool
m_variable_sized_group_encountered;
69
};
70
71
76
class
GroupSizeCalculator
:
public
ola::messaging::FieldDescriptorVisitor
{
77
public
:
78
typedef
enum
{
79
INSUFFICIENT_TOKENS,
80
EXTRA_TOKENS,
81
NO_VARIABLE_GROUPS,
82
SINGLE_VARIABLE_GROUP,
83
MULTIPLE_VARIABLE_GROUPS,
84
NESTED_VARIABLE_GROUPS,
85
MISMATCHED_TOKENS,
86
} calculator_state;
87
88
GroupSizeCalculator
() {}
89
~
GroupSizeCalculator
() {}
90
91
bool
Descend()
const
{
return
false
; }
92
calculator_state
CalculateGroupSize
(
93
unsigned
int
token_count,
94
const
class
ola::messaging::Descriptor
*descriptor,
95
unsigned
int
*group_repeat_count);
96
97
void
Visit(
const
ola::messaging::BoolFieldDescriptor
*);
98
void
Visit(
const
ola::messaging::IPV4FieldDescriptor
*);
99
void
Visit(
const
ola::messaging::MACFieldDescriptor
*);
100
void
Visit(
const
ola::messaging::UIDFieldDescriptor
*);
101
void
Visit(
const
ola::messaging::StringFieldDescriptor
*);
102
void
Visit(
const
ola::messaging::UInt8FieldDescriptor
*);
103
void
Visit(
const
ola::messaging::UInt16FieldDescriptor
*);
104
void
Visit(
const
ola::messaging::UInt32FieldDescriptor
*);
105
void
Visit(
const
ola::messaging::Int8FieldDescriptor
*);
106
void
Visit(
const
ola::messaging::Int16FieldDescriptor
*);
107
void
Visit(
const
ola::messaging::Int32FieldDescriptor
*);
108
void
Visit(
const
ola::messaging::FieldDescriptorGroup
*);
109
void
PostVisit(
const
ola::messaging::FieldDescriptorGroup
*);
110
111
private
:
112
std::vector<const ola::messaging::FieldDescriptorGroup*> m_groups;
113
std::vector<const ola::messaging::FieldDescriptorInterface*> m_non_groups;
114
StaticGroupTokenCalculator
m_simple_calculator;
115
116
unsigned
int
DetermineGroupSize(
const
117
ola::messaging::FieldDescriptorGroup
*);
118
};
119
}
// namespace rdm
120
}
// namespace ola
121
#endif // COMMON_RDM_GROUPSIZECALCULATOR_H_
Generated on Tue Jun 24 2014 03:57:51 for Open Lighting Architecture by
1.8.1.2