annotate transform/TransformFactory.h @ 49:39ae3dee27b9

* Set indent-tabs-mode to nil in Emacs mode direction
author Chris Cannam
date Mon, 20 Mar 2006 11:40:39 +0000
parents bac8b14ab355
children d397ea0a79f5
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@0 4 A waveform viewer and audio annotation editor.
Chris@2 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@0 6
Chris@0 7 This is experimental software. Not for distribution.
Chris@0 8 */
Chris@0 9
Chris@0 10 #ifndef _TRANSFORM_FACTORY_H_
Chris@0 11 #define _TRANSFORM_FACTORY_H_
Chris@0 12
Chris@0 13 #include "Transform.h"
Chris@0 14
Chris@16 15 #include <map>
Chris@16 16
Chris@0 17 class TransformFactory : public QObject
Chris@0 18 {
Chris@0 19 Q_OBJECT
Chris@0 20
Chris@0 21 public:
Chris@0 22 virtual ~TransformFactory();
Chris@0 23
Chris@0 24 static TransformFactory *instance();
Chris@0 25
Chris@0 26 // The name is intended to be computer-referencable, and unique
Chris@47 27 // within the application. The description is intended to be
Chris@47 28 // human readable. In principle it doesn't have to be unique, but
Chris@47 29 // the factory will add suffixes to ensure that it is, all the
Chris@47 30 // same (just to avoid user confusion).
Chris@0 31
Chris@0 32 struct TransformDesc {
Chris@0 33 TransformDesc(TransformName _name, QString _description = "") :
Chris@0 34 name(_name), description(_description) { }
Chris@0 35 TransformName name;
Chris@0 36 QString description;
Chris@0 37 };
Chris@0 38 typedef std::vector<TransformDesc> TransformList;
Chris@0 39
Chris@0 40 TransformList getAllTransforms();
Chris@0 41
Chris@0 42 /**
Chris@0 43 * Return the output model resulting from applying the named
Chris@0 44 * transform to the given input model. The transform may still be
Chris@0 45 * working in the background when the model is returned; check the
Chris@0 46 * output model's isReady completion status for more details.
Chris@0 47 *
Chris@0 48 * If the transform is unknown or the input model is not an
Chris@0 49 * appropriate type for the given transform, or if some other
Chris@0 50 * problem occurs, return 0.
Chris@0 51 *
Chris@0 52 * The returned model is owned by the caller and must be deleted
Chris@0 53 * when no longer needed.
Chris@0 54 */
Chris@0 55 Model *transform(TransformName name, Model *inputModel);
Chris@0 56
Chris@18 57 /**
Chris@18 58 * Full description of a transform, suitable for putting on a menu.
Chris@18 59 */
Chris@16 60 QString getTransformDescription(TransformName name);
Chris@16 61
Chris@18 62 /**
Chris@18 63 * Brief but friendly description of a transform, suitable for use
Chris@18 64 * as the name of the output layer.
Chris@18 65 */
Chris@18 66 QString getTransformFriendlyName(TransformName name);
Chris@18 67
Chris@0 68 //!!! Need some way to indicate that the input model has changed /
Chris@0 69 //been deleted so as not to blow up backgrounded transform! -- Or
Chris@0 70 //indeed, if the output model has been deleted -- could equally
Chris@0 71 //well happen!
Chris@0 72
Chris@0 73 //!!! Need transform category!
Chris@0 74
Chris@0 75 protected slots:
Chris@0 76 void transformFinished();
Chris@0 77
Chris@0 78 protected:
Chris@0 79 Transform *createTransform(TransformName name, Model *inputModel);
Chris@0 80 Transform *createTransform(TransformName name, Model *inputModel,
Chris@0 81 bool start);
Chris@0 82
Chris@16 83 typedef std::map<TransformName, QString> TransformMap;
Chris@16 84 TransformMap m_transforms;
Chris@16 85 void populateTransforms();
Chris@16 86
Chris@0 87 static TransformFactory *m_instance;
Chris@0 88 };
Chris@0 89
Chris@0 90
Chris@0 91 #endif