annotate transform/TransformFactory.h @ 42:7bf163161b88

* more MainWindow/Document stuff
author Chris Cannam
date Wed, 08 Mar 2006 17:47:58 +0000
parents 4563a72c1d8b
children bac8b14ab355
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 -*- 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@0 27 // within the application. The description should be
Chris@0 28 // human-readable, and does not have to be unique.
Chris@0 29
Chris@0 30 struct TransformDesc {
Chris@0 31 TransformDesc(TransformName _name, QString _description = "") :
Chris@0 32 name(_name), description(_description) { }
Chris@0 33 TransformName name;
Chris@0 34 QString description;
Chris@0 35 };
Chris@0 36 typedef std::vector<TransformDesc> TransformList;
Chris@0 37
Chris@0 38 TransformList getAllTransforms();
Chris@0 39
Chris@0 40 /**
Chris@0 41 * Return the output model resulting from applying the named
Chris@0 42 * transform to the given input model. The transform may still be
Chris@0 43 * working in the background when the model is returned; check the
Chris@0 44 * output model's isReady completion status for more details.
Chris@0 45 *
Chris@0 46 * If the transform is unknown or the input model is not an
Chris@0 47 * appropriate type for the given transform, or if some other
Chris@0 48 * problem occurs, return 0.
Chris@0 49 *
Chris@0 50 * The returned model is owned by the caller and must be deleted
Chris@0 51 * when no longer needed.
Chris@0 52 */
Chris@0 53 Model *transform(TransformName name, Model *inputModel);
Chris@0 54
Chris@18 55 /**
Chris@18 56 * Full description of a transform, suitable for putting on a menu.
Chris@18 57 */
Chris@16 58 QString getTransformDescription(TransformName name);
Chris@16 59
Chris@18 60 /**
Chris@18 61 * Brief but friendly description of a transform, suitable for use
Chris@18 62 * as the name of the output layer.
Chris@18 63 */
Chris@18 64 QString getTransformFriendlyName(TransformName name);
Chris@18 65
Chris@0 66 //!!! Need some way to indicate that the input model has changed /
Chris@0 67 //been deleted so as not to blow up backgrounded transform! -- Or
Chris@0 68 //indeed, if the output model has been deleted -- could equally
Chris@0 69 //well happen!
Chris@0 70
Chris@0 71 //!!! Need transform category!
Chris@0 72
Chris@0 73 protected slots:
Chris@0 74 void transformFinished();
Chris@0 75
Chris@0 76 protected:
Chris@0 77 Transform *createTransform(TransformName name, Model *inputModel);
Chris@0 78 Transform *createTransform(TransformName name, Model *inputModel,
Chris@0 79 bool start);
Chris@0 80
Chris@16 81 typedef std::map<TransformName, QString> TransformMap;
Chris@16 82 TransformMap m_transforms;
Chris@16 83 void populateTransforms();
Chris@16 84
Chris@0 85 static TransformFactory *m_instance;
Chris@0 86 };
Chris@0 87
Chris@0 88
Chris@0 89 #endif