annotate transform/TransformFactory.h @ 56:2157fa46c1e7

* Add plugin parameter dialog, and use it to set up parameters for feature extraction plugins via a semi-opaque (translucent?) configurationXml string which is associated with a given transform instance. This is not yet saved to and restored from the SV file properly. * Remove no-longer-relevant BeatDetect and BeatDetectionFunction transforms (replaced a long time ago with the beat detector plugin).
author Chris Cannam
date Wed, 22 Mar 2006 17:38:29 +0000
parents d397ea0a79f5
children 7439f1696314
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #ifndef _TRANSFORM_FACTORY_H_
Chris@0 17 #define _TRANSFORM_FACTORY_H_
Chris@0 18
Chris@0 19 #include "Transform.h"
Chris@0 20
Chris@16 21 #include <map>
Chris@16 22
Chris@0 23 class TransformFactory : public QObject
Chris@0 24 {
Chris@0 25 Q_OBJECT
Chris@0 26
Chris@0 27 public:
Chris@0 28 virtual ~TransformFactory();
Chris@0 29
Chris@0 30 static TransformFactory *instance();
Chris@0 31
Chris@56 32 // The name is intended to be computer-referenceable, and unique
Chris@47 33 // within the application. The description is intended to be
Chris@47 34 // human readable. In principle it doesn't have to be unique, but
Chris@47 35 // the factory will add suffixes to ensure that it is, all the
Chris@47 36 // same (just to avoid user confusion).
Chris@0 37
Chris@0 38 struct TransformDesc {
Chris@56 39 TransformDesc() { }
Chris@56 40 TransformDesc(TransformName _name, QString _description, bool _configurable) :
Chris@56 41 name(_name), description(_description), configurable(_configurable) { }
Chris@0 42 TransformName name;
Chris@0 43 QString description;
Chris@56 44 bool configurable;
Chris@0 45 };
Chris@0 46 typedef std::vector<TransformDesc> TransformList;
Chris@0 47
Chris@0 48 TransformList getAllTransforms();
Chris@0 49
Chris@0 50 /**
Chris@56 51 * Get a configuration XML string for the given transform (by
Chris@56 52 * asking the user, most likely). Returns true if the transform
Chris@56 53 * is acceptable, false if the operation should be cancelled.
Chris@56 54 */
Chris@56 55 bool getConfigurationForTransform(TransformName name, Model *inputModel,
Chris@56 56 QString &configurationXml);
Chris@56 57
Chris@56 58 /**
Chris@0 59 * Return the output model resulting from applying the named
Chris@0 60 * transform to the given input model. The transform may still be
Chris@0 61 * working in the background when the model is returned; check the
Chris@0 62 * output model's isReady completion status for more details.
Chris@0 63 *
Chris@0 64 * If the transform is unknown or the input model is not an
Chris@0 65 * appropriate type for the given transform, or if some other
Chris@0 66 * problem occurs, return 0.
Chris@0 67 *
Chris@0 68 * The returned model is owned by the caller and must be deleted
Chris@0 69 * when no longer needed.
Chris@0 70 */
Chris@56 71 Model *transform(TransformName name, Model *inputModel,
Chris@56 72 QString configurationXml = "");
Chris@0 73
Chris@18 74 /**
Chris@18 75 * Full description of a transform, suitable for putting on a menu.
Chris@18 76 */
Chris@16 77 QString getTransformDescription(TransformName name);
Chris@16 78
Chris@18 79 /**
Chris@18 80 * Brief but friendly description of a transform, suitable for use
Chris@18 81 * as the name of the output layer.
Chris@18 82 */
Chris@18 83 QString getTransformFriendlyName(TransformName name);
Chris@18 84
Chris@0 85 //!!! Need some way to indicate that the input model has changed /
Chris@0 86 //been deleted so as not to blow up backgrounded transform! -- Or
Chris@0 87 //indeed, if the output model has been deleted -- could equally
Chris@0 88 //well happen!
Chris@0 89
Chris@0 90 //!!! Need transform category!
Chris@0 91
Chris@0 92 protected slots:
Chris@0 93 void transformFinished();
Chris@0 94
Chris@0 95 protected:
Chris@0 96 Transform *createTransform(TransformName name, Model *inputModel,
Chris@56 97 QString configurationXml, bool start);
Chris@0 98
Chris@56 99 struct TransformIdent
Chris@56 100 {
Chris@56 101 TransformName name;
Chris@56 102 QString configurationXml;
Chris@56 103 };
Chris@56 104
Chris@56 105 typedef std::map<TransformName, QString> TransformConfigurationMap;
Chris@56 106 TransformConfigurationMap m_lastConfigurations;
Chris@56 107
Chris@56 108 typedef std::map<TransformName, TransformDesc> TransformDescriptionMap;
Chris@56 109 TransformDescriptionMap m_transforms;
Chris@56 110
Chris@16 111 void populateTransforms();
Chris@16 112
Chris@0 113 static TransformFactory *m_instance;
Chris@0 114 };
Chris@0 115
Chris@0 116
Chris@0 117 #endif