svcore  1.9
TransformFactory.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006-2007 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _TRANSFORM_FACTORY_H_
17 #define _TRANSFORM_FACTORY_H_
18 
19 #include "TransformDescription.h"
20 
21 #include "base/TextMatcher.h"
22 
23 #include <vamp-hostsdk/Plugin.h>
24 
25 #include <QObject>
26 #include <QStringList>
27 #include <QThread>
28 #include <QMutex>
29 
30 #include <map>
31 #include <set>
32 
33 class TransformFactory : public QObject
34 {
35  Q_OBJECT
36 
37 public:
39  virtual ~TransformFactory();
40 
41  static TransformFactory *getInstance();
42  static void deleteInstance(); // only when exiting
43 
54  void startPopulationThread();
55 
59 
62  bool haveUninstalledTransforms(bool waitForCheckToComplete = false);
63 
64  typedef enum {
69 
71 
72  std::vector<TransformDescription::Type> getAllTransformTypes();
74  std::vector<QString> getTransformMakers(TransformDescription::Type);
76 
77  typedef std::map<TransformId, TextMatcher::Match> SearchResults;
78  SearchResults search(QString keyword);
79  SearchResults search(QStringList keywords);
80 
84  bool haveTransform(TransformId identifier);
85 
91  Transform getDefaultTransformFor(TransformId identifier, int rate = 0);
92 
96  QString getTransformName(TransformId identifier);
97 
102  QString getTransformFriendlyName(TransformId identifier);
103 
104  QString getTransformUnits(TransformId identifier);
105 
106  QString getTransformInfoUrl(TransformId identifier);
107 
108  Vamp::Plugin::InputDomain getTransformInputDomain(TransformId identifier);
109 
115  bool isTransformConfigurable(TransformId identifier);
116 
123  bool getTransformChannelRange(TransformId identifier,
124  int &minChannels, int &maxChannels);
125 
146  Vamp::PluginBase *instantiatePluginFor(const Transform &transform);
147 
153  Vamp::Plugin *downcastVampPlugin(Vamp::PluginBase *);
154 
161  void setParametersFromPlugin(Transform &transform, Vamp::PluginBase *plugin);
162 
167  void setPluginParameters(const Transform &transform, Vamp::PluginBase *plugin);
168 
174  void makeContextConsistentWithPlugin(Transform &transform, Vamp::PluginBase *plugin);
175 
185  QString getPluginConfigurationXml(const Transform &transform);
186 
197  QString xml);
198 
199 protected:
200  typedef std::map<TransformId, TransformDescription> TransformDescriptionMap;
201 
204 
207 
208  void populateTransforms();
212 
213  Vamp::PluginBase *instantiateDefaultPluginFor(TransformId id, int rate);
216 
217  class UninstalledTransformsPopulateThread : public QThread
218  {
219  public:
221  m_factory(factory) {
222  }
223  virtual void run();
225  };
226 
228  bool m_exiting;
230 
232 };
233 
234 
235 #endif
TransformInstallStatus getTransformInstallStatus(TransformId id)
std::vector< QString > getTransformCategories(TransformDescription::Type)
TransformDescriptionMap m_transforms
TransformList getUninstalledTransformDescriptions()
Vamp::PluginBase * instantiateDefaultPluginFor(TransformId id, int rate)
QMutex m_uninstalledTransformsMutex
QString getTransformTypeName(TransformDescription::Type) const
std::map< TransformId, TransformDescription > TransformDescriptionMap
TransformDescription getTransformDescription(TransformId id)
std::vector< TransformDescription > TransformList
Vamp::Plugin::InputDomain getTransformInputDomain(TransformId identifier)
bool haveTransform(TransformId identifier)
Return true if the given transform is known.
Transform getDefaultTransformFor(TransformId identifier, int rate=0)
A single transform ID can lead to many possible Transforms, with different parameters and execution c...
void setParametersFromPlugin(Transform &transform, Vamp::PluginBase *plugin)
Set the plugin parameters, program and configuration strings on the given Transform object from the g...
UninstalledTransformsPopulateThread * m_thread
void makeContextConsistentWithPlugin(Transform &transform, Vamp::PluginBase *plugin)
If the given Transform object has no processing step and block sizes set, set them to appropriate def...
Vamp::Plugin * downcastVampPlugin(Vamp::PluginBase *)
Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one.
bool m_uninstalledTransformsPopulated
SearchResults search(QString keyword)
Vamp::PluginBase * instantiatePluginFor(const Transform &transform)
Load an appropriate plugin for the given transform and set the parameters, program and configuration ...
QString getTransformName(TransformId identifier)
Full name of a transform, suitable for putting on a menu.
QString getTransformFriendlyName(TransformId identifier)
Brief but friendly name of a transform, suitable for use as the name of the output layer.
static TransformFactory * getInstance()
bool getTransformChannelRange(TransformId identifier, int &minChannels, int &maxChannels)
If the transform has a prescribed number or range of channel inputs, return true and set minChannels ...
static TransformFactory * m_instance
TransformList getAllTransformDescriptions()
void populateUninstalledTransforms()
void populateFeatureExtractionPlugins(TransformDescriptionMap &)
QString getPluginConfigurationXml(const Transform &transform)
Retrieve a <plugin ...
void setPluginParameters(const Transform &transform, Vamp::PluginBase *plugin)
Set the parameters, program and configuration strings on the given plugin from the given Transform ob...
bool isTransformConfigurable(TransformId identifier)
Return true if the transform has any configurable parameters, i.e.
std::vector< TransformDescription::Type > getAllTransformTypes()
std::vector< QString > getTransformMakers(TransformDescription::Type)
void setParametersFromPluginConfigurationXml(Transform &transform, QString xml)
Set the plugin parameters, program and configuration strings on the given Transform object from the g...
bool haveUninstalledTransforms(bool waitForCheckToComplete=false)
std::map< TransformId, TextMatcher::Match > SearchResults
QString getTransformUnits(TransformId identifier)
Metadata associated with a transform.
void populateRealTimePlugins(TransformDescriptionMap &)
void startPopulationThread()
TransformFactory has a background thread that can populate uninstalled transforms from network RDF re...
static void deleteInstance()
QString getTransformInfoUrl(TransformId identifier)
virtual ~TransformFactory()
TransformDescription getUninstalledTransformDescription(TransformId id)
TransformDescriptionMap m_uninstalledTransforms
QString TransformId
Definition: Transform.h:30