Mercurial > hg > svcore
comparison data/model/SparseModel.h @ 1451:b40f67578976 streaming-csv-writer
Update getEndFrame so as to refer explicitly to final frame + 1 (consistent with selection semantics and existing wave model)
author | Chris Cannam |
---|---|
date | Tue, 17 Apr 2018 10:37:15 +0100 |
parents | 48e9f538e6e9 |
children | 6e9615bde1f9 |
comparison
equal
deleted
inserted
replaced
1450:a12fd0456f0c | 1451:b40f67578976 |
---|---|
60 // 10 sample frames later. | 60 // 10 sample frames later. |
61 virtual int getResolution() const { | 61 virtual int getResolution() const { |
62 return m_resolution ? m_resolution : 1; | 62 return m_resolution ? m_resolution : 1; |
63 } | 63 } |
64 virtual void setResolution(int resolution); | 64 virtual void setResolution(int resolution); |
65 | |
66 // Extend the end of the model. If this is set to something beyond | |
67 // the end of the final point in the model, then getEndFrame() | |
68 // will return this value. Otherwise getEndFrame() will return the | |
69 // end of the final point. | |
70 virtual void extendEndFrame(sv_frame_t to) { m_extendTo = to; } | |
71 | 65 |
72 typedef PointType Point; | 66 typedef PointType Point; |
73 typedef std::multiset<PointType, | 67 typedef std::multiset<PointType, |
74 typename PointType::OrderComparator> PointList; | 68 typename PointType::OrderComparator> PointList; |
75 typedef typename PointList::iterator PointListIterator; | 69 typedef typename PointList::iterator PointListIterator; |
166 | 160 |
167 virtual QString toDelimitedDataStringWithOptions(QString delimiter, | 161 virtual QString toDelimitedDataStringWithOptions(QString delimiter, |
168 DataExportOptions opts) const { | 162 DataExportOptions opts) const { |
169 return toDelimitedDataStringSubsetWithOptions | 163 return toDelimitedDataStringSubsetWithOptions |
170 (delimiter, opts, | 164 (delimiter, opts, |
171 std::min(getStartFrame(), sv_frame_t(0)), getEndFrame() + 1); | 165 std::min(getStartFrame(), sv_frame_t(0)), getEndFrame()); |
172 } | 166 } |
173 | 167 |
174 virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { | 168 virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { |
175 return toDelimitedDataStringSubsetWithOptions | 169 return toDelimitedDataStringSubsetWithOptions |
176 (delimiter, DataExportDefaults, f0, f1); | 170 (delimiter, DataExportDefaults, f0, f1); |
393 } | 387 } |
394 | 388 |
395 protected: | 389 protected: |
396 sv_samplerate_t m_sampleRate; | 390 sv_samplerate_t m_sampleRate; |
397 int m_resolution; | 391 int m_resolution; |
398 sv_frame_t m_extendTo; | |
399 bool m_notifyOnAdd; | 392 bool m_notifyOnAdd; |
400 sv_frame_t m_sinceLastNotifyMin; | 393 sv_frame_t m_sinceLastNotifyMin; |
401 sv_frame_t m_sinceLastNotifyMax; | 394 sv_frame_t m_sinceLastNotifyMax; |
402 bool m_hasTextLabels; | 395 bool m_hasTextLabels; |
403 | 396 |
539 SparseModel<PointType>::SparseModel(sv_samplerate_t sampleRate, | 532 SparseModel<PointType>::SparseModel(sv_samplerate_t sampleRate, |
540 int resolution, | 533 int resolution, |
541 bool notifyOnAdd) : | 534 bool notifyOnAdd) : |
542 m_sampleRate(sampleRate), | 535 m_sampleRate(sampleRate), |
543 m_resolution(resolution), | 536 m_resolution(resolution), |
544 m_extendTo(0), | |
545 m_notifyOnAdd(notifyOnAdd), | 537 m_notifyOnAdd(notifyOnAdd), |
546 m_sinceLastNotifyMin(-1), | 538 m_sinceLastNotifyMin(-1), |
547 m_sinceLastNotifyMax(-1), | 539 m_sinceLastNotifyMax(-1), |
548 m_hasTextLabels(false), | 540 m_hasTextLabels(false), |
549 m_pointCount(0), | 541 m_pointCount(0), |
569 { | 561 { |
570 QMutexLocker locker(&m_mutex); | 562 QMutexLocker locker(&m_mutex); |
571 sv_frame_t f = 0; | 563 sv_frame_t f = 0; |
572 if (!m_points.empty()) { | 564 if (!m_points.empty()) { |
573 PointListConstIterator i(m_points.end()); | 565 PointListConstIterator i(m_points.end()); |
574 f = (--i)->frame; | 566 f = (--i)->frame + 1; |
575 } | 567 } |
576 if (m_extendTo > f) return m_extendTo; | 568 return f; |
577 else return f; | |
578 } | 569 } |
579 | 570 |
580 template <typename PointType> | 571 template <typename PointType> |
581 bool | 572 bool |
582 SparseModel<PointType>::isEmpty() const | 573 SparseModel<PointType>::isEmpty() const |