diff base/Event.h @ 1634:687a2453cc15 single-point

Always return consistent defaults for absent elements
author Chris Cannam
date Wed, 13 Mar 2019 10:00:49 +0000
parents 73bda079567a
children e8099be64726
line wrap: on
line diff
--- 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);