svcore  1.9
TransformFactory Class Reference

#include <TransformFactory.h>

Collaboration diagram for TransformFactory:

List of all members.

Classes

class  UninstalledTransformsPopulateThread

Public Types

enum  TransformInstallStatus { TransformUnknown, TransformInstalled, TransformNotInstalled }
typedef std::map< TransformId,
TextMatcher::Match
SearchResults

Public Member Functions

 TransformFactory ()
virtual ~TransformFactory ()
void startPopulationThread ()
 TransformFactory has a background thread that can populate uninstalled transforms from network RDF resources.
TransformList getAllTransformDescriptions ()
TransformDescription getTransformDescription (TransformId id)
bool haveInstalledTransforms ()
TransformList getUninstalledTransformDescriptions ()
TransformDescription getUninstalledTransformDescription (TransformId id)
bool haveUninstalledTransforms (bool waitForCheckToComplete=false)
TransformInstallStatus getTransformInstallStatus (TransformId id)
std::vector
< TransformDescription::Type
getAllTransformTypes ()
std::vector< QString > getTransformCategories (TransformDescription::Type)
std::vector< QString > getTransformMakers (TransformDescription::Type)
QString getTransformTypeName (TransformDescription::Type) const
SearchResults search (QString keyword)
SearchResults search (QStringList keywords)
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 context settings.
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.
QString getTransformUnits (TransformId identifier)
QString getTransformInfoUrl (TransformId identifier)
Vamp::Plugin::InputDomain getTransformInputDomain (TransformId identifier)
bool isTransformConfigurable (TransformId identifier)
 Return true if the transform has any configurable parameters, i.e.
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 and maxChannels to the minimum and maximum number of channel inputs the transform can accept.
Vamp::PluginBase * instantiatePluginFor (const Transform &transform)
 Load an appropriate plugin for the given transform and set the parameters, program and configuration strings on that plugin from the Transform object.
Vamp::Plugin * downcastVampPlugin (Vamp::PluginBase *)
 Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one.
void setParametersFromPlugin (Transform &transform, Vamp::PluginBase *plugin)
 Set the plugin parameters, program and configuration strings on the given Transform object from the given plugin instance.
void setPluginParameters (const Transform &transform, Vamp::PluginBase *plugin)
 Set the parameters, program and configuration strings on the given plugin from the given Transform object.
void makeContextConsistentWithPlugin (Transform &transform, Vamp::PluginBase *plugin)
 If the given Transform object has no processing step and block sizes set, set them to appropriate defaults for the given plugin.
QString getPluginConfigurationXml (const Transform &transform)
 Retrieve a <plugin ...
void setParametersFromPluginConfigurationXml (Transform &transform, QString xml)
 Set the plugin parameters, program and configuration strings on the given Transform object from the given <plugin ...

Static Public Member Functions

static TransformFactorygetInstance ()
static void deleteInstance ()

Protected Types

typedef std::map< TransformId,
TransformDescription
TransformDescriptionMap

Protected Member Functions

void populateTransforms ()
void populateUninstalledTransforms ()
void populateFeatureExtractionPlugins (TransformDescriptionMap &)
void populateRealTimePlugins (TransformDescriptionMap &)
Vamp::PluginBase * instantiateDefaultPluginFor (TransformId id, int rate)

Protected Attributes

TransformDescriptionMap m_transforms
bool m_transformsPopulated
TransformDescriptionMap m_uninstalledTransforms
bool m_uninstalledTransformsPopulated
QMutex m_transformsMutex
QMutex m_uninstalledTransformsMutex
UninstalledTransformsPopulateThreadm_thread
bool m_exiting
bool m_populatingSlowly

Static Protected Attributes

static TransformFactorym_instance = new TransformFactory

Detailed Description

Definition at line 33 of file TransformFactory.h.


Member Typedef Documentation

Definition at line 200 of file TransformFactory.h.


Member Enumeration Documentation

Enumerator:
TransformUnknown 
TransformInstalled 
TransformNotInstalled 

Definition at line 64 of file TransformFactory.h.


Constructor & Destructor Documentation

Definition at line 68 of file TransformFactory.cpp.

References m_exiting, m_thread, and SVDEBUG.


Member Function Documentation

Definition at line 52 of file TransformFactory.cpp.

References m_instance, and SVDEBUG.

TransformFactory has a background thread that can populate uninstalled transforms from network RDF resources.

It is not started by default, but it's a good idea to start it when the program starts up, if the uninstalled transforms may be of use later; otherwise there will be a bottleneck the first time they're requested.

If this thread is not already running, start it now.

Definition at line 84 of file TransformFactory.cpp.

References m_thread, and m_uninstalledTransformsMutex.

std::vector< QString > TransformFactory::getTransformCategories ( TransformDescription::Type  transformType)

Definition at line 263 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

std::vector< QString > TransformFactory::getTransformMakers ( TransformDescription::Type  transformType)

Definition at line 290 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

Definition at line 1105 of file TransformFactory.cpp.

Return true if the given transform is known.

Definition at line 835 of file TransformFactory.cpp.

References m_transforms, and populateTransforms().

A single transform ID can lead to many possible Transforms, with different parameters and execution context settings.

Return the default one for the given transform.

Definition at line 753 of file TransformFactory.cpp.

References instantiateDefaultPluginFor(), makeContextConsistentWithPlugin(), Transform::setIdentifier(), setParametersFromPlugin(), Transform::setPluginVersion(), and Transform::setSampleRate().

