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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1248 - (hide annotations) (download) (as text)
Fri Jun 22 10:10:06 2007 UTC (13 years ago) by persson
File MIME type: text/x-c++hdr
File size: 15265 byte(s)
* fixed some minor memory leaks

1 schoenebeck 123 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 880 * Copyright (C) 2005, 2006 Christian Schoenebeck *
7 schoenebeck 123 * *
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 schoenebeck 880 #include "../common/Exception.h"
33 schoenebeck 207 #include "Device.h"
34 schoenebeck 123
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 schoenebeck 880 virtual void SetValue(String val) throw (Exception) = 0;
50 persson 1248 virtual ~DeviceRuntimeParameter(){};
51 schoenebeck 123 };
52    
53     class DeviceRuntimeParameterBool : public DeviceRuntimeParameter {
54     public:
55     DeviceRuntimeParameterBool(bool bVal);
56     virtual String Type();
57     virtual bool Multiplicity();
58     virtual optional<String> RangeMin();
59     virtual optional<String> RangeMax();
60     virtual optional<String> Possibilities();
61     virtual String Value();
62 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
63 schoenebeck 123
64     virtual bool ValueAsBool();
65 schoenebeck 880 virtual void SetValue(bool b) throw (Exception);
66 schoenebeck 123
67 schoenebeck 880 virtual void OnSetValue(bool b) throw (Exception) = 0;
68 schoenebeck 123 protected:
69     bool bVal;
70     };
71    
72     class DeviceRuntimeParameterInt : public DeviceRuntimeParameter {
73     public:
74     DeviceRuntimeParameterInt(int iVal);
75     virtual String Type();
76     virtual bool Multiplicity();
77     virtual optional<String> RangeMin();
78     virtual optional<String> RangeMax();
79     virtual optional<String> Possibilities();
80     virtual String Value();
81 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
82 schoenebeck 123
83     virtual int ValueAsInt();
84 schoenebeck 880 virtual void SetValue(int i) throw (Exception);
85 schoenebeck 123
86     virtual optional<int> RangeMinAsInt() = 0;
87     virtual optional<int> RangeMaxAsInt() = 0;
88     virtual std::vector<int> PossibilitiesAsInt() = 0;
89 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception) = 0;
90 schoenebeck 123 protected:
91     int iVal;
92     };
93    
94     class DeviceRuntimeParameterFloat : public DeviceRuntimeParameter {
95     public:
96     DeviceRuntimeParameterFloat(float fVal);
97     virtual String Type();
98     virtual bool Multiplicity();
99     virtual optional<String> RangeMin();
100     virtual optional<String> RangeMax();
101     virtual optional<String> Possibilities();
102     virtual String Value();
103 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
104 schoenebeck 123
105     virtual float ValueAsFloat();
106 schoenebeck 880 virtual void SetValue(float f) throw (Exception);
107 schoenebeck 123
108     virtual optional<float> RangeMinAsFloat() = 0;
109     virtual optional<float> RangeMaxAsFloat() = 0;
110     virtual std::vector<float> PossibilitiesAsFloat() = 0;
111     virtual void OnSetValue(float f) = 0;
112     protected:
113     float fVal;
114     };
115    
116     class DeviceRuntimeParameterString : public DeviceRuntimeParameter {
117     public:
118     DeviceRuntimeParameterString(String sVal);
119 schoenebeck 361 virtual ~DeviceRuntimeParameterString(){}
120 schoenebeck 123 virtual String Type();
121     virtual bool Multiplicity();
122     virtual optional<String> RangeMin();
123     virtual optional<String> RangeMax();
124     virtual optional<String> Possibilities();
125     virtual String Value();
126 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
127 schoenebeck 123
128 schoenebeck 214 virtual String ValueAsString();
129 schoenebeck 880 virtual void SetValueAsString(String s) throw (Exception);
130 schoenebeck 214
131 schoenebeck 123 virtual std::vector<String> PossibilitiesAsString() = 0;
132     virtual void OnSetValue(String s) = 0;
133     protected:
134     String sVal;
135     };
136    
137     class DeviceRuntimeParameterStrings : public DeviceRuntimeParameter {
138     public:
139     DeviceRuntimeParameterStrings(std::vector<String> vS);
140 schoenebeck 361 virtual ~DeviceRuntimeParameterStrings(){}
141 schoenebeck 123 virtual String Type();
142     virtual bool Multiplicity();
143     virtual optional<String> RangeMin();
144     virtual optional<String> RangeMax();
145     virtual optional<String> Possibilities();
146     virtual String Value();
147 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
148 schoenebeck 123
149     virtual std::vector<String> ValueAsStrings();
150 schoenebeck 880 virtual void SetValue(std::vector<String> vS) throw (Exception);
151 schoenebeck 123
152     virtual std::vector<String> PossibilitiesAsString() = 0;
153     virtual void OnSetValue(std::vector<String> vS) = 0;
154     protected:
155     std::vector<String> sVals;
156     };
157    
158    
159    
160     class DeviceCreationParameter : public DeviceRuntimeParameter {
161     public:
162 senkov 174 DeviceCreationParameter ( void ) { pDevice = NULL; }
163 schoenebeck 123 virtual bool Mandatory() = 0;
164     virtual optional<String> Depends();
165     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters() = 0;
166     virtual optional<String> Default();
167     virtual optional<String> Default(std::map<String,String> Parameters) = 0;
168     virtual optional<String> RangeMin();
169     virtual optional<String> RangeMin(std::map<String,String> Parameters) = 0;
170     virtual optional<String> RangeMax();
171     virtual optional<String> RangeMax(std::map<String,String> Parameters) = 0;
172     virtual optional<String> Possibilities();
173     virtual optional<String> Possibilities(std::map<String,String> Parameters) = 0;
174 schoenebeck 207 void Attach(Device* pDevice) { this->pDevice = pDevice; }
175 senkov 174 protected:
176 schoenebeck 207 Device* pDevice;
177 schoenebeck 123 };
178    
179     class DeviceCreationParameterBool : public DeviceCreationParameter {
180     public:
181 senkov 174 DeviceCreationParameterBool(bool bVal = false);
182 schoenebeck 880 DeviceCreationParameterBool(String val) throw (Exception);
183 schoenebeck 123 virtual String Type();
184     virtual bool Multiplicity();
185     virtual optional<String> Default(std::map<String,String> Parameters);
186     virtual optional<String> RangeMin(std::map<String,String> Parameters);
187     virtual optional<String> RangeMax(std::map<String,String> Parameters);
188     virtual optional<String> Possibilities(std::map<String,String> Parameters);
189     virtual String Value();
190 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
191 schoenebeck 123
192     virtual bool ValueAsBool();
193 schoenebeck 880 virtual void SetValue(bool b) throw (Exception);
194 schoenebeck 123
195     virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters) = 0;
196 schoenebeck 880 virtual void OnSetValue(bool b) throw (Exception) = 0;
197 schoenebeck 123 protected:
198     bool bVal;
199 senkov 128 void InitWithDefault();
200 schoenebeck 123 private:
201     };
202    
203     class DeviceCreationParameterInt : public DeviceCreationParameter {
204     public:
205 senkov 174 DeviceCreationParameterInt(int iVal = 0);
206 schoenebeck 880 DeviceCreationParameterInt(String val) throw (Exception);
207 schoenebeck 123 virtual String Type();
208     virtual bool Multiplicity();
209     virtual optional<String> Default(std::map<String,String> Parameters);
210     virtual optional<String> RangeMin(std::map<String,String> Parameters);
211     virtual optional<String> RangeMax(std::map<String,String> Parameters);
212     virtual optional<String> Possibilities(std::map<String,String> Parameters);
213     virtual String Value();
214 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
215 schoenebeck 123
216     virtual int ValueAsInt();
217 schoenebeck 880 virtual void SetValue(int i) throw (Exception);
218 schoenebeck 123
219     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters) = 0;
220     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters) = 0;
221     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters) = 0;
222     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) = 0;
223 schoenebeck 880 virtual void OnSetValue(int i) throw (Exception) = 0;
224 schoenebeck 123 protected:
225     int iVal;
226 senkov 128 void InitWithDefault();
227 schoenebeck 123 private:
228     };
229    
230     class DeviceCreationParameterFloat : public DeviceCreationParameter {
231     public:
232 senkov 174 DeviceCreationParameterFloat(float fVal = 0.0);
233 schoenebeck 880 DeviceCreationParameterFloat(String val) throw (Exception);
234 schoenebeck 123 virtual String Type();
235     virtual bool Multiplicity();
236     virtual optional<String> Default(std::map<String,String> Parameters);
237     virtual optional<String> RangeMin(std::map<String,String> Parameters);
238     virtual optional<String> RangeMax(std::map<String,String> Parameters);
239     virtual optional<String> Possibilities(std::map<String,String> Parameters);
240     virtual String Value();
241 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
242 schoenebeck 123
243     virtual float ValueAsFloat();
244 schoenebeck 880 virtual void SetValue(float f) throw (Exception);
245 schoenebeck 123
246     virtual optional<float> DefaultAsFloat(std::map<String,String> Parameters) = 0;
247     virtual optional<float> RangeMinAsFloat(std::map<String,String> Parameters) = 0;
248     virtual optional<float> RangeMaxAsFloat(std::map<String,String> Parameters) = 0;
249     virtual std::vector<float> PossibilitiesAsFloat(std::map<String,String> Parameters) = 0;
250 schoenebeck 880 virtual void OnSetValue(float f) throw (Exception) = 0;
251 schoenebeck 123 protected:
252     float fVal;
253 senkov 128 void InitWithDefault();
254 schoenebeck 123 private:
255     };
256    
257     class DeviceCreationParameterString : public DeviceCreationParameter {
258     public:
259 senkov 174 DeviceCreationParameterString(String sVal = String());
260 schoenebeck 361 virtual ~DeviceCreationParameterString(){}
261 schoenebeck 123 virtual String Type();
262     virtual bool Multiplicity();
263 schoenebeck 212 virtual optional<String> Default(std::map<String,String> Parameters);
264 schoenebeck 123 virtual optional<String> RangeMin(std::map<String,String> Parameters);
265     virtual optional<String> RangeMax(std::map<String,String> Parameters);
266     virtual optional<String> Possibilities(std::map<String,String> Parameters);
267     virtual String Value();
268 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
269 schoenebeck 123
270 schoenebeck 214 virtual String ValueAsString();
271 schoenebeck 880 virtual void SetValueAsString(String s) throw (Exception);
272 schoenebeck 214
273 schoenebeck 212 virtual optional<String> DefaultAsString(std::map<String,String> Parameters) = 0;
274 schoenebeck 123 virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0;
275 schoenebeck 880 virtual void OnSetValue(String s) throw (Exception) = 0;
276 schoenebeck 123 protected:
277     String sVal;
278 senkov 128 void InitWithDefault();
279 schoenebeck 123 private:
280     };
281    
282     class DeviceCreationParameterStrings : public DeviceCreationParameter {
283     public:
284     DeviceCreationParameterStrings();
285     DeviceCreationParameterStrings(std::vector<String> sVals);
286 schoenebeck 880 DeviceCreationParameterStrings(String val) throw (Exception);
287 schoenebeck 361 virtual ~DeviceCreationParameterStrings(){}
288 schoenebeck 123 virtual String Type();
289     virtual bool Multiplicity();
290 schoenebeck 212 virtual optional<String> Default(std::map<String,String> Parameters);
291 schoenebeck 123 virtual optional<String> RangeMin(std::map<String,String> Parameters);
292     virtual optional<String> RangeMax(std::map<String,String> Parameters);
293     virtual optional<String> Possibilities(std::map<String,String> Parameters);
294     virtual String Value();
295 schoenebeck 880 virtual void SetValue(String val) throw (Exception);
296 schoenebeck 123
297     virtual std::vector<String> ValueAsStrings();
298 schoenebeck 880 virtual void SetValue(std::vector<String> vS) throw (Exception);
299 schoenebeck 123
300 schoenebeck 212 virtual std::vector<String> DefaultAsStrings(std::map<String,String> Parameters) = 0;
301 schoenebeck 123 virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0;
302 schoenebeck 880 virtual void OnSetValue(std::vector<String> vS) throw (Exception) = 0;
303 schoenebeck 123 protected:
304     std::vector<String> sVals;
305 senkov 128 void InitWithDefault();
306 schoenebeck 123 private:
307     };
308    
309     } // namespace LinuxSampler
310    
311     #endif // __LS_DEVICE_PARAMETER_H__

  ViewVC Help
Powered by ViewVC