Chris@320: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@320: Chris@320: /* Chris@320: Sonic Visualiser Chris@320: An audio file viewer and annotation editor. Chris@320: Centre for Digital Music, Queen Mary, University of London. Chris@320: This file copyright 2006 Chris Cannam. Chris@320: Chris@320: This program is free software; you can redistribute it and/or Chris@320: modify it under the terms of the GNU General Public License as Chris@320: published by the Free Software Foundation; either version 2 of the Chris@320: License, or (at your option) any later version. See the file Chris@320: COPYING included with this distribution for more information. Chris@320: */ Chris@320: Chris@320: #ifndef _TRANSFORM_H_ Chris@320: #define _TRANSFORM_H_ Chris@320: Chris@320: #include "base/Thread.h" Chris@320: Chris@320: #include "data/model/Model.h" Chris@320: Chris@320: typedef QString TransformId; Chris@320: Chris@320: /** Chris@320: * A Transform turns one data model into another. Chris@320: * Chris@320: * Typically in this application, a Transform might have a Chris@320: * DenseTimeValueModel as its input (e.g. an audio waveform) and a Chris@320: * SparseOneDimensionalModel (e.g. detected beats) as its output. Chris@320: * Chris@320: * The Transform typically runs in the background, as a separate Chris@320: * thread populating the output model. The model is available to the Chris@320: * user of the Transform immediately, but may be initially empty until Chris@320: * the background thread has populated it. Chris@320: */ Chris@320: Chris@320: class Transform : public Thread Chris@320: { Chris@320: public: Chris@320: virtual ~Transform(); Chris@320: Chris@320: // Just a hint to the processing thread that it should give up. Chris@320: // Caller should still wait() and/or delete the transform before Chris@320: // assuming its input and output models are no longer required. Chris@320: void abandon() { m_abandoned = true; } Chris@320: Chris@320: Model *getInputModel() { return m_input; } Chris@320: Model *getOutputModel() { return m_output; } Chris@320: Model *detachOutputModel() { m_detached = true; return m_output; } Chris@320: Chris@320: protected: Chris@320: Transform(Model *m); Chris@320: Chris@320: Model *m_input; // I don't own this Chris@320: Model *m_output; // I own this, unless... Chris@320: bool m_detached; // ... this is true. Chris@320: bool m_abandoned; Chris@320: }; Chris@320: Chris@320: #endif