Mercurial > hg > svcore
comparison base/Event.h @ 1663:a77a7e8c085c single-point
Update ImageModel
author | Chris Cannam |
---|---|
date | Fri, 22 Mar 2019 17:49:10 +0000 |
parents | 29a20719796e |
children | 69ab62d378bf |
comparison
equal
deleted
inserted
replaced
1662:628ffbb05856 | 1663:a77a7e8c085c |
---|---|
137 Event withLabel(QString label) const { | 137 Event withLabel(QString label) const { |
138 Event p(*this); | 138 Event p(*this); |
139 p.m_label = label; | 139 p.m_label = label; |
140 return p; | 140 return p; |
141 } | 141 } |
142 | |
143 bool hasUri() const { return m_uri != QString(); } | |
144 QString getURI() const { return m_uri; } | |
145 | |
146 Event withURI(QString uri) const { | |
147 Event p(*this); | |
148 p.m_uri = uri; | |
149 return p; | |
150 } | |
142 | 151 |
143 bool hasLevel() const { return m_haveLevel; } | 152 bool hasLevel() const { return m_haveLevel; } |
144 float getLevel() const { return m_haveLevel ? m_level : 0.f; } | 153 float getLevel() const { return m_haveLevel ? m_level : 0.f; } |
145 | 154 |
146 Event withLevel(float level) const { | 155 Event withLevel(float level) const { |
194 if (m_haveReferenceFrame != p.m_haveReferenceFrame) return false; | 203 if (m_haveReferenceFrame != p.m_haveReferenceFrame) return false; |
195 if (m_haveReferenceFrame && | 204 if (m_haveReferenceFrame && |
196 (m_referenceFrame != p.m_referenceFrame)) return false; | 205 (m_referenceFrame != p.m_referenceFrame)) return false; |
197 | 206 |
198 if (m_label != p.m_label) return false; | 207 if (m_label != p.m_label) return false; |
208 if (m_uri != p.m_uri) return false; | |
199 | 209 |
200 return true; | 210 return true; |
201 } | 211 } |
202 | 212 |
203 bool operator!=(const Event &p) const { | 213 bool operator!=(const Event &p) const { |
238 } | 248 } |
239 if (m_haveReferenceFrame && (m_referenceFrame != p.m_referenceFrame)) { | 249 if (m_haveReferenceFrame && (m_referenceFrame != p.m_referenceFrame)) { |
240 return m_referenceFrame < p.m_referenceFrame; | 250 return m_referenceFrame < p.m_referenceFrame; |
241 } | 251 } |
242 | 252 |
243 return m_label < p.m_label; | 253 if (m_label != p.m_label) { |
254 return m_label < p.m_label; | |
255 } | |
256 return m_uri < p.m_uri; | |
244 } | 257 } |
245 | 258 |
246 void toXml(QTextStream &stream, | 259 void toXml(QTextStream &stream, |
247 QString indent = "", | 260 QString indent = "", |
248 QString extraAttributes = "") const { | 261 QString extraAttributes = "") const { |
254 if (m_haveLevel) stream << QString("level=\"%1\" ").arg(m_level); | 267 if (m_haveLevel) stream << QString("level=\"%1\" ").arg(m_level); |
255 if (m_haveReferenceFrame) stream << QString("referenceFrame=\"%1\" ") | 268 if (m_haveReferenceFrame) stream << QString("referenceFrame=\"%1\" ") |
256 .arg(m_referenceFrame); | 269 .arg(m_referenceFrame); |
257 stream << QString("label=\"%1\" ") | 270 stream << QString("label=\"%1\" ") |
258 .arg(XmlExportable::encodeEntities(m_label)); | 271 .arg(XmlExportable::encodeEntities(m_label)); |
272 if (m_uri != QString()) { | |
273 stream << QString("uri=\"%1\" ") | |
274 .arg(XmlExportable::encodeEntities(m_uri)); | |
275 } | |
259 stream << extraAttributes << "/>\n"; | 276 stream << extraAttributes << "/>\n"; |
260 } | 277 } |
261 | 278 |
262 QString toXmlString(QString indent = "", | 279 QString toXmlString(QString indent = "", |
263 QString extraAttributes = "") const { | 280 QString extraAttributes = "") const { |
330 list << QString("%1").arg(m_level); | 347 list << QString("%1").arg(m_level); |
331 } | 348 } |
332 } | 349 } |
333 | 350 |
334 if (m_label != "") list << m_label; | 351 if (m_label != "") list << m_label; |
352 if (m_uri != "") list << m_uri; | |
335 | 353 |
336 return list.join(delimiter); | 354 return list.join(delimiter); |
337 } | 355 } |
338 | 356 |
339 uint hash(uint seed = 0) const { | 357 uint hash(uint seed = 0) const { |
341 if (m_haveValue) h ^= qHash(m_value); | 359 if (m_haveValue) h ^= qHash(m_value); |
342 if (m_haveLevel) h ^= qHash(m_level); | 360 if (m_haveLevel) h ^= qHash(m_level); |
343 h ^= qHash(m_frame); | 361 h ^= qHash(m_frame); |
344 if (m_haveDuration) h ^= qHash(m_duration); | 362 if (m_haveDuration) h ^= qHash(m_duration); |
345 if (m_haveReferenceFrame) h ^= qHash(m_referenceFrame); | 363 if (m_haveReferenceFrame) h ^= qHash(m_referenceFrame); |
364 h ^= qHash(m_uri); | |
346 return h; | 365 return h; |
347 } | 366 } |
348 | 367 |
349 private: | 368 private: |
350 // The order of fields here is chosen to minimise overall size of struct. | 369 // The order of fields here is chosen to minimise overall size of struct. |
358 float m_level; | 377 float m_level; |
359 sv_frame_t m_frame; | 378 sv_frame_t m_frame; |
360 sv_frame_t m_duration; | 379 sv_frame_t m_duration; |
361 sv_frame_t m_referenceFrame; | 380 sv_frame_t m_referenceFrame; |
362 QString m_label; | 381 QString m_label; |
382 QString m_uri; | |
363 }; | 383 }; |
364 | 384 |
365 inline uint qHash(const Event &e, uint seed = 0) { | 385 inline uint qHash(const Event &e, uint seed = 0) { |
366 return e.hash(seed); | 386 return e.hash(seed); |
367 } | 387 } |