Full name of a transform, suitable for putting on a menu.

Definition at line 842 of file TransformFactory.cpp.

References m_transforms.

Brief but friendly name of a transform, suitable for use as the name of the output layer.

Definition at line 850 of file TransformFactory.cpp.

References m_transforms.

Definition at line 866 of file TransformFactory.cpp.

References m_transforms.

Return true if the transform has any configurable parameters, i.e.

if getConfigurationForTransform can ever return a non-trivial (not equivalent to empty) configuration string.

Definition at line 896 of file TransformFactory.cpp.

References m_transforms.

bool TransformFactory::getTransformChannelRange ( TransformId  identifier,
int &  minChannels,
int &  maxChannels 
)

If the transform has a prescribed number or range of channel inputs, return true and set minChannels and maxChannels to the minimum and maximum number of channel inputs the transform can accept.

Return false if it doesn't care.

Definition at line 904 of file TransformFactory.cpp.

References RealTimePluginDescriptor::audioInputPortCount, FeatureExtractionPluginFactory::instanceFor(), and RealTimePluginFactory::instanceFor().

Vamp::PluginBase * TransformFactory::instantiatePluginFor ( const Transform transform)

Load an appropriate plugin for the given transform and set the parameters, program and configuration strings on that plugin from the Transform object.

Note that this requires that the transform has a meaningful sample rate set, as that is used as the rate for the plugin. A Transform can legitimately have rate set at zero (= "use the rate of the input source"), so the caller will need to test for this case.

Returns the plugin thus loaded. This will be a Vamp::PluginBase, but not necessarily a Vamp::Plugin (only if the transform was a feature-extraction type -- call downcastVampPlugin if you only want Vamp::Plugins). Returns NULL if no suitable plugin was available.

The returned plugin is owned by the caller, and should be deleted (using "delete") when no longer needed.

Definition at line 772 of file TransformFactory.cpp.

References Transform::getIdentifier(), Transform::getSampleRate(), instantiateDefaultPluginFor(), and setPluginParameters().

Vamp::Plugin * TransformFactory::downcastVampPlugin ( Vamp::PluginBase *  plugin)

Convert a Vamp::PluginBase to a Vamp::Plugin, if it is one.

Return NULL otherwise. This ill-fitting convenience function is really just a dynamic_cast wrapper.

!! why?

!! no, I mean really why?

Definition at line 817 of file TransformFactory.cpp.

Referenced by getTransformInputDomain(), and makeContextConsistentWithPlugin().

void TransformFactory::setParametersFromPlugin ( Transform transform,
Vamp::PluginBase *  plugin 
)

Set the plugin parameters, program and configuration strings on the given Transform object from the given plugin instance.

Note that no check is made whether the plugin is actually the "correct" one for the transform.

!! record plugin & API version

!! check that this is the right plugin!

Definition at line 941 of file TransformFactory.cpp.

References RealTimePluginInstance::getConfigurePairs(), Transform::setConfiguration(), Transform::setParameters(), and Transform::setProgram().

Referenced by getDefaultTransformFor(), and setParametersFromPluginConfigurationXml().

void TransformFactory::setPluginParameters ( const Transform transform,
Vamp::PluginBase *  plugin 
)

Set the parameters, program and configuration strings on the given plugin from the given Transform object.

!! check plugin & API version (see e.g. PluginXml::setParameters)

!! check that this is the right plugin!

Definition at line 989 of file TransformFactory.cpp.

References RealTimePluginInstance::configure(), Transform::getConfiguration(), Transform::getParameters(), and Transform::getProgram().

Referenced by getPluginConfigurationXml(), FeatureExtractionModelTransformer::initialise(), instantiatePluginFor(), and RealTimeEffectModelTransformer::RealTimeEffectModelTransformer().

void TransformFactory::makeContextConsistentWithPlugin ( Transform transform,
Vamp::PluginBase *  plugin 
)

If the given Transform object has no processing step and block sizes set, set them to appropriate defaults for the given plugin.

Definition at line 1027 of file TransformFactory.cpp.

References downcastVampPlugin(), Transform::getBlockSize(), Transform::getStepSize(), Transform::setBlockSize(), and Transform::setStepSize().

Referenced by getDefaultTransformFor(), and FeatureExtractionModelTransformer::initialise().

Retrieve a <plugin ...

/> XML fragment that describes the plugin parameters, program and configuration data for the given transform.

This function is provided for backward compatibility only. Use Transform::toXml where compatibility with PluginXml descriptions of transforms is not required.

Definition at line 1064 of file TransformFactory.cpp.

References Transform::getIdentifier(), instantiateDefaultPluginFor(), setPluginParameters(), and PluginXml::toXml().

Set the plugin parameters, program and configuration strings on the given Transform object from the given <plugin ...

/> XML fragment.

This function is provided for backward compatibility only. Use Transform(QString) where compatibility with PluginXml descriptions of transforms is not required.

Definition at line 1087 of file TransformFactory.cpp.

References Transform::getIdentifier(), instantiateDefaultPluginFor(), setParametersFromPlugin(), and PluginXml::setParametersFromXml().


Member Data Documentation

Definition at line 203 of file TransformFactory.h.

Referenced by populateTransforms().

Definition at line 214 of file TransformFactory.h.

Referenced by populateTransforms().

Definition at line 231 of file TransformFactory.h.

Referenced by deleteInstance(), and getInstance().


The documentation for this class was generated from the following files: