/[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 1889 - (hide annotations) (download)
Sun Apr 26 12:19:00 2009 UTC (15 years ago) by persson
File size: 3999 byte(s)
* fixed a memory management error which could cause a crash when a
  plugin was unloaded
* minor fixes in ASIO and MME drivers for win64

1 senkov 174 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 persson 1889 * Copyright (C) 2005 - 2009 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 1049 DeviceCreationParameter* DeviceParameterFactory::Create(String ParameterName, std::map<String,String> Parameters) throw (Exception) {
34 schoenebeck 880 if (!InnerFactories.count(ParameterName)) throw Exception("No such parameter: '" + ParameterName + "'.");
35 schoenebeck 1049 return InnerFactories[ParameterName]->Create(Parameters);
36 senkov 174 }
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 schoenebeck 1049 param = iter->second->Create(Parameters);
52 senkov 174 }
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 persson 1889 DeviceParameterFactory::~DeviceParameterFactory() {
67     for (std::map<String, InnerFactory*>::iterator iter = InnerFactories.begin(); iter != InnerFactories.end(); iter++) {
68     delete iter->second;
69     }
70     }
71    
72 senkov 174 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC