svcore
1.9
|
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 _MODEL_H_ 00017 #define _MODEL_H_ 00018 00019 #include <vector> 00020 #include <QObject> 00021 00022 #include "base/XmlExportable.h" 00023 #include "base/Playable.h" 00024 00025 typedef std::vector<float> SampleBlock; 00026 00027 class ZoomConstraint; 00028 class AlignmentModel; 00029 00035 class Model : public QObject, 00036 public XmlExportable, 00037 public Playable 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 virtual ~Model(); 00043 00048 virtual bool isOK() const = 0; 00049 00053 virtual int getStartFrame() const = 0; 00054 00058 virtual int getEndFrame() const = 0; 00059 00063 virtual int getSampleRate() const = 0; 00064 00069 virtual int getNativeRate() const { return getSampleRate(); } 00070 00074 virtual QString getTitle() const; 00075 00079 virtual QString getMaker() const; 00080 00086 virtual QString getLocation() const; 00087 00091 virtual QString getTypeName() const = 0; 00092 00107 virtual Model *clone() const = 0; 00108 00118 virtual void abandon() { 00119 m_abandoning = true; 00120 } 00121 00125 virtual bool isAbandoning() const { 00126 return m_abandoning; 00127 } 00128 00142 virtual bool isReady(int *completion = 0) const { 00143 bool ok = isOK(); 00144 if (completion) *completion = (ok ? 100 : 0); 00145 return ok; 00146 } 00147 static const int COMPLETION_UNKNOWN; 00148 00154 virtual const ZoomConstraint *getZoomConstraint() const { 00155 return 0; 00156 } 00157 00165 virtual Model *getSourceModel() const { 00166 return m_sourceModel; 00167 } 00168 00172 virtual void setSourceModel(Model *model); 00173 00180 virtual void setAlignment(AlignmentModel *alignment); 00181 00191 virtual const AlignmentModel *getAlignment() const; 00192 00197 virtual const Model *getAlignmentReference() const; 00198 00203 virtual int alignToReference(int frame) const; 00204 00209 virtual int alignFromReference(int referenceFrame) const; 00210 00216 virtual int getAlignmentCompletion() const; 00217 00223 void setRDFTypeURI(QString uri) { m_typeUri = uri; } 00224 00230 QString getRDFTypeURI() const { return m_typeUri; } 00231 00232 virtual void toXml(QTextStream &stream, 00233 QString indent = "", 00234 QString extraAttributes = "") const; 00235 00236 virtual QString toDelimitedDataString(QString delimiter) const { 00237 return toDelimitedDataStringSubset(delimiter, getStartFrame(), getEndFrame()); 00238 } 00239 virtual QString toDelimitedDataStringSubset(QString, int /* f0 */, int /* f1 */) const { 00240 return ""; 00241 } 00242 00243 public slots: 00244 void aboutToDelete(); 00245 void sourceModelAboutToBeDeleted(); 00246 00247 signals: 00252 void modelChanged(); 00253 00258 void modelChangedWithin(int startFrame, int endFrame); 00259 00266 void completionChanged(); 00267 00272 void ready(); 00273 00278 void alignmentCompletionChanged(); 00279 00288 void aboutToBeDeleted(); 00289 00290 protected: 00291 Model() : 00292 m_sourceModel(0), 00293 m_alignment(0), 00294 m_abandoning(false), 00295 m_aboutToDelete(false) { } 00296 00297 // Not provided. 00298 Model(const Model &); 00299 Model &operator=(const Model &); 00300 00301 Model *m_sourceModel; 00302 AlignmentModel *m_alignment; 00303 QString m_typeUri; 00304 bool m_abandoning; 00305 bool m_aboutToDelete; 00306 }; 00307 00308 #endif