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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (show annotations) (download) (as text)
Tue Jul 6 03:27:38 2004 UTC (19 years, 9 months ago) by senkov
File MIME type: text/x-c++hdr
File size: 3060 byte(s)
* Reworked the infrastructure to allow for parameter
registration and creation
* Changed alsa audio output and midi drivers
to work with new infrastructure

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_FACTORY_H__
24 #define __LS_DEVICE_PARAMETER_FACTORY_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 "DeviceParameter.h"
33
34 namespace LinuxSampler {
35
36 class DeviceParameterFactory {
37 public:
38 class InnerFactory {
39 public:
40 virtual DeviceCreationParameter* Create() = 0;
41 virtual DeviceCreationParameter* Create(String val) = 0;
42 };
43
44 template <class Parameter_T>
45 class InnerFactoryTemplate : public InnerFactory {
46 public:
47 virtual DeviceCreationParameter* Create() { return new Parameter_T(); }
48 virtual DeviceCreationParameter* Create(String val) { return new Parameter_T(val); }
49 };
50
51 template <class Parameter_T>
52 static void Register(DeviceParameterFactory* factory) {
53 factory->InnerFactories[Parameter_T::Name()] = new InnerFactoryTemplate<Parameter_T>;
54 }
55
56 std::map<String,DeviceCreationParameter*> CreateAllParams ( std::map<String,String> Parameters );
57 std::map<String,DeviceCreationParameter*> CreateAllParams ();
58
59 DeviceCreationParameter* Create(String ParameterName) throw (LinuxSamplerException);
60 DeviceCreationParameter* Create(String ParameterName, String val) throw (LinuxSamplerException);
61
62 protected:
63 std::map<String, InnerFactory*> InnerFactories;
64 };
65
66 } // namespace LinuxSampler
67
68 #endif // __LS_DEVICE_PARAMETER_FACTORY_H__

  ViewVC Help
Powered by ViewVC