annotate plugin/transform/Transform.h @ 325:82a2d3161e14

* Document FileSource
author Chris Cannam
date Thu, 01 Nov 2007 12:34:17 +0000
parents 32e50b620a6c
children 21bd032ae791
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@320 16 #ifndef _TRANSFORM_H_
Chris@320 17 #define _TRANSFORM_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@320 23 typedef QString TransformId;
Chris@320 24
Chris@320 25 /**
Chris@320 26 * A Transform turns one data model into another.
Chris@320 27 *
Chris@320 28 * Typically in this application, a Transform 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@320 32 * The Transform typically runs in the background, as a separate
Chris@320 33 * thread populating the output model. The model is available to the
Chris@320 34 * user of the Transform immediately, but may be initially empty until
Chris@320 35 * the background thread has populated it.
Chris@320 36 */
Chris@320 37
Chris@320 38 class Transform : public Thread
Chris@320 39 {
Chris@320 40 public:
Chris@320 41 virtual ~Transform();
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@320 53 Transform(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