Mercurial > hg > svcore
comparison data/model/Model.h @ 1527:710e6250a401 zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:14 +0100 |
parents | 9d37c8cf9686 |
children | c01cbe41aeb5 |
comparison
equal
deleted
inserted
replaced
1324:d4a28d1479a8 | 1527:710e6250a401 |
---|---|
11 published by the Free Software Foundation; either version 2 of the | 11 published by the Free Software Foundation; either version 2 of the |
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #ifndef _MODEL_H_ | 16 #ifndef SV_MODEL_H |
17 #define _MODEL_H_ | 17 #define SV_MODEL_H |
18 | 18 |
19 #include <vector> | 19 #include <vector> |
20 #include <QObject> | 20 #include <QObject> |
21 | 21 |
22 #include "base/XmlExportable.h" | 22 #include "base/XmlExportable.h" |
25 #include "base/DataExportOptions.h" | 25 #include "base/DataExportOptions.h" |
26 | 26 |
27 class ZoomConstraint; | 27 class ZoomConstraint; |
28 class AlignmentModel; | 28 class AlignmentModel; |
29 | 29 |
30 typedef int ModelId; | |
31 | |
30 /** | 32 /** |
31 * Model is the base class for all data models that represent any sort | 33 * Model is the base class for all data models that represent any sort |
32 * of data on a time scale based on an audio frame rate. | 34 * of data on a time scale based on an audio frame rate. |
33 */ | 35 */ |
34 | 36 |
35 class Model : public QObject, | 37 class Model : public QObject, |
36 public XmlExportable, | 38 public XmlExportable, |
37 public Playable | 39 public Playable |
38 { | 40 { |
39 Q_OBJECT | 41 Q_OBJECT |
40 | 42 |
41 public: | 43 public: |
51 * Return the first audio frame spanned by the model. | 53 * Return the first audio frame spanned by the model. |
52 */ | 54 */ |
53 virtual sv_frame_t getStartFrame() const = 0; | 55 virtual sv_frame_t getStartFrame() const = 0; |
54 | 56 |
55 /** | 57 /** |
56 * Return the last audio frame spanned by the model. | 58 * Return the audio frame at the end of the model, i.e. 1 more |
59 * than the final frame contained within the model. The end frame | |
60 * minus the start frame should yield the total duration in frames | |
61 * spanned by the model. This is consistent with the definition of | |
62 * the end frame of a Selection object. | |
57 */ | 63 */ |
58 virtual sv_frame_t getEndFrame() const = 0; | 64 virtual sv_frame_t getEndFrame() const = 0; |
59 | 65 |
60 /** | 66 /** |
61 * Return the frame rate in frames per second. | 67 * Return the frame rate in frames per second. |
88 /** | 94 /** |
89 * Return the type of the model. For display purposes only. | 95 * Return the type of the model. For display purposes only. |
90 */ | 96 */ |
91 virtual QString getTypeName() const = 0; | 97 virtual QString getTypeName() const = 0; |
92 | 98 |
99 /** | |
100 * Return true if this is a sparse model. | |
101 */ | |
102 virtual bool isSparse() const { return false; } | |
103 | |
104 /** | |
105 * Return an id for this model. The id is guaranteed to be a | |
106 * unique identifier for this model among all models that may ever | |
107 * exist within this single run of the application. | |
108 */ | |
109 ModelId getId() const { return m_id; } | |
110 | |
93 /** | 111 /** |
94 * Mark the model as abandoning. This means that the application | 112 * Mark the model as abandoning. This means that the application |
95 * no longer needs it, so it can stop doing any background | 113 * no longer needs it, so it can stop doing any background |
96 * calculations it may be involved in. Note that as far as the | 114 * calculations it may be involved in. Note that as far as the |
97 * model API is concerned, this does nothing more than tell the | 115 * model API is concerned, this does nothing more than tell the |
123 * reporting). If it has no way to calculate progress, it may | 141 * reporting). If it has no way to calculate progress, it may |
124 * return the special value COMPLETION_UNKNOWN. See also | 142 * return the special value COMPLETION_UNKNOWN. See also |
125 * getCompletion(). | 143 * getCompletion(). |
126 */ | 144 */ |
127 virtual bool isReady(int *completion = 0) const { | 145 virtual bool isReady(int *completion = 0) const { |
128 bool ok = isOK(); | 146 bool ok = isOK(); |
129 if (completion) *completion = (ok ? 100 : 0); | 147 if (completion) *completion = (ok ? 100 : 0); |
130 return ok; | 148 return ok; |
131 } | 149 } |
132 static const int COMPLETION_UNKNOWN; | 150 static const int COMPLETION_UNKNOWN; |
133 | 151 |
134 /** | 152 /** |
135 * If this model imposes a zoom constraint, i.e. some limit to the | 153 * If this model imposes a zoom constraint, i.e. some limit to the |
218 QString indent = "", | 236 QString indent = "", |
219 QString extraAttributes = "") const; | 237 QString extraAttributes = "") const; |
220 | 238 |
221 virtual QString toDelimitedDataString(QString delimiter) const { | 239 virtual QString toDelimitedDataString(QString delimiter) const { |
222 return toDelimitedDataStringSubset | 240 return toDelimitedDataStringSubset |
223 (delimiter, getStartFrame(), getEndFrame() + 1); | 241 (delimiter, getStartFrame(), getEndFrame()); |
224 } | 242 } |
225 virtual QString toDelimitedDataStringWithOptions(QString delimiter, DataExportOptions opts) const { | 243 virtual QString toDelimitedDataStringWithOptions(QString delimiter, DataExportOptions opts) const { |
226 return toDelimitedDataStringSubsetWithOptions | 244 return toDelimitedDataStringSubsetWithOptions |
227 (delimiter, opts, getStartFrame(), getEndFrame() + 1); | 245 (delimiter, opts, getStartFrame(), getEndFrame()); |
228 } | 246 } |
229 virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const { | 247 virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const { |
230 return ""; | 248 return ""; |
231 } | 249 } |
232 virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions, sv_frame_t f0, sv_frame_t f1) const { | 250 virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions, sv_frame_t f0, sv_frame_t f1) const { |
280 * will be emitted before the actual deletion. | 298 * will be emitted before the actual deletion. |
281 */ | 299 */ |
282 void aboutToBeDeleted(); | 300 void aboutToBeDeleted(); |
283 | 301 |
284 protected: | 302 protected: |
285 Model() : | 303 Model() : |
304 m_id(getNextId()), | |
286 m_sourceModel(0), | 305 m_sourceModel(0), |
287 m_alignment(0), | 306 m_alignment(0), |
288 m_abandoning(false), | 307 m_abandoning(false), |
289 m_aboutToDelete(false) { } | 308 m_aboutToDelete(false) { } |
290 | 309 |
291 // Not provided. | 310 // Not provided. |
292 Model(const Model &); | 311 Model(const Model &); |
293 Model &operator=(const Model &); | 312 Model &operator=(const Model &); |
294 | 313 |
314 const ModelId m_id; | |
295 Model *m_sourceModel; | 315 Model *m_sourceModel; |
296 AlignmentModel *m_alignment; | 316 AlignmentModel *m_alignment; |
297 QString m_typeUri; | 317 QString m_typeUri; |
298 bool m_abandoning; | 318 bool m_abandoning; |
299 bool m_aboutToDelete; | 319 bool m_aboutToDelete; |
320 | |
321 int getNextId(); | |
300 }; | 322 }; |
301 | 323 |
302 #endif | 324 #endif |