/[svn]/linuxsampler/trunk/src/drivers/DeviceParameter.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/DeviceParameter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 880 - (show annotations) (download) (as text)
Tue Jun 27 22:57:37 2006 UTC (14 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 15216 byte(s)
just some refactoring work:
- renamed class LinuxSamplerException -> Exception
- encapsulated LS API relevant files into LS namespace
- removed unnecessary header inclusions

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

  ViewVC Help
Powered by ViewVC