Mercurial > hg > svgui
comparison view/LayerGeometryProvider.h @ 1057:218be6cf2d4f spectrogram-minor-refactor
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 13 Jun 2016 12:46:36 +0100 |
parents | 4e5c1c326794 |
children |
comparison
equal
deleted
inserted
replaced
1040:25b035362c44 | 1057:218be6cf2d4f |
---|---|
25 class View; | 25 class View; |
26 class Layer; | 26 class Layer; |
27 | 27 |
28 class LayerGeometryProvider | 28 class LayerGeometryProvider |
29 { | 29 { |
30 public: | 30 protected: |
31 LayerGeometryProvider() { | 31 static int getNextId() { |
32 static QMutex idMutex; | 32 static QMutex idMutex; |
33 static int nextId = 1; | 33 static int nextId = 1; |
34 static int maxId = INT_MAX; | |
34 QMutexLocker locker(&idMutex); | 35 QMutexLocker locker(&idMutex); |
35 m_id = nextId; | 36 int id = nextId; |
36 nextId++; | 37 if (nextId == maxId) { |
37 } | 38 // we don't expect this to happen in the lifetime of a |
39 // process, but it would be undefined behaviour if it did | |
40 // since we're using a signed int, so we should really | |
41 // guard for it... | |
42 nextId = 1; | |
43 } else { | |
44 nextId++; | |
45 } | |
46 return id; | |
47 } | |
48 | |
49 public: | |
50 LayerGeometryProvider() { } | |
38 | 51 |
39 /** | 52 /** |
40 * Retrieve the id of this object. Each LayerGeometryProvider has | 53 * Retrieve the id of this object. |
41 * a separate id. | |
42 */ | 54 */ |
43 int getId() const { return m_id; } | 55 virtual int getId() const = 0; |
44 | 56 |
45 /** | 57 /** |
46 * Retrieve the first visible sample frame on the widget. | 58 * Retrieve the first visible sample frame on the widget. |
47 * This is a calculated value based on the centre-frame, widget | 59 * This is a calculated value based on the centre-frame, widget |
48 * width and zoom level. The result may be negative. | 60 * width and zoom level. The result may be negative. |
155 | 167 |
156 virtual void updatePaintRect(QRect r) = 0; | 168 virtual void updatePaintRect(QRect r) = 0; |
157 | 169 |
158 virtual View *getView() = 0; | 170 virtual View *getView() = 0; |
159 virtual const View *getView() const = 0; | 171 virtual const View *getView() const = 0; |
160 | |
161 private: | |
162 int m_id; | |
163 }; | 172 }; |
164 | 173 |
165 #endif | 174 #endif |