linuxsampler 2.3.1
DeviceParameter.h
Go to the documentation of this file.
1/***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2013 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
35namespace LinuxSampler {
36
38 // "Runtime" parameters
39
40 // 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.
41
74 public:
81 virtual String Type() = 0;
82
89 virtual String Description() = 0;
90
102 virtual bool Fix() = 0;
103
113 virtual bool Multiplicity() = 0;
114
130
146
160
167 virtual String Value() = 0;
168
181 virtual void SetValue(String val) throw (Exception) = 0;
182
190 };
191
205 public:
213
215 // derived methods, implementing type "BOOL"
216 // (usually not to be overriden by descendant)
217
225
227 // convenience methods for type "BOOL"
228 // (usually not to be overriden by descendant)
229
232
234 // abstract methods
235 // (these have to be implemented by the descendant)
236
247 protected:
248 bool bVal;
249 };
250
264 public:
272
274 // derived methods, implementing type "INT"
275 // (usually not to be overriden by descendant)
276
284
286 // convenience methods for type "INT"
287 // (usually not to be overriden by descendant)
288
289 virtual int ValueAsInt();
291
293 // abstract methods
294 // (these have to be implemented by the descendant)
295
302 virtual optional<int> RangeMinAsInt() = 0;
303
310 virtual optional<int> RangeMaxAsInt() = 0;
311
318 virtual std::vector<int> PossibilitiesAsInt() = 0;
319
330 protected:
331 int iVal;
332 };
333
348 public:
356
358 // derived methods, implementing type "FLOAT"
359 // (usually not to be overriden by descendant)
360
368
370 // convenience methods for type "FLOAT"
371 // (usually not to be overriden by descendant)
372
373 virtual float ValueAsFloat();
375
377 // abstract methods
378 // (these have to be implemented by the descendant)
379
386 virtual optional<float> RangeMinAsFloat() = 0;
387
394 virtual optional<float> RangeMaxAsFloat() = 0;
395
402 virtual std::vector<float> PossibilitiesAsFloat() = 0;
403
413 virtual void OnSetValue(float f) = 0;
414 protected:
415 float fVal;
416 };
417
431 public:
439
442
444 // derived methods, implementing type "STRING"
445 // (usually not to be overriden by descendant)
446
454
456 // convenience methods for type "STRING"
457 // (usually not to be overriden by descendant)
458
459 virtual String ValueAsString();
460 virtual void SetValueAsString(String s) throw (Exception);
461
463 // abstract methods
464 // (these have to be implemented by the descendant)
465
472 virtual std::vector<String> PossibilitiesAsString() = 0;
473
484 protected:
485 String sVal;
486 };
487
501 public:
508 DeviceRuntimeParameterStrings(std::vector<String> vS);
509
512
514 // derived methods, implementing type "STRINGS"
515 // (usually not to be overriden by descendant)
516
524
526 // convenience methods for type "STRINGS"
527 // (usually not to be overriden by descendant)
528
529 virtual std::vector<String> ValueAsStrings();
531
533 // abstract methods
534 // (these have to be implemented by the descendant)
535
542 virtual std::vector<String> PossibilitiesAsString() = 0;
543
554 protected:
555 std::vector<String> sVals;
556 };
557
558
560 // "Creation" parameters
561
581 public:
583 DeviceCreationParameter ( void ) { pDevice = NULL; }
584
590 virtual bool Mandatory() = 0;
591
606
621 virtual std::map<String,DeviceCreationParameter*> DependsAsParameters() = 0;
622
635
654 virtual optional<String> Default(std::map<String,String> Parameters) = 0;
655
666
683 virtual optional<String> RangeMin(std::map<String,String> Parameters) = 0;
684
695
712 virtual optional<String> RangeMax(std::map<String,String> Parameters) = 0;
713
725
743 virtual optional<String> Possibilities(std::map<String,String> Parameters) = 0;
744
751 void Attach(Device* pDevice) { this->pDevice = pDevice; }
752 protected:
754 };
755
769 public:
770 DeviceCreationParameterBool(bool bVal = false);
773 virtual bool Multiplicity() OVERRIDE;
774 virtual optional<String> Default(std::map<String,String> Parameters) OVERRIDE;
775 virtual optional<String> RangeMin(std::map<String,String> Parameters) OVERRIDE;
776 virtual optional<String> RangeMax(std::map<String,String> Parameters) OVERRIDE;
777 virtual optional<String> Possibilities(std::map<String,String> Parameters) OVERRIDE;
780
781 virtual bool ValueAsBool();
782 virtual void SetValue(bool b) throw (Exception);
783
784 virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters) = 0;
785 virtual void OnSetValue(bool b) throw (Exception) = 0;
786 protected:
787 bool bVal;
788 void InitWithDefault();
789 private:
790 };
791
806 public:
810 virtual bool Multiplicity() OVERRIDE;
811 virtual optional<String> Default(std::map<String,String> Parameters) OVERRIDE;
812 virtual optional<String> RangeMin(std::map<String,String> Parameters) OVERRIDE;
813 virtual optional<String> RangeMax(std::map<String,String> Parameters) OVERRIDE;
814 virtual optional<String> Possibilities(std::map<String,String> Parameters) OVERRIDE;
817
818 virtual int ValueAsInt();
819 virtual void SetValue(int i) throw (Exception);
820
821 virtual optional<int> DefaultAsInt(std::map<String,String> Parameters) = 0;
822 virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters) = 0;
823 virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters) = 0;
824 virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) = 0;
825 virtual void OnSetValue(int i) throw (Exception) = 0;
826 protected:
827 int iVal;
828 void InitWithDefault();
829 private:
830 };
831
846 public:
850 virtual bool Multiplicity() OVERRIDE;
851 virtual optional<String> Default(std::map<String,String> Parameters) OVERRIDE;
852 virtual optional<String> RangeMin(std::map<String,String> Parameters) OVERRIDE;
853 virtual optional<String> RangeMax(std::map<String,String> Parameters) OVERRIDE;
854 virtual optional<String> Possibilities(std::map<String,String> Parameters) OVERRIDE;
857
858 virtual float ValueAsFloat();
859 virtual void SetValue(float f) throw (Exception);
860
861 virtual optional<float> DefaultAsFloat(std::map<String,String> Parameters) = 0;
862 virtual optional<float> RangeMinAsFloat(std::map<String,String> Parameters) = 0;
863 virtual optional<float> RangeMaxAsFloat(std::map<String,String> Parameters) = 0;
864 virtual std::vector<float> PossibilitiesAsFloat(std::map<String,String> Parameters) = 0;
865 virtual void OnSetValue(float f) throw (Exception) = 0;
866 protected:
867 float fVal;
868 void InitWithDefault();
869 private:
870 };
871
885 public:
889 virtual bool Multiplicity() OVERRIDE;
890 virtual optional<String> Default(std::map<String,String> Parameters) OVERRIDE;
891 virtual optional<String> RangeMin(std::map<String,String> Parameters) OVERRIDE;
892 virtual optional<String> RangeMax(std::map<String,String> Parameters) OVERRIDE;
893 virtual optional<String> Possibilities(std::map<String,String> Parameters) OVERRIDE;
896
897 virtual String ValueAsString();
898 virtual void SetValueAsString(String s) throw (Exception);
899
900 virtual optional<String> DefaultAsString(std::map<String,String> Parameters) = 0;
901 virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0;
902 virtual void OnSetValue(String s) throw (Exception) = 0;
903 protected:
904 String sVal;
905 void InitWithDefault();
906 private:
907 };
908
923 public:
925 DeviceCreationParameterStrings(std::vector<String> sVals);
929 virtual bool Multiplicity() OVERRIDE;
930 virtual optional<String> Default(std::map<String,String> Parameters) OVERRIDE;
931 virtual optional<String> RangeMin(std::map<String,String> Parameters) OVERRIDE;
932 virtual optional<String> RangeMax(std::map<String,String> Parameters) OVERRIDE;
933 virtual optional<String> Possibilities(std::map<String,String> Parameters) OVERRIDE;
936
937 virtual std::vector<String> ValueAsStrings();
938 virtual void SetValue(std::vector<String> vS) throw (Exception);
939
940 virtual std::vector<String> DefaultAsStrings(std::map<String,String> Parameters) = 0;
941 virtual std::vector<String> PossibilitiesAsString(std::map<String,String> Parameters) = 0;
942 virtual void OnSetValue(std::vector<String> vS) throw (Exception) = 0;
943 protected:
944 std::vector<String> sVals;
945 void InitWithDefault();
946 private:
947 };
948
949} // namespace LinuxSampler
950
951#endif // __LS_DEVICE_PARAMETER_H__
Abstract base class for driver parameters of type Bool.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of type float.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of type int.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of type String.
DeviceCreationParameterString(String sVal=String())
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of a String list type.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
DeviceCreationParameterStrings(std::vector< String > sVals)
Abstract base class for parameters at driver instanciation time.
virtual std::map< String, DeviceCreationParameter * > DependsAsParameters()=0
Might return a unique key-value pair list (map) reflecting the dependencies of this parameter to othe...
virtual optional< String > Depends()
Might return a comma separated list of parameter names this parameter depends on.
virtual optional< String > RangeMin(std::map< String, String > Parameters)=0
Might return a minimum value for this parameter.
virtual optional< String > Possibilities(std::map< String, String > Parameters)=0
Might return a comma separated list as String with possible values for this parameter.
void Attach(Device *pDevice)
Sets the internal device pointer to a specific device (driver instance) for this parameter object.
virtual optional< String > RangeMin()
Might return a minimum value for this parameter.
virtual optional< String > RangeMax()
Might return a maximum value for this parameter.
virtual optional< String > Default()
Might return a default value for this parameter.
virtual optional< String > Possibilities()
Might return a comma separated list as String with possible values for this parameter.
virtual optional< String > RangeMax(std::map< String, String > Parameters)=0
Might return a maximum value for this parameter.
virtual bool Mandatory()=0
Whether the parameter must be supplied by the user at device creation time.
virtual optional< String > Default(std::map< String, String > Parameters)=0
Might return a default value for this parameter.
Abstract base class for driver parameters of type bool.
virtual void SetValue(String val) OVERRIDE
Alter the parameter with the value given by val.
virtual optional< String > RangeMin() OVERRIDE
The driver parameter might (optionally) return a minimum value for the parameter.
virtual void OnSetValue(bool b)=0
Must be implemented be a driver's parameter class to react on the parameter value being set / altered...
virtual bool Multiplicity() OVERRIDE
Whether the parameter only allows to set one scalar value, or if true is returned here,...
virtual String Value() OVERRIDE
The current value of this parameter (encoded as String).
virtual optional< String > Possibilities() OVERRIDE
The driver parameter might (optionally) return a list of possible values for this parameter,...
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
DeviceRuntimeParameterBool(bool bVal)
Constructor for value type bool.
virtual optional< String > RangeMax() OVERRIDE
The driver parameter might (optionally) return a maximum value for the parameter.
Abstract base class for driver parameters of type float.
DeviceRuntimeParameterFloat(float fVal)
Constructor for value type float.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of type int.
DeviceRuntimeParameterInt(int iVal)
Constructor for value type int.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of type String.
DeviceRuntimeParameterString(String sVal)
Constructor for value type String.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
Abstract base class for driver parameters of a String list type.
virtual String Type() OVERRIDE
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
DeviceRuntimeParameterStrings(std::vector< String > vS)
Constructor for value type String.
Abstracet base class for all driver parameters of the sampler.
virtual bool Fix()=0
Whether the parameter is read only.
virtual String Description()=0
A human readable description, explaining the exact purpose of the driver parameter.
virtual String Type()=0
Some name reflecting the parameter's value type, like "BOOL, "INT", "FLOAT", "STRING",...
virtual void SetValue(String val)=0
Alter the parameter with the value given by val.
virtual bool Multiplicity()=0
Whether the parameter only allows to set one scalar value, or if true is returned here,...
virtual optional< String > Possibilities()=0
The driver parameter might (optionally) return a list of possible values for this parameter,...
virtual String Value()=0
The current value of this parameter (encoded as String).
virtual optional< String > RangeMin()=0
The driver parameter might (optionally) return a minimum value for the parameter.
virtual optional< String > RangeMax()=0
The driver parameter might (optionally) return a maximum value for the parameter.
virtual ~DeviceRuntimeParameter()
Destructor.
Abstract base class for all kind of drivers in LinuxSampler.
Definition Device.h:35
Exception that will be thrown in NON REAL TIME PARTS of the LinuxSampler application.
Definition Exception.h:37
Wraps as a kind of pointer class some data object shared with other threads, to protect / synchronize...
#define OVERRIDE
Definition global.h:84
std::string String
Definition global.h:44