comparison data/model/SparseModel.h @ 1126:39019ce29178 tony-2.0-integration

Merge through to branch for Tony 2.0
author Chris Cannam
date Thu, 20 Aug 2015 14:54:21 +0100
parents e22bfe8ca248 ed207f89aaef
children 815f82508f96
comparison
equal deleted inserted replaced
1119:e22bfe8ca248 1126:39019ce29178
131 * supplied one using Point::Comparator. Other identical points 131 * supplied one using Point::Comparator. Other identical points
132 * may remain in the model. 132 * may remain in the model.
133 */ 133 */
134 virtual void deletePoint(const PointType &point); 134 virtual void deletePoint(const PointType &point);
135 135
136 /**
137 * Return true if the given point is found in this model, false
138 * otherwise.
139 */
140 virtual bool containsPoint(const PointType &point);
141
136 virtual bool isReady(int *completion = 0) const { 142 virtual bool isReady(int *completion = 0) const {
137 bool ready = isOK() && (m_completion == 100); 143 bool ready = isOK() && (m_completion == 100);
138 if (completion) *completion = m_completion; 144 if (completion) *completion = m_completion;
139 return ready; 145 return ready;
140 } 146 }
151 virtual void toXml(QTextStream &out, 157 virtual void toXml(QTextStream &out,
152 QString indent = "", 158 QString indent = "",
153 QString extraAttributes = "") const; 159 QString extraAttributes = "") const;
154 160
155 virtual QString toDelimitedDataString(QString delimiter) const { 161 virtual QString toDelimitedDataString(QString delimiter) const {
156 return toDelimitedDataStringWithOptions(delimiter, DataExportDefaults); 162 return toDelimitedDataStringWithOptions
163 (delimiter, DataExportDefaults);
157 } 164 }
158 165
159 virtual QString toDelimitedDataStringWithOptions(QString delimiter, 166 virtual QString toDelimitedDataStringWithOptions(QString delimiter,
160 DataExportOptions opts) const { 167 DataExportOptions opts) const {
161 return toDelimitedDataStringSubsetWithOptions 168 return toDelimitedDataStringSubsetWithOptions
162 (delimiter, opts, 169 (delimiter, opts,
163 std::min(getStartFrame(), sv_frame_t(0)), getEndFrame()); 170 std::min(getStartFrame(), sv_frame_t(0)), getEndFrame() + 1);
164 } 171 }
165 172
166 virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const { 173 virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const {
167 return toDelimitedDataStringSubsetWithOptions(delimiter, DataExportDefaults, f0, f1); 174 return toDelimitedDataStringSubsetWithOptions
175 (delimiter, DataExportDefaults, f0, f1);
168 } 176 }
169 177
170 virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions opts, sv_frame_t f0, sv_frame_t f1) const { 178 virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions opts, sv_frame_t f0, sv_frame_t f1) const {
171 if (opts & DataExportFillGaps) { 179 if (opts & DataExportFillGaps) {
172 return toDelimitedDataStringSubsetFilled(delimiter, opts, f0, f1); 180 return toDelimitedDataStringSubsetFilled(delimiter, opts, f0, f1);
767 if (m_sinceLastNotifyMax == -1 || 775 if (m_sinceLastNotifyMax == -1 ||
768 point.frame > m_sinceLastNotifyMax) { 776 point.frame > m_sinceLastNotifyMax) {
769 m_sinceLastNotifyMax = point.frame; 777 m_sinceLastNotifyMax = point.frame;
770 } 778 }
771 } 779 }
780 }
781
782 template <typename PointType>
783 bool
784 SparseModel<PointType>::containsPoint(const PointType &point)
785 {
786 {
787 QMutexLocker locker(&m_mutex);
788
789 PointListIterator i = m_points.lower_bound(point);
790 typename PointType::Comparator comparator;
791 while (i != m_points.end()) {
792 if (i->frame > point.frame) break;
793 if (!comparator(*i, point) && !comparator(point, *i)) {
794 return true;
795 }
796 ++i;
797 }
798 }
799
800 return false;
772 } 801 }
773 802
774 template <typename PointType> 803 template <typename PointType>
775 void 804 void
776 SparseModel<PointType>::deletePoint(const PointType &point) 805 SparseModel<PointType>::deletePoint(const PointType &point)