# HG changeset patch # User Chris Cannam # Date 1552303038 0 # Node ID 676e32fa403ebde8d38144f05aa43a232b4f44f2 # Parent 172bd3374adfa4fe944f897e24eedbdd3a9b4398 Permit hashing diff -r 172bd3374adf -r 676e32fa403e base/Event.h --- 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 EventVector; #endif