comparison data/model/Model.h @ 1500:9d37c8cf9686 avoid-pointer-keys

Provide model id
author Chris Cannam
date Mon, 13 Aug 2018 16:45:29 +0100
parents 6e9615bde1f9
children c01cbe41aeb5
comparison
equal deleted inserted replaced
1499:68a0abfe7263 1500:9d37c8cf9686
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"
24 #include "base/BaseTypes.h" 24 #include "base/BaseTypes.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
30 typedef int ModelId;
29 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 */
96 98
97 /** 99 /**
98 * Return true if this is a sparse model. 100 * Return true if this is a sparse model.
99 */ 101 */
100 virtual bool isSparse() const { return false; } 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; }
101 110
102 /** 111 /**
103 * Mark the model as abandoning. This means that the application 112 * Mark the model as abandoning. This means that the application
104 * no longer needs it, so it can stop doing any background 113 * no longer needs it, so it can stop doing any background
105 * 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
289 * will be emitted before the actual deletion. 298 * will be emitted before the actual deletion.
290 */ 299 */
291 void aboutToBeDeleted(); 300 void aboutToBeDeleted();
292 301
293 protected: 302 protected:
294 Model() : 303 Model() :
304 m_id(getNextId()),
295 m_sourceModel(0), 305 m_sourceModel(0),
296 m_alignment(0), 306 m_alignment(0),
297 m_abandoning(false), 307 m_abandoning(false),
298 m_aboutToDelete(false) { } 308 m_aboutToDelete(false) { }
299 309
300 // Not provided. 310 // Not provided.
301 Model(const Model &); 311 Model(const Model &);
302 Model &operator=(const Model &); 312 Model &operator=(const Model &);
303 313
314 const ModelId m_id;
304 Model *m_sourceModel; 315 Model *m_sourceModel;
305 AlignmentModel *m_alignment; 316 AlignmentModel *m_alignment;
306 QString m_typeUri; 317 QString m_typeUri;
307 bool m_abandoning; 318 bool m_abandoning;
308 bool m_aboutToDelete; 319 bool m_aboutToDelete;
320
321 int getNextId();
309 }; 322 };
310 323
311 #endif 324 #endif