comparison 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
comparison
equal deleted inserted replaced
1633:6ac92836cd86 1634:687a2453cc15
93 p.m_frame = frame; 93 p.m_frame = frame;
94 return p; 94 return p;
95 } 95 }
96 96
97 bool hasValue() const { return m_haveValue; } 97 bool hasValue() const { return m_haveValue; }
98 float getValue() const { return m_value; } 98 float getValue() const { return m_haveValue ? m_value : 0.f; }
99 99
100 Event withValue(float value) const { 100 Event withValue(float value) const {
101 Event p(*this); 101 Event p(*this);
102 p.m_haveValue = true; 102 p.m_haveValue = true;
103 p.m_value = value; 103 p.m_value = value;
109 p.m_value = 0.f; 109 p.m_value = 0.f;
110 return p; 110 return p;
111 } 111 }
112 112
113 bool hasDuration() const { return m_haveDuration; } 113 bool hasDuration() const { return m_haveDuration; }
114 sv_frame_t getDuration() const { return m_duration; } 114 sv_frame_t getDuration() const { return m_haveDuration ? m_duration : 0; }
115 115
116 Event withDuration(sv_frame_t duration) const { 116 Event withDuration(sv_frame_t duration) const {
117 Event p(*this); 117 Event p(*this);
118 p.m_duration = duration; 118 p.m_duration = duration;
119 p.m_haveDuration = true; 119 p.m_haveDuration = true;
135 p.m_label = label; 135 p.m_label = label;
136 return p; 136 return p;
137 } 137 }
138 138
139 bool hasLevel() const { return m_haveLevel; } 139 bool hasLevel() const { return m_haveLevel; }
140 float getLevel() const { return m_level; } 140 float getLevel() const { return m_haveLevel ? m_level : 0.f; }
141 141
142 Event withLevel(float level) const { 142 Event withLevel(float level) const {
143 Event p(*this); 143 Event p(*this);
144 p.m_haveLevel = true; 144 p.m_haveLevel = true;
145 p.m_level = level; 145 p.m_level = level;
151 p.m_level = 0.f; 151 p.m_level = 0.f;
152 return p; 152 return p;
153 } 153 }
154 154
155 bool hasReferenceFrame() const { return m_haveReferenceFrame; } 155 bool hasReferenceFrame() const { return m_haveReferenceFrame; }
156 sv_frame_t getReferenceFrame() const { return m_referenceFrame; } 156 sv_frame_t getReferenceFrame() const {
157 return m_haveReferenceFrame ? m_referenceFrame : m_frame;
158 }
157 159
158 bool referenceFrameDiffers() const { // from event frame 160 bool referenceFrameDiffers() const { // from event frame
159 return m_haveReferenceFrame && (m_referenceFrame != m_frame); 161 return m_haveReferenceFrame && (m_referenceFrame != m_frame);
160 } 162 }
161 163