diff data/model/NoteModel.h @ 1742:52705a328b34 by-id

Rejig ById so as to put everything in a single pool, so that at the core you can go from numeric id (untyped) to anything the object can be dynamic_cast to. Useful for building other abstractions like PlayParameter-type registrations that don't know about e.g. Models. Probably some more tweaking needed. Also add tests
author Chris Cannam
date Fri, 28 Jun 2019 17:36:30 +0100
parents 9d82b164f264
children 77543124651b
line wrap: on
line diff
--- a/data/model/NoteModel.h	Thu Jun 27 13:08:10 2019 +0100
+++ b/data/model/NoteModel.h	Fri Jun 28 17:36:30 2019 +0100
@@ -66,7 +66,7 @@
             m_valueMinimum = 33.f;
             m_valueMaximum = 88.f;
         }
-        PlayParameterRepository::getInstance()->addPlayable(this);
+        PlayParameterRepository::getInstance()->addPlayable(getId().untyped);
     }
 
     NoteModel(sv_samplerate_t sampleRate, int resolution,
@@ -87,11 +87,11 @@
                    DeferredNotifier::NOTIFY_ALWAYS :
                    DeferredNotifier::NOTIFY_DEFERRED),
         m_completion(100) {
-        PlayParameterRepository::getInstance()->addPlayable(this);
+        PlayParameterRepository::getInstance()->addPlayable(getId().untyped);
     }
 
     virtual ~NoteModel() {
-        PlayParameterRepository::getInstance()->removePlayable(this);
+        PlayParameterRepository::getInstance()->removePlayable(getId().untyped);
     }
 
     QString getTypeName() const override { return tr("Note"); }
@@ -308,7 +308,7 @@
         case 5: e1 = e0.withLabel(value.toString()); break;
         }
 
-        auto command = new ChangeEventsCommand<Model>(getId(), tr("Edit Data"));
+        auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
         command->remove(e0);
         command->add(e1);
         return command->finish();