comparison data/model/IntervalModel.h @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents bfe724787abf
children a1cd5abcb38b
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
53 /** 53 /**
54 * PointTypes have a duration, so this returns all points that span the 54 * PointTypes have a duration, so this returns all points that span the
55 * given frame. Consequently this can be very slow (optimised 55 * given frame. Consequently this can be very slow (optimised
56 * data structures still to be done!). 56 * data structures still to be done!).
57 */ 57 */
58 virtual typename SparseValueModel<PointType>::PointList getPoints(long frame) const; 58 virtual typename SparseValueModel<PointType>::PointList getPoints(sv_frame_t frame) const;
59 59
60 virtual const typename SparseModel<PointType>::PointList &getPoints() const { 60 virtual const typename SparseModel<PointType>::PointList &getPoints() const {
61 return SparseModel<PointType>::getPoints(); 61 return SparseModel<PointType>::getPoints();
62 } 62 }
63 63
105 PointType point(*i); 105 PointType point(*i);
106 command->deletePoint(point); 106 command->deletePoint(point);
107 107
108 switch (column) { 108 switch (column) {
109 // column cannot be 0 or 1, those cases were handled above 109 // column cannot be 0 or 1, those cases were handled above
110 case 2: point.value = value.toDouble(); break; 110 case 2: point.value = float(value.toDouble()); break;
111 case 3: point.duration = value.toInt(); break; 111 case 3: point.duration = value.toInt(); break;
112 } 112 }
113 113
114 command->addPoint(point); 114 command->addPoint(point);
115 return command->finish(); 115 return command->finish();
123 } 123 }
124 }; 124 };
125 125
126 template <typename PointType> 126 template <typename PointType>
127 typename SparseValueModel<PointType>::PointList 127 typename SparseValueModel<PointType>::PointList
128 IntervalModel<PointType>::getPoints(long start, long end) const 128 IntervalModel<PointType>::getPoints(sv_frame_t start, sv_frame_t end) const
129 { 129 {
130 typedef IntervalModel<PointType> I; 130 typedef IntervalModel<PointType> I;
131 131
132 if (start > end) return typename I::PointList(); 132 if (start > end) return typename I::PointList();
133 133
144 typename I::PointList rv; 144 typename I::PointList rv;
145 145
146 for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) { 146 for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
147 --i; 147 --i;
148 if (i->frame < start) { 148 if (i->frame < start) {
149 if (i->frame + long(i->duration) >= start) { 149 if (i->frame + i->duration >= start) {
150 rv.insert(*i); 150 rv.insert(*i);
151 } 151 }
152 } else if (i->frame <= end) { 152 } else if (i->frame <= end) {
153 rv.insert(*i); 153 rv.insert(*i);
154 } 154 }
157 return rv; 157 return rv;
158 } 158 }
159 159
160 template <typename PointType> 160 template <typename PointType>
161 typename SparseValueModel<PointType>::PointList 161 typename SparseValueModel<PointType>::PointList
162 IntervalModel<PointType>::getPoints(long frame) const 162 IntervalModel<PointType>::getPoints(sv_frame_t frame) const
163 { 163 {
164 typedef IntervalModel<PointType> I; 164 typedef IntervalModel<PointType> I;
165 165
166 QMutex &mutex(I::m_mutex); 166 QMutex &mutex(I::m_mutex);
167 QMutexLocker locker(&mutex); 167 QMutexLocker locker(&mutex);
168 168
169 if (I::m_resolution == 0) return typename I::PointList(); 169 if (I::m_resolution == 0) return typename I::PointList();
170 170
171 long start = (frame / I::m_resolution) * I::m_resolution; 171 sv_frame_t start = (frame / I::m_resolution) * I::m_resolution;
172 long end = start + I::m_resolution; 172 sv_frame_t end = start + I::m_resolution;
173 173
174 PointType endPoint(end); 174 PointType endPoint(end);
175 175
176 typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint); 176 typename I::PointListConstIterator endItr = I::m_points.upper_bound(endPoint);
177 177
178 typename I::PointList rv; 178 typename I::PointList rv;
179 179
180 for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) { 180 for (typename I::PointListConstIterator i = endItr; i != I::m_points.begin(); ) {
181 --i; 181 --i;
182 if (i->frame < start) { 182 if (i->frame < start) {
183 if (i->frame + long(i->duration) >= start) { 183 if (i->frame + i->duration >= start) {
184 rv.insert(*i); 184 rv.insert(*i);
185 } 185 }
186 } else if (i->frame <= end) { 186 } else if (i->frame <= end) {
187 rv.insert(*i); 187 rv.insert(*i);
188 } 188 }