comparison data/model/SparseModel.h @ 929:59e7fe1b1003 warnfix_no_size_t

Unsigned removals and warning fixes in data/
author Chris Cannam
date Tue, 17 Jun 2014 14:33:42 +0100
parents c2a399f93843
children 06579b8ffb7b
comparison
equal deleted inserted replaced
928:6a94bb528e9d 929:59e7fe1b1003
41 template <typename PointType> 41 template <typename PointType>
42 class SparseModel : public Model, 42 class SparseModel : public Model,
43 public TabularModel 43 public TabularModel
44 { 44 {
45 public: 45 public:
46 SparseModel(size_t sampleRate, size_t resolution, 46 SparseModel(int sampleRate, int resolution,
47 bool notifyOnAdd = true); 47 bool notifyOnAdd = true);
48 virtual ~SparseModel() { } 48 virtual ~SparseModel() { }
49 49
50 virtual bool isOK() const { return true; } 50 virtual bool isOK() const { return true; }
51 virtual size_t getStartFrame() const; 51 virtual int getStartFrame() const;
52 virtual size_t getEndFrame() const; 52 virtual int getEndFrame() const;
53 virtual size_t getSampleRate() const { return m_sampleRate; } 53 virtual int getSampleRate() const { return m_sampleRate; }
54 54
55 virtual Model *clone() const; 55 virtual Model *clone() const;
56 56
57 // Number of frames of the underlying sample rate that this model 57 // Number of frames of the underlying sample rate that this model
58 // is capable of resolving to. For example, if m_resolution == 10 58 // is capable of resolving to. For example, if m_resolution == 10
59 // then every point in this model will be at a multiple of 10 59 // then every point in this model will be at a multiple of 10
60 // sample frames and should be considered to cover a window ending 60 // sample frames and should be considered to cover a window ending
61 // 10 sample frames later. 61 // 10 sample frames later.
62 virtual size_t getResolution() const { 62 virtual int getResolution() const {
63 return m_resolution ? m_resolution : 1; 63 return m_resolution ? m_resolution : 1;
64 } 64 }
65 virtual void setResolution(size_t resolution); 65 virtual void setResolution(int resolution);
66 66
67 typedef PointType Point; 67 typedef PointType Point;
68 typedef std::multiset<PointType, 68 typedef std::multiset<PointType,
69 typename PointType::OrderComparator> PointList; 69 typename PointType::OrderComparator> PointList;
70 typedef typename PointList::iterator PointListIterator; 70 typedef typename PointList::iterator PointListIterator;
76 virtual bool isEmpty() const; 76 virtual bool isEmpty() const;
77 77
78 /** 78 /**
79 * Get the total number of points in the model. 79 * Get the total number of points in the model.
80 */ 80 */
81 virtual size_t getPointCount() const; 81 virtual int getPointCount() const;
82 82
83 /** 83 /**
84 * Get all points. 84 * Get all points.
85 */ 85 */
86 virtual const PointList &getPoints() const; 86 virtual const PointList &getPoints() const;
155 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; 155 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n";
156 } 156 }
157 return s; 157 return s;
158 } 158 }
159 159
160 virtual QString toDelimitedDataString(QString delimiter, size_t f0, size_t f1) const 160 virtual QString toDelimitedDataString(QString delimiter, int f0, int f1) const
161 { 161 {
162 QString s; 162 QString s;
163 for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) { 163 for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
164 if (i->frame >= (long)f0 && i->frame < (long)f1) { 164 if (i->frame >= (long)f0 && i->frame < (long)f1) {
165 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; 165 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n";
369 command->deletePoint(*i); 369 command->deletePoint(*i);
370 return command->finish(); 370 return command->finish();
371 } 371 }
372 372
373 protected: 373 protected:
374 size_t m_sampleRate; 374 int m_sampleRate;
375 size_t m_resolution; 375 int m_resolution;
376 bool m_notifyOnAdd; 376 bool m_notifyOnAdd;
377 long m_sinceLastNotifyMin; 377 long m_sinceLastNotifyMin;
378 long m_sinceLastNotifyMax; 378 long m_sinceLastNotifyMax;
379 bool m_hasTextLabels; 379 bool m_hasTextLabels;
380 380
381 PointList m_points; 381 PointList m_points;
382 size_t m_pointCount; 382 int m_pointCount;
383 mutable QMutex m_mutex; 383 mutable QMutex m_mutex;
384 int m_completion; 384 int m_completion;
385 385
386 void getPointIterators(long frame, 386 void getPointIterators(long frame,
387 PointListIterator &startItr, 387 PointListIterator &startItr,
405 PointListIterator getPointListIteratorForRow(int row) 405 PointListIterator getPointListIteratorForRow(int row)
406 { 406 {
407 if (m_rows.empty()) rebuildRowVector(); 407 if (m_rows.empty()) rebuildRowVector();
408 if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end(); 408 if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end();
409 409
410 size_t frame = m_rows[row]; 410 int frame = m_rows[row];
411 int indexAtFrame = 0; 411 int indexAtFrame = 0;
412 int ri = row; 412 int ri = row;
413 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } 413 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; }
414 int initialIndexAtFrame = indexAtFrame; 414 int initialIndexAtFrame = indexAtFrame;
415 415
432 PointListConstIterator getPointListIteratorForRow(int row) const 432 PointListConstIterator getPointListIteratorForRow(int row) const
433 { 433 {
434 if (m_rows.empty()) rebuildRowVector(); 434 if (m_rows.empty()) rebuildRowVector();
435 if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end(); 435 if (row < 0 || row + 1 > int(m_rows.size())) return m_points.end();
436 436
437 size_t frame = m_rows[row]; 437 int frame = m_rows[row];
438 int indexAtFrame = 0; 438 int indexAtFrame = 0;
439 int ri = row; 439 int ri = row;
440 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; } 440 while (ri > 0 && m_rows[ri-1] == m_rows[row]) { --ri; ++indexAtFrame; }
441 int initialIndexAtFrame = indexAtFrame; 441 int initialIndexAtFrame = indexAtFrame;
442 442
463 } 463 }
464 }; 464 };
465 465
466 466
467 template <typename PointType> 467 template <typename PointType>
468 SparseModel<PointType>::SparseModel(size_t sampleRate, 468 SparseModel<PointType>::SparseModel(int sampleRate,
469 size_t resolution, 469 int resolution,
470 bool notifyOnAdd) : 470 bool notifyOnAdd) :
471 m_sampleRate(sampleRate), 471 m_sampleRate(sampleRate),
472 m_resolution(resolution), 472 m_resolution(resolution),
473 m_notifyOnAdd(notifyOnAdd), 473 m_notifyOnAdd(notifyOnAdd),
474 m_sinceLastNotifyMin(-1), 474 m_sinceLastNotifyMin(-1),
478 m_completion(100) 478 m_completion(100)
479 { 479 {
480 } 480 }
481 481
482 template <typename PointType> 482 template <typename PointType>
483 size_t 483 int
484 SparseModel<PointType>::getStartFrame() const 484 SparseModel<PointType>::getStartFrame() const
485 { 485 {
486 QMutexLocker locker(&m_mutex); 486 QMutexLocker locker(&m_mutex);
487 size_t f = 0; 487 int f = 0;
488 if (!m_points.empty()) { 488 if (!m_points.empty()) {
489 f = m_points.begin()->frame; 489 f = m_points.begin()->frame;
490 } 490 }
491 return f; 491 return f;
492 } 492 }
493 493
494 template <typename PointType> 494 template <typename PointType>
495 size_t 495 int
496 SparseModel<PointType>::getEndFrame() const 496 SparseModel<PointType>::getEndFrame() const
497 { 497 {
498 QMutexLocker locker(&m_mutex); 498 QMutexLocker locker(&m_mutex);
499 size_t f = 0; 499 int f = 0;
500 if (!m_points.empty()) { 500 if (!m_points.empty()) {
501 PointListConstIterator i(m_points.end()); 501 PointListConstIterator i(m_points.end());
502 f = (--i)->frame; 502 f = (--i)->frame;
503 } 503 }
504 return f; 504 return f;
524 { 524 {
525 return m_pointCount == 0; 525 return m_pointCount == 0;
526 } 526 }
527 527
528 template <typename PointType> 528 template <typename PointType>
529 size_t 529 int
530 SparseModel<PointType>::getPointCount() const 530 SparseModel<PointType>::getPointCount() const
531 { 531 {
532 return m_pointCount; 532 return m_pointCount;
533 } 533 }
534 534
674 return rv; 674 return rv;
675 } 675 }
676 676
677 template <typename PointType> 677 template <typename PointType>
678 void 678 void
679 SparseModel<PointType>::setResolution(size_t resolution) 679 SparseModel<PointType>::setResolution(int resolution)
680 { 680 {
681 { 681 {
682 QMutexLocker locker(&m_mutex); 682 QMutexLocker locker(&m_mutex);
683 m_resolution = resolution; 683 m_resolution = resolution;
684 } 684 }