Chris@0: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@0: A waveform viewer and audio annotation editor. Chris@2: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@0: Chris@0: This is experimental software. Not for distribution. Chris@0: */ Chris@0: Chris@0: #ifndef _TRANSFORM_FACTORY_H_ Chris@0: #define _TRANSFORM_FACTORY_H_ Chris@0: Chris@0: #include "Transform.h" Chris@0: Chris@16: #include Chris@16: Chris@0: class TransformFactory : public QObject Chris@0: { Chris@0: Q_OBJECT Chris@0: Chris@0: public: Chris@0: virtual ~TransformFactory(); Chris@0: Chris@0: static TransformFactory *instance(); Chris@0: Chris@0: // The name is intended to be computer-referencable, and unique Chris@47: // within the application. The description is intended to be Chris@47: // human readable. In principle it doesn't have to be unique, but Chris@47: // the factory will add suffixes to ensure that it is, all the Chris@47: // same (just to avoid user confusion). Chris@0: Chris@0: struct TransformDesc { Chris@0: TransformDesc(TransformName _name, QString _description = "") : Chris@0: name(_name), description(_description) { } Chris@0: TransformName name; Chris@0: QString description; Chris@0: }; Chris@0: typedef std::vector TransformList; Chris@0: Chris@0: TransformList getAllTransforms(); Chris@0: Chris@0: /** Chris@0: * Return the output model resulting from applying the named Chris@0: * transform to the given input model. The transform may still be Chris@0: * working in the background when the model is returned; check the Chris@0: * output model's isReady completion status for more details. Chris@0: * Chris@0: * If the transform is unknown or the input model is not an Chris@0: * appropriate type for the given transform, or if some other Chris@0: * problem occurs, return 0. Chris@0: * Chris@0: * The returned model is owned by the caller and must be deleted Chris@0: * when no longer needed. Chris@0: */ Chris@0: Model *transform(TransformName name, Model *inputModel); Chris@0: Chris@18: /** Chris@18: * Full description of a transform, suitable for putting on a menu. Chris@18: */ Chris@16: QString getTransformDescription(TransformName name); Chris@16: Chris@18: /** Chris@18: * Brief but friendly description of a transform, suitable for use Chris@18: * as the name of the output layer. Chris@18: */ Chris@18: QString getTransformFriendlyName(TransformName name); Chris@18: Chris@0: //!!! Need some way to indicate that the input model has changed / Chris@0: //been deleted so as not to blow up backgrounded transform! -- Or Chris@0: //indeed, if the output model has been deleted -- could equally Chris@0: //well happen! Chris@0: Chris@0: //!!! Need transform category! Chris@0: Chris@0: protected slots: Chris@0: void transformFinished(); Chris@0: Chris@0: protected: Chris@0: Transform *createTransform(TransformName name, Model *inputModel); Chris@0: Transform *createTransform(TransformName name, Model *inputModel, Chris@0: bool start); Chris@0: Chris@16: typedef std::map TransformMap; Chris@16: TransformMap m_transforms; Chris@16: void populateTransforms(); Chris@16: Chris@0: static TransformFactory *m_instance; Chris@0: }; Chris@0: Chris@0: Chris@0: #endif