RealTimePluginFactory.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 indent-tabs-mode: nil -*-
2 
3 /*
4  Rosegarden-4
5  A sequencer and musical notation editor.
6 
7  This program is Copyright 2000-2006
8  Guillaume Laurent <glaurent@telegraph-road.org>,
9  Chris Cannam <cannam@all-day-breakfast.com>,
10  Richard Bown <bownie@bownie.com>
11 
12  The moral right of the authors to claim authorship of this work
13  has been asserted.
14 
15  This program is free software; you can redistribute it and/or
16  modify it under the terms of the GNU General Public License as
17  published by the Free Software Foundation; either version 2 of the
18  License, or (at your option) any later version. See the file
19  COPYING included with this distribution for more information.
20 */
21 
22 #include "RealTimePluginFactory.h"
23 #include "PluginIdentifier.h"
24 
25 #include "LADSPAPluginFactory.h"
26 #include "DSSIPluginFactory.h"
27 
28 #include "system/System.h"
29 #include "base/Profiler.h"
30 
31 #include <iostream>
32 
34 
37 
39 {
40 }
41 
44 {
45  if (pluginType == "ladspa") {
46  if (!_ladspaInstance) {
47 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new LADSPAPluginFactory" << endl;
48  _ladspaInstance = new LADSPAPluginFactory();
49  _ladspaInstance->discoverPlugins();
50  }
51  return _ladspaInstance;
52  } else if (pluginType == "dssi") {
53  if (!_dssiInstance) {
54 // SVDEBUG << "RealTimePluginFactory::instance(" << pluginType// << "): creating new DSSIPluginFactory" << endl;
55  _dssiInstance = new DSSIPluginFactory();
56  _dssiInstance->discoverPlugins();
57  }
58  return _dssiInstance;
59  }
60 
61  else return nullptr;
62 }
63 
66 {
67  QString type, soName, label;
68  PluginIdentifier::parseIdentifier(identifier, type, soName, label);
69  return instance(type);
70 }
71 
72 std::vector<QString>
74 {
75  Profiler profiler("RealTimePluginFactory::getAllPluginIdentifiers");
76 
77  RealTimePluginFactory *factory;
78  std::vector<QString> rv;
79 
80  // Query DSSI plugins before LADSPA ones.
81  // This is to provide for the interesting possibility of plugins
82  // providing either DSSI or LADSPA versions of themselves,
83  // returning both versions if the LADSPA identifiers are queried
84  // first but only the DSSI version if the DSSI identifiers are
85  // queried first.
86 
87  factory = instance("dssi");
88  if (factory) {
89  const std::vector<QString> &tmp = factory->getPluginIdentifiers();
90  for (size_t i = 0; i < tmp.size(); ++i) {
91  rv.push_back(tmp[i]);
92  }
93  }
94 
95  factory = instance("ladspa");
96  if (factory) {
97  const std::vector<QString> &tmp = factory->getPluginIdentifiers();
98  for (size_t i = 0; i < tmp.size(); ++i) {
99  rv.push_back(tmp[i]);
100  }
101  }
102 
103  // Plugins can change the locale, revert it to default.
105 
106  return rv;
107 }
108 
109 void
111 {
112  Profiler profiler("RealTimePluginFactory::enumerateAllPlugins");
113 
114  RealTimePluginFactory *factory;
115 
116  // Query DSSI plugins before LADSPA ones.
117  // This is to provide for the interesting possibility of plugins
118  // providing either DSSI or LADSPA versions of themselves,
119  // returning both versions if the LADSPA identifiers are queried
120  // first but only the DSSI version if the DSSI identifiers are
121  // queried first.
122 
123  factory = instance("dssi");
124  if (factory) factory->enumeratePlugins(list);
125 
126  factory = instance("ladspa");
127  if (factory) factory->enumeratePlugins(list);
128 
129  // Plugins can change the locale, revert it to default.
131 }
132 
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
static void enumerateAllPlugins(std::vector< QString > &)
static RealTimePluginFactory * instanceFor(QString identifier)
void discoverPlugins() override
Look up the plugin path and find the plugins in it.
static void parseIdentifier(QString identifier, QString &type, QString &soName, QString &label)
static LADSPAPluginFactory * _dssiInstance
static std::vector< QString > getAllPluginIdentifiers()
static sv_samplerate_t m_sampleRate
static LADSPAPluginFactory * _ladspaInstance
void RestoreStartupLocale()
Definition: System.cpp:328
static RealTimePluginFactory * instance(QString pluginType)
virtual const std::vector< QString > & getPluginIdentifiers() const =0
Return a reference to a list of all plugin identifiers that can be created by this factory...
virtual void enumeratePlugins(std::vector< QString > &list)=0
Append to the given list descriptions of all the available plugins and their ports.
Profile point instance class.
Definition: Profiler.h:93