ModelTransformer.h
Go to the documentation of this file.
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 SV_MODEL_TRANSFORMER_H
17 #define SV_MODEL_TRANSFORMER_H
18 
19 #include "base/Thread.h"
20 
21 #include "data/model/Model.h"
22 
23 #include "Transform.h"
24 
37 class ModelTransformer : public Thread
38 {
39 public:
40  virtual ~ModelTransformer();
41 
42  typedef std::vector<ModelId> Models;
43 
44  class Input {
45  public:
46  Input(ModelId m) : m_model(m), m_channel(-1) { }
47  Input(ModelId m, int c) : m_model(m), m_channel(c) { }
48 
49  ModelId getModel() const { return m_model; }
50  void setModel(ModelId m) { m_model = m; }
51 
52  int getChannel() const { return m_channel; }
53  void setChannel(int c) { m_channel = c; }
54 
55  protected:
57  int m_channel;
58  };
59 
66  void abandon() { m_abandoned = true; }
67 
72  bool isAbandoned() const { return m_abandoned; }
73 
78 
82  int getInputChannel() { return m_input.getChannel(); }
83 
91  Models getOutputModels() {
93  return m_outputs;
94  }
95 
103  virtual Models getAdditionalOutputModels() { return Models(); }
104 
110  virtual bool willHaveAdditionalOutputModels() { return false; }
111 
118  QString getMessage() const { return m_message; }
119 
120 protected:
121  ModelTransformer(Input input, const Transform &transform);
122  ModelTransformer(Input input, const Transforms &transforms);
123 
124  virtual void awaitOutputModels() = 0;
125 
128  Models m_outputs;
130  QString m_message;
131 };
132 
133 #endif
void abandon()
Hint to the processing thread that it should give up, for example because the process is going to exi...
int getInputChannel()
Return the input channel spec for the transform.
virtual void awaitOutputModels()=0
ModelTransformer(Input input, const Transform &transform)
std::vector< Transform > Transforms
Definition: Transform.h:204
void setModel(ModelId m)
std::vector< ModelId > Models
QString getMessage() const
Return a warning or error message.
Transforms m_transforms
ModelId getInputModel()
Return the input model for the transform.
virtual Models getAdditionalOutputModels()
Return any additional models that were created during processing.
ModelId getModel() const
virtual bool willHaveAdditionalOutputModels()
Return true if the current transform is one that may produce additional models (to be retrieved throu...
Models getOutputModels()
Return the set of output model IDs created by the transform or transforms.
Definition: Thread.h:24
A ModelTransformer turns one data model into another.
bool isAbandoned() const
Return true if the processing thread is being or has been abandoned, i.e.
Input(ModelId m, int c)
Definition: ById.h:115
virtual ~ModelTransformer()