annotate transform/TransformFactory.h @ 52:d397ea0a79f5

* Update licensing rubric for GPL
author Chris Cannam
date Mon, 20 Mar 2006 15:10:07 +0000
parents 39ae3dee27b9
children 2157fa46c1e7
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@0 32 // The name is intended to be computer-referencable, 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@0 39 TransformDesc(TransformName _name, QString _description = "") :
Chris@0 40 name(_name), description(_description) { }
Chris@0 41 TransformName name;
Chris@0 42 QString description;
Chris@0 43 };
Chris@0 44 typedef std::vector<TransformDesc> TransformList;
Chris@0 45
Chris@0 46 TransformList getAllTransforms();
Chris@0 47
Chris@0 48 /**
Chris@0 49 * Return the output model resulting from applying the named
Chris@0 50 * transform to the given input model. The transform may still be
Chris@0 51 * working in the background when the model is returned; check the
Chris@0 52 * output model's isReady completion status for more details.
Chris@0 53 *
Chris@0 54 * If the transform is unknown or the input model is not an
Chris@0 55 * appropriate type for the given transform, or if some other
Chris@0 56 * problem occurs, return 0.
Chris@0 57 *
Chris@0 58 * The returned model is owned by the caller and must be deleted
Chris@0 59 * when no longer needed.
Chris@0 60 */
Chris@0 61 Model *transform(TransformName name, Model *inputModel);
Chris@0 62
Chris@18 63 /**
Chris@18 64 * Full description of a transform, suitable for putting on a menu.
Chris@18 65 */
Chris@16 66 QString getTransformDescription(TransformName name);
Chris@16 67
Chris@18 68 /**
Chris@18 69 * Brief but friendly description of a transform, suitable for use
Chris@18 70 * as the name of the output layer.
Chris@18 71 */
Chris@18 72 QString getTransformFriendlyName(TransformName name);
Chris@18 73
Chris@0 74 //!!! Need some way to indicate that the input model has changed /
Chris@0 75 //been deleted so as not to blow up backgrounded transform! -- Or
Chris@0 76 //indeed, if the output model has been deleted -- could equally
Chris@0 77 //well happen!
Chris@0 78
Chris@0 79 //!!! Need transform category!
Chris@0 80
Chris@0 81 protected slots:
Chris@0 82 void transformFinished();
Chris@0 83
Chris@0 84 protected:
Chris@0 85 Transform *createTransform(TransformName name, Model *inputModel);
Chris@0 86 Transform *createTransform(TransformName name, Model *inputModel,
Chris@0 87 bool start);
Chris@0 88
Chris@16 89 typedef std::map<TransformName, QString> TransformMap;
Chris@16 90 TransformMap m_transforms;
Chris@16 91 void populateTransforms();
Chris@16 92
Chris@0 93 static TransformFactory *m_instance;
Chris@0 94 };
Chris@0 95
Chris@0 96
Chris@0 97 #endif