annotate plugin/transform/Transformer.h @ 329:3179d8b29336

* Another incremental Transform update
author Chris Cannam
date Tue, 06 Nov 2007 17:08:11 +0000
parents 21bd032ae791
children
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.
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@329 16 #ifndef _TRANSFORMER_H_
Chris@329 17 #define _TRANSFORMER_H_
Chris@320 18
Chris@320 19 #include "base/Thread.h"
Chris@320 20
Chris@320 21 #include "data/model/Model.h"
Chris@320 22
Chris@328 23 typedef QString TransformerId;
Chris@320 24
Chris@320 25 /**
Chris@328 26 * A Transformer turns one data model into another.
Chris@320 27 *
Chris@328 28 * Typically in this application, a Transformer might have a
Chris@320 29 * DenseTimeValueModel as its input (e.g. an audio waveform) and a
Chris@320 30 * SparseOneDimensionalModel (e.g. detected beats) as its output.
Chris@320 31 *
Chris@328 32 * The Transformer typically runs in the background, as a separate
Chris@320 33 * thread populating the output model. The model is available to the
Chris@328 34 * user of the Transformer immediately, but may be initially empty until
Chris@320 35 * the background thread has populated it.
Chris@320 36 */
Chris@320 37
Chris@328 38 class Transformer : public Thread
Chris@320 39 {
Chris@320 40 public:
Chris@328 41 virtual ~Transformer();
Chris@320 42
Chris@320 43 // Just a hint to the processing thread that it should give up.
Chris@320 44 // Caller should still wait() and/or delete the transform before
Chris@320 45 // assuming its input and output models are no longer required.
Chris@320 46 void abandon() { m_abandoned = true; }
Chris@320 47
Chris@320 48 Model *getInputModel() { return m_input; }
Chris@320 49 Model *getOutputModel() { return m_output; }
Chris@320 50 Model *detachOutputModel() { m_detached = true; return m_output; }
Chris@320 51
Chris@320 52 protected:
Chris@328 53 Transformer(Model *m);
Chris@320 54
Chris@320 55 Model *m_input; // I don't own this
Chris@320 56 Model *m_output; // I own this, unless...
Chris@320 57 bool m_detached; // ... this is true.
Chris@320 58 bool m_abandoned;
Chris@320 59 };
Chris@320 60
Chris@320 61 #endif