1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 | /**
* @file XabslParameters.h
*
* Definition of class Parameters
*
* @author <a href="http://www.sim.informatik.tu-darmstadt.de/pers/card/risler.html">Max Risler</a>
*/
#ifndef __XabslParameters_h_
#define __XabslParameters_h_
#include "XabslTools.h"
namespace xabsl
{
// class prototypes needed for declaration of Parameters
class Symbols;
class Enumeration;
class Option;
class State;
class DecimalExpression;
class BooleanExpression;
class EnumeratedExpression;
/**
* @class Parameters
*
* Represents the current set of parameters of a behavior or an input symbol
*/
class Parameters
{
public:
/**
* Constructor.
* @param errorHandler A reference to a ErrorHandler instance
*/
Parameters(ErrorHandler& errorHandler)<--- Class 'Parameters' has a constructor with 1 argument that is not explicit. [+]Class 'Parameters' has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided.
: errorHandler(errorHandler), pEnumerations(0)
{}
/**
* Destructor
*/
virtual ~Parameters() {};
/** Reset all parameters to default values (=0) */
void reset();
/** The decimal parameters */
NamedArray<double*> decimal;
/** The boolean parameters */
NamedArray<bool*> boolean;
/** The enumerated parameters */
NamedArray<int*> enumerated;
/** The enumeration domain of the enumerated parameters */
NamedArray<const Enumeration*> enumerations;
/**
* Registers a reference to the enumerations of the engine
* This is only required when registerEnumerated is called afterwards
*/
void registerEnumerations(NamedArray<Enumeration*>& enumerations);
/**
* Registers a reference to a decimal parameter at the parameters array.
* @param name The name of the parameter
* @param parameter The reference to a parameter
*/
void registerDecimal(const char* name, double& parameter);
/**
* Registers a reference to a boolean parameter at the parameters array.
* @param name The name of the parameter
* @param parameter The reference to a parameter
*/
void registerBoolean(const char* name, bool& parameter);
/**
* Registers a reference to an enumerated parameter at the parameters array.
* @param name The name of the parameter
* @param enumName The name of the corresponding enumeration
* @param parameter The reference to a parameter
*/
void registerEnumerated(const char* name, const char* enumName, int& parameter);
protected:
/** Used for error handling */
ErrorHandler& errorHandler;
private:
/** Pointer to the enumerations of the engine */
NamedArray<Enumeration*>* pEnumerations;
};
/**
* @class ParameterAssignment
*
* Represents the assignment of parameters of a subsequent basic behaviors or an option or an input symbol
*/
class ParameterAssignment : public Parameters
{
public:
/** Constructor.
* @param refParameters The referenced set of parameters
* @param errorHandler A reference to a ErrorHandler instance
*/
ParameterAssignment(
Parameters* refParameters,
ErrorHandler& errorHandler
);
/**
* Creates the parameter assignment.
* @param input An input source for the intermediate code. It must be opened and read until
* A position where a state starts.
* @param symbols All available symbols
* @param option The current option
* @param state The current state
*/
void create(
InputSource& input,
Symbols& symbols,
Option& option,
State& state);
/** Destructor */
~ParameterAssignment();
/** Adds a decimal parameter assignment
* @param param name of the parameter
* @param exp expression to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setDecimalParameter(const char* param, const DecimalExpression* exp);
/** Adds a decimal parameter assignment
* @param param name of the parameter
* @param value value to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setDecimalParameter(const char* param, double value);
/** Adds a boolean parameter assignment
* @param param name of the parameter
* @param exp expression to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setBooleanParameter(const char* param, const BooleanExpression* exp);
/** Adds a boolean parameter assignment
* @param param name of the parameter
* @param value value to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setBooleanParameter(const char* param, bool value);
/** Adds an enumerated parameter assignment
* @param param name of the parameter
* @param exp expression to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setEnumeratedParameter(const char* param, const EnumeratedExpression* exp);
/** Adds an enumerated parameter assignment
* @param param name of the parameter
* @param value value to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setEnumeratedParameter(const char* param, const Enumeration* enumeration, int value);
/** Adds an enumerated parameter assignment
* @param param name of the parameter
* @param value value to be set to the parameter value when executing
* @return False, if an error occurred
*/
bool setEnumeratedParameter(const char* param, const char* value);
/** Current parameter values, these are stored just for debugging purposes */
NamedArray<double> decimalValues;
NamedArray<bool> booleanValues;
NamedArray<int> enumeratedValues;
/** Decimal expressions for the parameters */
NamedArray<const DecimalExpression*> decimalExpressions;
/** Boolean expressions for the parameters */
NamedArray<const BooleanExpression*> booleanExpressions;
/** Enumerated expressions for the parameters */
NamedArray<const EnumeratedExpression*> enumeratedExpressions;
/**
* sets parameter variables to current expression values
* returns true when parameter values have been changed
*/
bool set();
};
} // namespace
#endif // __XabslParameters_h_
|