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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (hide annotations) (download)
Tue Jul 6 03:27:38 2004 UTC (19 years, 9 months ago) by senkov
File size: 3682 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 senkov 174 /***************************************************************************
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     #include "DeviceParameterFactory.h"
24    
25     namespace LinuxSampler {
26    
27     DeviceCreationParameter* DeviceParameterFactory::Create(String ParameterName, String val) throw (LinuxSamplerException) {
28     if (!InnerFactories.count(ParameterName)) throw LinuxSamplerException("No such parameter: '" + ParameterName + "'.");
29     return InnerFactories[ParameterName]->Create(val);
30     }
31    
32     DeviceCreationParameter* DeviceParameterFactory::Create(String ParameterName) throw (LinuxSamplerException) {
33     if (!InnerFactories.count(ParameterName)) throw LinuxSamplerException("No such parameter: '" + ParameterName + "'.");
34     return InnerFactories[ParameterName]->Create();
35     }
36    
37     /* This method is used by the device factory to create parameters _before_ creating a device
38     * Input parameter map is used to set parameters that device supports
39     * If extra parameters are present in the input map they are ignored. Only supported parameters are created.
40     * If parameter is not present in the input map it is created with a default setting
41     **/
42     std::map<String,DeviceCreationParameter*> DeviceParameterFactory::CreateAllParams (std::map<String,String> Parameters) {
43     std::map<String,DeviceCreationParameter*> result;
44     for (std::map<String, InnerFactory*>::iterator iter = InnerFactories.begin(); iter != InnerFactories.end(); iter++) {
45     DeviceCreationParameter* param;
46     String paramName = iter->first;
47     if (Parameters.count(paramName)) { //Parameter with this name was specified
48     param = iter->second->Create(Parameters[paramName]);
49     } else { //Not specified, create default
50     param = iter->second->Create();
51     }
52     result[paramName] = param;
53     }
54     return result;
55     }
56    
57     std::map<String,DeviceCreationParameter*> DeviceParameterFactory::CreateAllParams () {
58     std::map<String,DeviceCreationParameter*> result;
59     for (std::map<String, InnerFactory*>::iterator iter = InnerFactories.begin(); iter != InnerFactories.end(); iter++) {
60     result[iter->first] = iter->second->Create();
61     }
62     return result;
63     }
64    
65     } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC