diff data/model/RangeSummarisableTimeValueModel.h @ 1053:48e4ffa9fb48 cxx11

Minor simplification; could use more
author Chris Cannam
date Wed, 11 Mar 2015 11:52:05 +0000
parents cc27f35aa75c
children 54af1e21705c
line wrap: on
line diff
--- a/data/model/RangeSummarisableTimeValueModel.h	Wed Mar 11 11:03:22 2015 +0000
+++ b/data/model/RangeSummarisableTimeValueModel.h	Wed Mar 11 11:52:05 2015 +0000
@@ -41,21 +41,33 @@
     {
     public:
         Range() : 
-            m_min(0.f), m_max(0.f), m_absmean(0.f) { }
+            m_new(true), m_min(0.f), m_max(0.f), m_absmean(0.f) { }
         Range(const Range &r) : 
-            m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { }
+            m_new(true), m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { }
         Range(float min, float max, float absmean) :
-            m_min(min), m_max(max), m_absmean(absmean) { }
+            m_new(true), m_min(min), m_max(max), m_absmean(absmean) { }
 
         float min() const { return m_min; }
         float max() const { return m_max; }
         float absmean() const { return m_absmean; }
 
-        void setMin(float min) { m_min = min; }
-        void setMax(float max) { m_max = max; }
+        void setMin(float min) { m_min = min; m_new = false; }
+        void setMax(float max) { m_max = max; m_new = false; }
         void setAbsmean(float absmean) { m_absmean = absmean; }
 
+        void sample(float s) {
+            if (m_new) {
+                m_min = s;
+                m_max = s;
+                m_new = false;
+            } else {
+                if (s < m_min) m_min = s;
+                if (s > m_max) m_max = s;
+            }
+        }
+        
     private:
+        bool m_new;
         float m_min;
         float m_max;
         float m_absmean;