# HG changeset patch # User Chris Cannam # Date 1552471249 0 # Node ID 687a2453cc1503a0b4f44950fd4ce3482a38e6d8 # Parent 6ac92836cd860645daade6ebd1ed2e8492573b62 Always return consistent defaults for absent elements diff -r 6ac92836cd86 -r 687a2453cc15 base/Event.h --- a/base/Event.h Tue Mar 12 14:56:31 2019 +0000 +++ b/base/Event.h Wed Mar 13 10:00:49 2019 +0000 @@ -95,7 +95,7 @@ } bool hasValue() const { return m_haveValue; } - float getValue() const { return m_value; } + float getValue() const { return m_haveValue ? m_value : 0.f; } Event withValue(float value) const { Event p(*this); @@ -111,7 +111,7 @@ } bool hasDuration() const { return m_haveDuration; } - sv_frame_t getDuration() const { return m_duration; } + sv_frame_t getDuration() const { return m_haveDuration ? m_duration : 0; } Event withDuration(sv_frame_t duration) const { Event p(*this); @@ -137,7 +137,7 @@ } bool hasLevel() const { return m_haveLevel; } - float getLevel() const { return m_level; } + float getLevel() const { return m_haveLevel ? m_level : 0.f; } Event withLevel(float level) const { Event p(*this); @@ -153,7 +153,9 @@ } bool hasReferenceFrame() const { return m_haveReferenceFrame; } - sv_frame_t getReferenceFrame() const { return m_referenceFrame; } + sv_frame_t getReferenceFrame() const { + return m_haveReferenceFrame ? m_referenceFrame : m_frame; + } bool referenceFrameDiffers() const { // from event frame return m_haveReferenceFrame && (m_referenceFrame != m_frame);