Mercurial > hg > svcore
diff base/Event.h @ 1623:676e32fa403e single-point
Permit hashing
author | Chris Cannam |
---|---|
date | Mon, 11 Mar 2019 11:17:18 +0000 |
parents | 2f9deb8d3295 |
children | 895186c43fce |
line wrap: on
line diff
--- a/base/Event.h Mon Mar 11 09:53:28 2019 +0000 +++ b/base/Event.h Mon Mar 11 11:17:18 2019 +0000 @@ -40,6 +40,11 @@ class Event { public: + Event() : + m_haveValue(false), m_haveLevel(false), m_haveReferenceFrame(false), + m_value(0.f), m_level(0.f), m_frame(0), + m_duration(0), m_referenceFrame(0), m_label() { } + Event(sv_frame_t frame) : m_haveValue(false), m_haveLevel(false), m_haveReferenceFrame(false), m_value(0.f), m_level(0.f), m_frame(frame), @@ -264,6 +269,16 @@ return n; } + + uint hash(uint seed = 0) const { + uint h = qHash(m_label, seed); + if (m_haveValue) h ^= qHash(m_value); + if (m_haveLevel) h ^= qHash(m_level); + h ^= qHash(m_frame); + h ^= qHash(m_duration); + if (m_haveReferenceFrame) h ^= qHash(m_referenceFrame); + return h; + } private: // The order of fields here is chosen to minimise overall size of struct. @@ -280,6 +295,10 @@ QString m_label; }; +inline uint qHash(const Event &e, uint seed = 0) { + return e.hash(seed); +} + typedef std::vector<Event> EventVector; #endif