diff data/model/Model.h @ 1507:fe579dc6a713 import-audio-data

Merge from default branch
author Chris Cannam
date Tue, 04 Sep 2018 13:19:20 +0100
parents 9d37c8cf9686
children c01cbe41aeb5
line wrap: on
line diff
--- a/data/model/Model.h	Fri Jun 29 13:52:36 2018 +0100
+++ b/data/model/Model.h	Tue Sep 04 13:19:20 2018 +0100
@@ -13,8 +13,8 @@
     COPYING included with this distribution for more information.
 */
 
-#ifndef _MODEL_H_
-#define _MODEL_H_
+#ifndef SV_MODEL_H
+#define SV_MODEL_H
 
 #include <vector>
 #include <QObject>
@@ -27,6 +27,8 @@
 class ZoomConstraint;
 class AlignmentModel;
 
+typedef int ModelId;
+
 /** 
  * Model is the base class for all data models that represent any sort
  * of data on a time scale based on an audio frame rate.
@@ -98,6 +100,13 @@
      * Return true if this is a sparse model.
      */
     virtual bool isSparse() const { return false; }
+
+    /**
+     * Return an id for this model. The id is guaranteed to be a
+     * unique identifier for this model among all models that may ever
+     * exist within this single run of the application.
+     */
+    ModelId getId() const { return m_id; }
     
     /**
      * Mark the model as abandoning. This means that the application
@@ -291,7 +300,8 @@
     void aboutToBeDeleted();
 
 protected:
-    Model() : 
+    Model() :
+        m_id(getNextId()),
         m_sourceModel(0), 
         m_alignment(0), 
         m_abandoning(false), 
@@ -301,11 +311,14 @@
     Model(const Model &);
     Model &operator=(const Model &); 
 
+    const ModelId m_id;
     Model *m_sourceModel;
     AlignmentModel *m_alignment;
     QString m_typeUri;
     bool m_abandoning;
     bool m_aboutToDelete;
+
+    int getNextId();
 };
 
 #endif