/[svn]/linuxsampler/trunk/src/engines/InstrumentEditorFactory.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/InstrumentEditorFactory.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1212 - (show annotations) (download) (as text)
Tue May 29 23:59:36 2007 UTC (16 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 4418 byte(s)
* added highly experimental support for on-the-fly instrument editing
  within the sampler's process (by using instrument editor plugins),
  you'll notice the new "Registered instrument editors:" message on
  startup, the plugin path can be overridden at compile time with
  ./configure --enable-plugin-dir=/some/dir
* added a new LSCP command "EDIT INSTRUMENT <sampler-channel>" to spawn
  a matching instrument editor for the instrument on the given sampler
  channel (LSCP command syntax might be subject to change soon)
* config.h is not going to be installed along with liblinuxsampler's
  API header files anymore (not necessary anymore)
* take care of $(DESTDIR) when creating the instruments DB on 'make
  install' rule (needed for packaging and cross compilation)
* bumped version to 0.4.0.5cvs

1 /***************************************************************************
2 * *
3 * Copyright (C) 2007 Christian Schoenebeck *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18 * MA 02111-1307 USA *
19 ***************************************************************************/
20
21 #ifndef LS_INSTRUMENT_EDITOR_FACTORY_H
22 #define LS_INSTRUMENT_EDITOR_FACTORY_H
23
24 #include <map>
25 #include <vector>
26 #include <list>
27
28 #include "../common/Exception.h"
29 #include "InstrumentEditor.h"
30
31 #define REGISTER_INSTRUMENT_EDITOR(PluginClass) \
32 LinuxSampler::InstrumentEditorFactory::InnerFactoryRegistrator<PluginClass> \
33 __auto_register_instrument_editor__##PluginClass;
34
35 namespace LinuxSampler {
36
37 class InstrumentEditorFactory {
38 public:
39 class InnerFactory {
40 public:
41 virtual InstrumentEditor* Create() = 0;
42 virtual void Destroy(InstrumentEditor* pEditor) = 0;
43 };
44
45 template<class PluginClass_T>
46 class InnerFactoryTemplate : public InnerFactory {
47 public:
48 virtual InstrumentEditor* Create() {
49 return new PluginClass_T();
50 }
51
52 virtual void Destroy(InstrumentEditor* pEditor) {
53 delete pEditor;
54 }
55 };
56
57 template<class PluginClass_T>
58 class InnerFactoryRegistrator {
59 public:
60 InnerFactoryRegistrator() {
61 InnerFactoryTemplate<PluginClass_T>* pInnerFactory =
62 new InnerFactoryTemplate<PluginClass_T>();
63 InstrumentEditor* pEditor = pInnerFactory->Create();
64 if (InnerFactories.count(pEditor->Name())) {
65 pInnerFactory->Destroy(pEditor);
66 delete pInnerFactory;
67 } else {
68 InnerFactories[pEditor->Name()] = pInnerFactory;
69 pInnerFactory->Destroy(pEditor);
70 }
71 }
72
73 ~InnerFactoryRegistrator() {
74 InnerFactoryTemplate<PluginClass_T> innerFactory;
75 InstrumentEditor* pEditor = innerFactory.Create();
76 if (InnerFactories.count(pEditor->Name())) {
77 InnerFactory* pZombie =
78 InnerFactories[pEditor->Name()];
79 InnerFactories.erase(pEditor->Name());
80 if (pZombie) delete pZombie;
81 }
82 innerFactory.Destroy(pEditor);
83 }
84 };
85
86 static InstrumentEditor* Create(String InstrumentEditorName) throw (Exception);
87 static void Destroy(InstrumentEditor* pInstrumentEditor) throw (Exception);
88 static std::vector<String> AvailableEditors();
89 static String AvailableEditorsAsString();
90 static std::vector<String> MatchingEditors(String sTypeName, String sTypeVersion);
91 static void LoadPlugins();
92 static void ClosePlugins();
93
94 protected:
95 static std::map<String, InnerFactory*> InnerFactories;
96 static bool bPluginsLoaded;
97 static std::list<void*> LoadedDLLs;
98 };
99
100 } // namespace LinuxSampler
101
102 #endif // LS_INSTRUMENT_EDITOR_FACTORY_H

  ViewVC Help
Powered by ViewVC