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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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

  ViewVC Help
Powered by ViewVC