comparison plugin/transform/ModelTransformer.h @ 350:d7c41483af8f

* Merge from transforms branch -- switch over to using Transform object properly
author Chris Cannam
date Fri, 07 Dec 2007 16:47:31 +0000
parents f620ce48c950
children 399ea254afd6
comparison
equal deleted inserted replaced
348:edda24bb85fc 350:d7c41483af8f
18 18
19 #include "base/Thread.h" 19 #include "base/Thread.h"
20 20
21 #include "data/model/Model.h" 21 #include "data/model/Model.h"
22 22
23 #include "Transform.h"
24
23 /** 25 /**
24 * A ModelTransformer turns one data model into another. 26 * A ModelTransformer turns one data model into another.
25 * 27 *
26 * Typically in this application, a ModelTransformer might have a 28 * Typically in this application, a ModelTransformer might have a
27 * DenseTimeValueModel as its input (e.g. an audio waveform) and a 29 * DenseTimeValueModel as its input (e.g. an audio waveform) and a
36 class ModelTransformer : public Thread 38 class ModelTransformer : public Thread
37 { 39 {
38 public: 40 public:
39 virtual ~ModelTransformer(); 41 virtual ~ModelTransformer();
40 42
43 class Input {
44 public:
45 Input(Model *m) : m_model(m), m_channel(-1) { }
46 Input(Model *m, int c) : m_model(m), m_channel(c) { }
47
48 Model *getModel() const { return m_model; }
49 void setModel(Model *m) { m_model = m; }
50
51 int getChannel() const { return m_channel; }
52 void setChannel(int c) { m_channel = c; }
53
54 protected:
55 Model *m_model;
56 int m_channel;
57 };
58
41 // Just a hint to the processing thread that it should give up. 59 // Just a hint to the processing thread that it should give up.
42 // Caller should still wait() and/or delete the transform before 60 // Caller should still wait() and/or delete the transform before
43 // assuming its input and output models are no longer required. 61 // assuming its input and output models are no longer required.
44 void abandon() { m_abandoned = true; } 62 void abandon() { m_abandoned = true; }
45 63
46 Model *getInputModel() { return m_input; } 64 Model *getInputModel() { return m_input.getModel(); }
65 int getInputChannel() { return m_input.getChannel(); }
66
47 Model *getOutputModel() { return m_output; } 67 Model *getOutputModel() { return m_output; }
48 Model *detachOutputModel() { m_detached = true; return m_output; } 68 Model *detachOutputModel() { m_detached = true; return m_output; }
49 69
50 protected: 70 protected:
51 ModelTransformer(Model *m); 71 ModelTransformer(Input input, const Transform &transform);
52 72
53 Model *m_input; // I don't own this 73 Transform m_transform;
74 Input m_input; // I don't own the model in this
54 Model *m_output; // I own this, unless... 75 Model *m_output; // I own this, unless...
55 bool m_detached; // ... this is true. 76 bool m_detached; // ... this is true.
56 bool m_abandoned; 77 bool m_abandoned;
57 }; 78 };
58 79