1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* * |
7 |
* This program is free software; you can redistribute it and/or modify * |
8 |
* it under the terms of the GNU General Public License as published by * |
9 |
* the Free Software Foundation; either version 2 of the License, or * |
10 |
* (at your option) any later version. * |
11 |
* * |
12 |
* This program is distributed in the hope that it will be useful, * |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
* GNU General Public License for more details. * |
16 |
* * |
17 |
* You should have received a copy of the GNU General Public License * |
18 |
* along with this program; if not, write to the Free Software * |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
* MA 02111-1307 USA * |
21 |
***************************************************************************/ |
22 |
|
23 |
#ifndef __LS_DEVICE_PARAMETER_H__ |
24 |
#define __LS_DEVICE_PARAMETER_H__ |
25 |
|
26 |
#include <map> |
27 |
#include <vector> |
28 |
|
29 |
#include "../common/global.h" |
30 |
#include "../common/optional.h" |
31 |
#include "../common/LinuxSamplerException.h" |
32 |
#include "Device.h" |
33 |
|
34 |
namespace LinuxSampler { |
35 |
|
36 |
// TODO: All plurar parameter classes (except for String) have to be added (namely DeviceRuntimeParameterBools, DeviceRuntimeParameterInts, DeviceRuntimeParameterFloats, DeviceCreationParameterBools, DeviceCreationParameterInts, DeviceCreationParameterFloats), I ignored them for the moment, because they were not that necessary. |
37 |
|
38 |
class DeviceRuntimeParameter { |
39 |
public: |
40 |
virtual String Type() = 0; |
41 |
virtual String Description() = 0; |
42 |
virtual bool Fix() = 0; |
43 |
virtual bool Multiplicity() = 0; |
44 |
virtual optional<String> RangeMin() = 0; |
45 |
virtual optional<String> RangeMax() = 0; |
46 |
virtual optional<String> Possibilities() = 0; |
47 |
virtual String Value() = 0; |
48 |
virtual void SetValue(String val) throw (LinuxSamplerException) = 0; |
49 |
}; |
50 |
|
51 |
class DeviceRuntimeParameterBool : public DeviceRuntimeParameter { |
52 |
public: |
53 |
DeviceRuntimeParameterBool(bool bVal); |
54 |
virtual String Type(); |
55 |
virtual bool Multiplicity(); |
56 |
virtual optional<String> RangeMin(); |
57 |
virtual optional<String> RangeMax(); |
58 |
virtual optional<String> Possibilities(); |
59 |
virtual String Value(); |
60 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
61 |
|
62 |
virtual bool ValueAsBool(); |
63 |
virtual void SetValue(bool b) throw (LinuxSamplerException); |
64 |
|
65 |
virtual void OnSetValue(bool b) throw (LinuxSamplerException) = 0; |
66 |
protected: |
67 |
bool bVal; |
68 |
}; |
69 |
|
70 |
class DeviceRuntimeParameterInt : public DeviceRuntimeParameter { |
71 |
public: |
72 |
DeviceRuntimeParameterInt(int iVal); |
73 |
virtual String Type(); |
74 |
virtual bool Multiplicity(); |
75 |
virtual optional<String> RangeMin(); |
76 |
virtual optional<String> RangeMax(); |
77 |
virtual optional<String> Possibilities(); |
78 |
virtual String Value(); |
79 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
80 |
|
81 |
virtual int ValueAsInt(); |
82 |
virtual void SetValue(int i) throw (LinuxSamplerException); |
83 |
|
84 |
virtual optional<int> RangeMinAsInt() = 0; |
85 |
virtual optional<int> RangeMaxAsInt() = 0; |
86 |
virtual std::vector<int> PossibilitiesAsInt() = 0; |
87 |
virtual void OnSetValue(int i) throw (LinuxSamplerException) = 0; |
88 |
protected: |
89 |
int iVal; |
90 |
}; |
91 |
|
92 |
class DeviceRuntimeParameterFloat : public DeviceRuntimeParameter { |
93 |
public: |
94 |
DeviceRuntimeParameterFloat(float fVal); |
95 |
virtual String Type(); |
96 |
virtual bool Multiplicity(); |
97 |
virtual optional<String> RangeMin(); |
98 |
virtual optional<String> RangeMax(); |
99 |
virtual optional<String> Possibilities(); |
100 |
virtual String Value(); |
101 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
102 |
|
103 |
virtual float ValueAsFloat(); |
104 |
virtual void SetValue(float f) throw (LinuxSamplerException); |
105 |
|
106 |
virtual optional<float> RangeMinAsFloat() = 0; |
107 |
virtual optional<float> RangeMaxAsFloat() = 0; |
108 |
virtual std::vector<float> PossibilitiesAsFloat() = 0; |
109 |
virtual void OnSetValue(float f) = 0; |
110 |
protected: |
111 |
float fVal; |
112 |
}; |
113 |
|
114 |
class DeviceRuntimeParameterString : public DeviceRuntimeParameter { |
115 |
public: |
116 |
DeviceRuntimeParameterString(String sVal); |
117 |
virtual String Type(); |
118 |
virtual bool Multiplicity(); |
119 |
virtual optional<String> RangeMin(); |
120 |
virtual optional<String> RangeMax(); |
121 |
virtual optional<String> Possibilities(); |
122 |
virtual String Value(); |
123 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
124 |
|
125 |
virtual String ValueAsString(); |
126 |
virtual void SetValueAsString(String s) throw (LinuxSamplerException); |
127 |
|
128 |
virtual std::vector<String> PossibilitiesAsString() = 0; |
129 |
virtual void OnSetValue(String s) = 0; |
130 |
protected: |
131 |
String sVal; |
132 |
}; |
133 |
|
134 |
class DeviceRuntimeParameterStrings : public DeviceRuntimeParameter { |
135 |
public: |
136 |
DeviceRuntimeParameterStrings(std::vector<String> vS); |
137 |
virtual String Type(); |
138 |
virtual bool Multiplicity(); |
139 |
virtual optional<String> RangeMin(); |
140 |
virtual optional<String> RangeMax(); |
141 |
virtual optional<String> Possibilities(); |
142 |
virtual String Value(); |
143 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
144 |
|
145 |
virtual std::vector<String> ValueAsStrings(); |
146 |
virtual void SetValue(std::vector<String> vS) throw (LinuxSamplerException); |
147 |
|
148 |
virtual std::vector<String> PossibilitiesAsString() = 0; |
149 |
virtual void OnSetValue(std::vector<String> vS) = 0; |
150 |
protected: |
151 |
std::vector<String> sVals; |
152 |
}; |
153 |
|
154 |
|
155 |
|
156 |
class DeviceCreationParameter : public DeviceRuntimeParameter { |
157 |
public: |
158 |
DeviceCreationParameter ( void ) { pDevice = NULL; } |
159 |
virtual bool Mandatory() = 0; |
160 |
virtual optional<String> Depends(); |
161 |
virtual std::map<String,DeviceCreationParameter*> DependsAsParameters() = 0; |
162 |
virtual optional<String> Default(); |
163 |
virtual optional<String> Default(std::map<String,String> Parameters) = 0; |
164 |
virtual optional<String> RangeMin(); |
165 |
virtual optional<String> RangeMin(std::map<String,String> Parameters) = 0; |
166 |
virtual optional<String> RangeMax(); |
167 |
virtual optional<String> RangeMax(std::map<String,String> Parameters) = 0; |
168 |
virtual optional<String> Possibilities(); |
169 |
virtual optional<String> Possibilities(std::map<String,String> Parameters) = 0; |
170 |
void Attach(Device* pDevice) { this->pDevice = pDevice; } |
171 |
protected: |
172 |
Device* pDevice; |
173 |
}; |
174 |
|
175 |
class DeviceCreationParameterBool : public DeviceCreationParameter { |
176 |
public: |
177 |
DeviceCreationParameterBool(bool bVal = false); |
178 |
DeviceCreationParameterBool(String val) throw (LinuxSamplerException); |
179 |
virtual String Type(); |
180 |
virtual bool Multiplicity(); |
181 |
virtual optional<String> Default(std::map<String,String> Parameters); |
182 |
virtual optional<String> RangeMin(std::map<String,String> Parameters); |
183 |
virtual optional<String> RangeMax(std::map<String,String> Parameters); |
184 |
virtual optional<String> Possibilities(std::map<String,String> Parameters); |
185 |
virtual String Value(); |
186 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
187 |
|
188 |
virtual bool ValueAsBool(); |
189 |
virtual void SetValue(bool b) throw (LinuxSamplerException); |
190 |
|
191 |
virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters) = 0; |
192 |
virtual void OnSetValue(bool b) throw (LinuxSamplerException) = 0; |
193 |
protected: |
194 |
bool bVal; |
195 |
void InitWithDefault(); |
196 |
private: |
197 |
}; |
198 |
|
199 |
class DeviceCreationParameterInt : public DeviceCreationParameter { |
200 |
public: |
201 |
DeviceCreationParameterInt(int iVal = 0); |
202 |
DeviceCreationParameterInt(String val) throw (LinuxSamplerException); |
203 |
virtual String Type(); |
204 |
virtual bool Multiplicity(); |
205 |
virtual optional<String> Default(std::map<String,String> Parameters); |
206 |
virtual optional<String> RangeMin(std::map<String,String> Parameters); |
207 |
virtual optional<String> RangeMax(std::map<String,String> Parameters); |
208 |
virtual optional<String> Possibilities(std::map<String,String> Parameters); |
209 |
virtual String Value(); |
210 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
211 |
|
212 |
virtual int ValueAsInt(); |
213 |
virtual void SetValue(int i) throw (LinuxSamplerException); |
214 |
|
215 |
virtual optional<int> DefaultAsInt(std::map<String,String> Parameters) = 0; |
216 |
virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters) = 0; |
217 |
virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters) = 0; |
218 |
virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) = 0; |
219 |
virtual void OnSetValue(int i) throw (LinuxSamplerException) = 0; |
220 |
protected: |
221 |
int iVal; |
222 |
void InitWithDefault(); |
223 |
private: |
224 |
}; |
225 |
|
226 |
class DeviceCreationParameterFloat : public DeviceCreationParameter { |
227 |
public: |
228 |
DeviceCreationParameterFloat(float fVal = 0.0); |
229 |
DeviceCreationParameterFloat(String val) throw (LinuxSamplerException); |
230 |
virtual String Type(); |
231 |
virtual bool Multiplicity(); |
232 |
virtual optional<String> Default(std::map<String,String> Parameters); |
233 |
virtual optional<String> RangeMin(std::map<String,String> Parameters); |
234 |
virtual optional<String> RangeMax(std::map<String,String> Parameters); |
235 |
virtual optional<String> Possibilities(std::map<String,String> Parameters); |
236 |
virtual String Value(); |
237 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
238 |
|
239 |
virtual float ValueAsFloat(); |
240 |
virtual void SetValue(float f) throw (LinuxSamplerException); |
241 |
|
242 |
virtual optional<float> DefaultAsFloat(std::map<String,String> Parameters) = 0; |
243 |
virtual optional<float> RangeMinAsFloat(std::map<String,String> Parameters) = 0; |
244 |
virtual optional<float> RangeMaxAsFloat(std::map<String,String> Parameters) = 0; |
245 |
virtual std::vector<float> PossibilitiesAsFloat(std::map<String,String> Parameters) = 0; |
246 |
virtual void OnSetValue(float f) throw (LinuxSamplerException) = 0; |
247 |
protected: |
248 |
float fVal; |
249 |
void InitWithDefault(); |
250 |
private: |
251 |
}; |
252 |
|
253 |
class DeviceCreationParameterString : public DeviceCreationParameter { |
254 |
public: |
255 |
DeviceCreationParameterString(String sVal = String()); |
256 |
virtual String Type(); |
257 |
virtual bool Multiplicity(); |
258 |
virtual optional<String> Default(std::map<String,String> Parameters); |
259 |
virtual optional<String> RangeMin(std::map<String,String> Parameters); |
260 |
virtual optional<String> RangeMax(std::map<String,String> Parameters); |
261 |
virtual optional<String> Possibilities(std::map<String,String> Parameters); |
262 |
virtual String Value(); |
263 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
264 |
|
265 |
virtual String ValueAsString(); |
266 |
virtual void SetValueAsString(String s) throw (LinuxSamplerException); |
267 |
|
268 |
virtual optional<String> DefaultAsString(std::map<String,String> Parameters) = 0; |
269 |
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0; |
270 |
virtual void OnSetValue(String s) throw (LinuxSamplerException) = 0; |
271 |
protected: |
272 |
String sVal; |
273 |
void InitWithDefault(); |
274 |
private: |
275 |
}; |
276 |
|
277 |
class DeviceCreationParameterStrings : public DeviceCreationParameter { |
278 |
public: |
279 |
DeviceCreationParameterStrings(); |
280 |
DeviceCreationParameterStrings(std::vector<String> sVals); |
281 |
DeviceCreationParameterStrings(String val) throw (LinuxSamplerException); |
282 |
virtual String Type(); |
283 |
virtual bool Multiplicity(); |
284 |
virtual optional<String> Default(std::map<String,String> Parameters); |
285 |
virtual optional<String> RangeMin(std::map<String,String> Parameters); |
286 |
virtual optional<String> RangeMax(std::map<String,String> Parameters); |
287 |
virtual optional<String> Possibilities(std::map<String,String> Parameters); |
288 |
virtual String Value(); |
289 |
virtual void SetValue(String val) throw (LinuxSamplerException); |
290 |
|
291 |
virtual std::vector<String> ValueAsStrings(); |
292 |
virtual void SetValue(std::vector<String> vS) throw (LinuxSamplerException); |
293 |
|
294 |
virtual std::vector<String> DefaultAsStrings(std::map<String,String> Parameters) = 0; |
295 |
virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0; |
296 |
virtual void OnSetValue(std::vector<String> vS) throw (LinuxSamplerException) = 0; |
297 |
protected: |
298 |
std::vector<String> sVals; |
299 |
void InitWithDefault(); |
300 |
private: |
301 |
}; |
302 |
|
303 |
} // namespace LinuxSampler |
304 |
|
305 |
#endif // __LS_DEVICE_PARAMETER_H__ |