annotate transform/ModelTransformerFactory.h @ 808:67003fb58ba4

Merge from branch "qt5". This revision actually builds with Qt4 (late releases) or Qt5, though it will warn on configure with Qt4.
author Chris Cannam
date Tue, 14 May 2013 12:36:05 +0100
parents c3dee40e77d2
children 5295bdb58840
rev   line source
Chris@320 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@320 2
Chris@320 3 /*
Chris@320 4 Sonic Visualiser
Chris@320 5 An audio file viewer and annotation editor.
Chris@320 6 Centre for Digital Music, Queen Mary, University of London.
Chris@320 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@320 8
Chris@320 9 This program is free software; you can redistribute it and/or
Chris@320 10 modify it under the terms of the GNU General Public License as
Chris@320 11 published by the Free Software Foundation; either version 2 of the
Chris@320 12 License, or (at your option) any later version. See the file
Chris@320 13 COPYING included with this distribution for more information.
Chris@320 14 */
Chris@320 15
Chris@331 16 #ifndef _MODEL_TRANSFORMER_FACTORY_H_
Chris@331 17 #define _MODEL_TRANSFORMER_FACTORY_H_
Chris@320 18
Chris@331 19 #include "Transform.h"
Chris@329 20 #include "TransformDescription.h"
Chris@329 21
Chris@331 22 #include "ModelTransformer.h"
Chris@331 23
Chris@486 24 #include <vamp-hostsdk/PluginBase.h>
Chris@486 25
Chris@653 26 #include <QMap>
Chris@320 27 #include <map>
Chris@320 28 #include <set>
Chris@320 29
Chris@389 30 class AudioPlaySource;
Chris@320 31
Chris@331 32 class ModelTransformerFactory : public QObject
Chris@320 33 {
Chris@320 34 Q_OBJECT
Chris@320 35
Chris@320 36 public:
Chris@331 37 virtual ~ModelTransformerFactory();
Chris@320 38
Chris@331 39 static ModelTransformerFactory *getInstance();
Chris@320 40
Chris@653 41 class UserConfigurator {
Chris@653 42 public:
Chris@653 43 virtual bool configure(ModelTransformer::Input &input,
Chris@653 44 Transform &transform,
Chris@653 45 Vamp::PluginBase *plugin,
Chris@664 46 Model *&inputModel,
Chris@653 47 AudioPlaySource *source,
Chris@653 48 size_t startFrame,
Chris@653 49 size_t duration,
Chris@653 50 const QMap<QString, Model *> &modelMap,
Chris@653 51 QStringList candidateModelNames,
Chris@653 52 QString defaultModelName) = 0;
Chris@653 53 };
Chris@653 54
Chris@320 55 /**
Chris@653 56 * Fill out the configuration for the given transform (may include
Chris@653 57 * asking the user by calling back on the UserConfigurator).
Chris@653 58 * Returns the selected input model and channel if the transform
Chris@653 59 * is acceptable, or an input with a null model if the operation
Chris@653 60 * should be cancelled. Audio play source may be used to audition
Chris@653 61 * effects plugins, if provided.
Chris@320 62 */
Chris@350 63 ModelTransformer::Input
Chris@350 64 getConfigurationForTransform(Transform &transform,
Chris@350 65 const std::vector<Model *> &candidateInputModels,
Chris@350 66 Model *defaultInputModel,
Chris@389 67 AudioPlaySource *source = 0,
Chris@350 68 size_t startFrame = 0,
Chris@653 69 size_t duration = 0,
Chris@653 70 UserConfigurator *configurator = 0);
Chris@350 71
Chris@320 72 /**
Chris@320 73 * Return the output model resulting from applying the named
Chris@320 74 * transform to the given input model. The transform may still be
Chris@320 75 * working in the background when the model is returned; check the
Chris@320 76 * output model's isReady completion status for more details.
Chris@320 77 *
Chris@320 78 * If the transform is unknown or the input model is not an
Chris@320 79 * appropriate type for the given transform, or if some other
Chris@361 80 * problem occurs, return 0. Set message if there is any error or
Chris@361 81 * warning to report.
Chris@320 82 *
Chris@320 83 * The returned model is owned by the caller and must be deleted
Chris@320 84 * when no longer needed.
Chris@320 85 */
Chris@350 86 Model *transform(const Transform &transform,
Chris@361 87 const ModelTransformer::Input &input,
Chris@361 88 QString &message);
Chris@320 89
Chris@320 90 protected slots:
Chris@331 91 void transformerFinished();
Chris@320 92
Chris@320 93 void modelAboutToBeDeleted(Model *);
Chris@320 94
Chris@320 95 protected:
Chris@350 96 ModelTransformer *createTransformer(const Transform &transform,
Chris@350 97 const ModelTransformer::Input &input);
Chris@320 98
Chris@329 99 typedef std::map<TransformId, QString> TransformerConfigurationMap;
Chris@328 100 TransformerConfigurationMap m_lastConfigurations;
Chris@320 101
Chris@331 102 typedef std::set<ModelTransformer *> TransformerSet;
Chris@328 103 TransformerSet m_runningTransformers;
Chris@320 104
Chris@331 105 static ModelTransformerFactory *m_instance;
Chris@320 106 };
Chris@320 107
Chris@320 108
Chris@320 109 #endif