svcore  1.9
ModelTransformer.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008    
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _TRANSFORMER_H_
00017 #define _TRANSFORMER_H_
00018 
00019 #include "base/Thread.h"
00020 
00021 #include "data/model/Model.h"
00022 
00023 #include "Transform.h"
00024 
00038 class ModelTransformer : public Thread
00039 {
00040 public:
00041     virtual ~ModelTransformer();
00042 
00043     typedef std::vector<Model *> Models;
00044 
00045     class Input {
00046     public:
00047         Input(Model *m) : m_model(m), m_channel(-1) { }
00048         Input(Model *m, int c) : m_model(m), m_channel(c) { }
00049 
00050         Model *getModel() const { return m_model; }
00051         void setModel(Model *m) { m_model = m; }
00052 
00053         int getChannel() const { return m_channel; }
00054         void setChannel(int c) { m_channel = c; }
00055 
00056     protected:
00057         Model *m_model;
00058         int m_channel;
00059     };
00060 
00068     void abandon() { m_abandoned = true; }
00069 
00073     Model *getInputModel()  { return m_input.getModel(); }
00074 
00078     int getInputChannel() { return m_input.getChannel(); }
00079 
00086     Models getOutputModels() { return m_outputs; }
00087 
00093     Models detachOutputModels() { 
00094         m_detached = true; 
00095         return getOutputModels(); 
00096     }
00097 
00105     virtual Models getAdditionalOutputModels() { return Models(); }
00106 
00112     virtual bool willHaveAdditionalOutputModels() { return false; }
00113 
00118     virtual Models detachAdditionalOutputModels() { 
00119         m_detachedAdd = true;
00120         return getAdditionalOutputModels();
00121     }
00122 
00129     QString getMessage() const { return m_message; }
00130 
00131 protected:
00132     ModelTransformer(Input input, const Transform &transform);
00133     ModelTransformer(Input input, const Transforms &transforms);
00134 
00135     Transforms m_transforms;
00136     Input m_input; // I don't own the model in this
00137     Models m_outputs; // I own this, unless...
00138     bool m_detached; // ... this is true.
00139     bool m_detachedAdd;
00140     bool m_abandoned;
00141     QString m_message;
00142 };
00143 
00144 #endif