Mercurial > hg > svcore
comparison plugin/transform/ModelTransformer.h @ 331:f620ce48c950
* Further naming change: Transformer -> ModelTransformer.
The Transform class now describes a thing that can be done, and the
ModelTransformer does it to a Model.
author | Chris Cannam |
---|---|
date | Wed, 07 Nov 2007 12:59:01 +0000 |
parents | plugin/transform/Transformer.h@3179d8b29336 |
children | d7c41483af8f 94fc0591ea43 |
comparison
equal
deleted
inserted
replaced
330:6e9dcf09b7fe | 331:f620ce48c950 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _TRANSFORMER_H_ | |
17 #define _TRANSFORMER_H_ | |
18 | |
19 #include "base/Thread.h" | |
20 | |
21 #include "data/model/Model.h" | |
22 | |
23 /** | |
24 * A ModelTransformer turns one data model into another. | |
25 * | |
26 * Typically in this application, a ModelTransformer might have a | |
27 * DenseTimeValueModel as its input (e.g. an audio waveform) and a | |
28 * SparseOneDimensionalModel (e.g. detected beats) as its output. | |
29 * | |
30 * The ModelTransformer typically runs in the background, as a | |
31 * separate thread populating the output model. The model is | |
32 * available to the user of the ModelTransformer immediately, but may | |
33 * be initially empty until the background thread has populated it. | |
34 */ | |
35 | |
36 class ModelTransformer : public Thread | |
37 { | |
38 public: | |
39 virtual ~ModelTransformer(); | |
40 | |
41 // Just a hint to the processing thread that it should give up. | |
42 // Caller should still wait() and/or delete the transform before | |
43 // assuming its input and output models are no longer required. | |
44 void abandon() { m_abandoned = true; } | |
45 | |
46 Model *getInputModel() { return m_input; } | |
47 Model *getOutputModel() { return m_output; } | |
48 Model *detachOutputModel() { m_detached = true; return m_output; } | |
49 | |
50 protected: | |
51 ModelTransformer(Model *m); | |
52 | |
53 Model *m_input; // I don't own this | |
54 Model *m_output; // I own this, unless... | |
55 bool m_detached; // ... this is true. | |
56 bool m_abandoned; | |
57 }; | |
58 | |
59 #endif |