comparison data/model/SparseModel.h @ 1066:9fc8823a73e9 tonioni

Permit extending nominal end of sparse model
author Chris Cannam
date Tue, 31 Mar 2015 12:27:56 +0100
parents 0fd3661bcfff
children 882d448c8a6d e22bfe8ca248
comparison
equal deleted inserted replaced
1065:0fd3661bcfff 1066:9fc8823a73e9
60 virtual int getResolution() const { 60 virtual int getResolution() const {
61 return m_resolution ? m_resolution : 1; 61 return m_resolution ? m_resolution : 1;
62 } 62 }
63 virtual void setResolution(int resolution); 63 virtual void setResolution(int resolution);
64 64
65 // Extend the end of the model. If this is set to something beyond
66 // the end of the final point in the model, then getEndFrame()
67 // will return this value. Otherwise getEndFrame() will return the
68 // end of the final point.
69 virtual void extendEndFrame(sv_frame_t to) { m_extendTo = to; }
70
65 typedef PointType Point; 71 typedef PointType Point;
66 typedef std::multiset<PointType, 72 typedef std::multiset<PointType,
67 typename PointType::OrderComparator> PointList; 73 typename PointType::OrderComparator> PointList;
68 typedef typename PointList::iterator PointListIterator; 74 typedef typename PointList::iterator PointListIterator;
69 typedef typename PointList::const_iterator PointListConstIterator; 75 typedef typename PointList::const_iterator PointListConstIterator;
373 } 379 }
374 380
375 protected: 381 protected:
376 sv_samplerate_t m_sampleRate; 382 sv_samplerate_t m_sampleRate;
377 int m_resolution; 383 int m_resolution;
384 sv_frame_t m_extendTo;
378 bool m_notifyOnAdd; 385 bool m_notifyOnAdd;
379 sv_frame_t m_sinceLastNotifyMin; 386 sv_frame_t m_sinceLastNotifyMin;
380 sv_frame_t m_sinceLastNotifyMax; 387 sv_frame_t m_sinceLastNotifyMax;
381 bool m_hasTextLabels; 388 bool m_hasTextLabels;
382 389
513 SparseModel<PointType>::SparseModel(sv_samplerate_t sampleRate, 520 SparseModel<PointType>::SparseModel(sv_samplerate_t sampleRate,
514 int resolution, 521 int resolution,
515 bool notifyOnAdd) : 522 bool notifyOnAdd) :
516 m_sampleRate(sampleRate), 523 m_sampleRate(sampleRate),
517 m_resolution(resolution), 524 m_resolution(resolution),
525 m_extendTo(0),
518 m_notifyOnAdd(notifyOnAdd), 526 m_notifyOnAdd(notifyOnAdd),
519 m_sinceLastNotifyMin(-1), 527 m_sinceLastNotifyMin(-1),
520 m_sinceLastNotifyMax(-1), 528 m_sinceLastNotifyMax(-1),
521 m_hasTextLabels(false), 529 m_hasTextLabels(false),
522 m_pointCount(0), 530 m_pointCount(0),
544 sv_frame_t f = 0; 552 sv_frame_t f = 0;
545 if (!m_points.empty()) { 553 if (!m_points.empty()) {
546 PointListConstIterator i(m_points.end()); 554 PointListConstIterator i(m_points.end());
547 f = (--i)->frame; 555 f = (--i)->frame;
548 } 556 }
549 return f; 557 if (m_extendTo > f) return m_extendTo;
558 else return f;
550 } 559 }
551 560
552 template <typename PointType> 561 template <typename PointType>
553 bool 562 bool
554 SparseModel<PointType>::isEmpty() const 563 SparseModel<PointType>::isEmpty() const