comparison base/ById.h @ 1744:b92bdcd4954b by-id

Update FFT model to ById
author Chris Cannam
date Tue, 02 Jul 2019 11:49:28 +0100
parents 52705a328b34
children 826e0cb77d8e
comparison
equal deleted inserted replaced
1743:7001b9570e37 1744:b92bdcd4954b
24 24
25 #include <QMutex> 25 #include <QMutex>
26 #include <QString> 26 #include <QString>
27 27
28 #include "XmlExportable.h" 28 #include "XmlExportable.h"
29
30 //!!! todo: docs
29 31
30 struct IdAlloc { 32 struct IdAlloc {
31 33
32 // The value NO_ID (-1) is never allocated 34 // The value NO_ID (-1) is never allocated
33 static const int NO_ID = -1; 35 static const int NO_ID = -1;
151 release(item->getId()); 153 release(item->getId());
152 } 154 }
153 155
154 template <typename Derived> 156 template <typename Derived>
155 static std::shared_ptr<Derived> getAs(Id id) { 157 static std::shared_ptr<Derived> getAs(Id id) {
156 if (id.isNone()) return {}; // this id is never issued: avoid locking
157 return AnyById::getAs<Derived>(id.untyped); 158 return AnyById::getAs<Derived>(id.untyped);
158 } 159 }
159 160
160 static std::shared_ptr<Item> get(Id id) { 161 static std::shared_ptr<Item> get(Id id) {
161 return getAs<Item>(id); 162 return getAs<Item>(id);