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 00024 typedef std::vector<float> SampleBlock; 00025 00026 class ZoomConstraint; 00027 class AlignmentModel; 00028 00034 class Model : public QObject, 00035 public XmlExportable 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 virtual ~Model(); 00041 00046 virtual bool isOK() const = 0; 00047 00051 virtual size_t getStartFrame() const = 0; 00052 00056 virtual size_t getEndFrame() const = 0; 00057 00061 virtual size_t getSampleRate() const = 0; 00062 00067 virtual size_t getNativeRate() const { return getSampleRate(); } 00068 00072 virtual QString getTitle() const; 00073 00077 virtual QString getMaker() const; 00078 00084 virtual QString getLocation() const; 00085 00089 virtual QString getTypeName() const = 0; 00090 00105 virtual Model *clone() const = 0; 00106 00120 virtual bool isReady(int *completion = 0) const { 00121 bool ok = isOK(); 00122 if (completion) *completion = (ok ? 100 : 0); 00123 return ok; 00124 } 00125 static const int COMPLETION_UNKNOWN; 00126 00132 virtual const ZoomConstraint *getZoomConstraint() const { 00133 return 0; 00134 } 00135 00143 virtual Model *getSourceModel() const { 00144 return m_sourceModel; 00145 } 00146 00150 virtual void setSourceModel(Model *model); 00151 00158 virtual void setAlignment(AlignmentModel *alignment); 00159 00164 virtual const Model *getAlignmentReference() const; 00165 00170 virtual size_t alignToReference(size_t frame) const; 00171 00176 virtual size_t alignFromReference(size_t referenceFrame) const; 00177 00183 virtual int getAlignmentCompletion() const; 00184 00185 virtual void toXml(QTextStream &stream, 00186 QString indent = "", 00187 QString extraAttributes = "") const; 00188 00189 virtual QString toDelimitedDataString(QString) const { return ""; } 00190 00191 public slots: 00192 void aboutToDelete(); 00193 void sourceModelAboutToBeDeleted(); 00194 00195 signals: 00200 void modelChanged(); 00201 00206 void modelChanged(size_t startFrame, size_t endFrame); 00207 00214 void completionChanged(); 00215 00220 void alignmentCompletionChanged(); 00221 00230 void aboutToBeDeleted(); 00231 00232 protected: 00233 Model() : m_sourceModel(0), m_alignment(0), m_aboutToDelete(false) { } 00234 00235 // Not provided. 00236 Model(const Model &); 00237 Model &operator=(const Model &); 00238 00239 Model *m_sourceModel; 00240 AlignmentModel *m_alignment; 00241 bool m_aboutToDelete; 00242 }; 00243 00244 #endif
1.5.1