Mercurial > hg > svcore
comparison data/model/Dense3DModelPeakCache.h @ 1778:59d9dcfd67c2
Replace the model used for the cache part of the peak-cache model with a simple vector of vectors. Avoids unnecessary locking in a class that is not thread-safe in any case. Also record whether the final column is actually truncated, rather than risk possible backward seeks to re-read it in the case where it simply might be
author | Chris Cannam |
---|---|
date | Wed, 11 Sep 2019 11:19:27 +0100 |
parents | 6d09d68165a4 |
children | c546429d4c2f |
comparison
equal
deleted
inserted
replaced
1777:d484490cdf69 | 1778:59d9dcfd67c2 |
---|---|
17 #define DENSE_3D_MODEL_PEAK_CACHE_H | 17 #define DENSE_3D_MODEL_PEAK_CACHE_H |
18 | 18 |
19 #include "DenseThreeDimensionalModel.h" | 19 #include "DenseThreeDimensionalModel.h" |
20 #include "EditableDenseThreeDimensionalModel.h" | 20 #include "EditableDenseThreeDimensionalModel.h" |
21 | 21 |
22 /** | |
23 * A DenseThreeDimensionalModel that represents a reduction in the | |
24 * time dimension of another DenseThreeDimensionalModel. Each column | |
25 * contains the peak values from a number of consecutive columns in | |
26 * the source. Each column is populated from the source model when | |
27 * first requested, and is returned from cache on subsequent requests. | |
28 * | |
29 * Dense3DModelPeakCache is not thread-safe. | |
30 */ | |
22 class Dense3DModelPeakCache : public DenseThreeDimensionalModel | 31 class Dense3DModelPeakCache : public DenseThreeDimensionalModel |
23 { | 32 { |
24 Q_OBJECT | 33 Q_OBJECT |
25 | 34 |
26 public: | 35 public: |
118 protected slots: | 127 protected slots: |
119 void sourceModelChanged(ModelId); | 128 void sourceModelChanged(ModelId); |
120 | 129 |
121 private: | 130 private: |
122 ModelId m_source; | 131 ModelId m_source; |
123 mutable std::unique_ptr<EditableDenseThreeDimensionalModel> m_cache; | |
124 mutable std::vector<bool> m_coverage; // must be bool, for space efficiency | |
125 // (vector of bool uses 1-bit elements) | |
126 int m_columnsPerPeak; | 132 int m_columnsPerPeak; |
133 | |
134 mutable std::vector<std::vector<float>> m_cache; | |
135 mutable std::vector<bool> m_coverage; // bool for space efficiency | |
136 // (vector of bool is a bitmap) | |
137 mutable bool m_finalColumnIncomplete; | |
127 | 138 |
128 bool haveColumn(int column) const; | 139 bool haveColumn(int column) const; |
129 void fillColumn(int column) const; | 140 void fillColumn(int column) const; |
130 }; | 141 }; |
131 | 142 |