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

  ViewVC Help
Powered by ViewVC