changeset 872:afeb580b1b57 tonioni

Add methods to return new Clipboard points with particular characteristics (this is an immutable object)
author Chris Cannam
date Fri, 10 Jan 2014 15:21:01 +0000
parents 0b15c9328003
children 4dce43294740
files base/Clipboard.cpp base/Clipboard.h
diffstat 2 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/base/Clipboard.cpp	Thu Jan 09 21:43:33 2014 +0000
+++ b/base/Clipboard.cpp	Fri Jan 10 15:21:01 2014 +0000
@@ -123,6 +123,15 @@
     return m_frame;
 }
 
+Clipboard::Point
+Clipboard::Point::withFrame(long frame) const
+{
+    Point p(*this);
+    p.m_haveFrame = true;
+    p.m_frame = frame;
+    return p;
+}
+
 bool
 Clipboard::Point::haveValue() const
 {
@@ -135,6 +144,15 @@
     return m_value;
 }
 
+Clipboard::Point
+Clipboard::Point::withValue(float value) const
+{
+    Point p(*this);
+    p.m_haveValue = true;
+    p.m_value = value;
+    return p;
+}
+
 bool
 Clipboard::Point::haveDuration() const
 {
@@ -147,6 +165,15 @@
     return m_duration;
 }
 
+Clipboard::Point
+Clipboard::Point::withDuration(size_t duration) const
+{
+    Point p(*this);
+    p.m_haveDuration = true;
+    p.m_duration = duration;
+    return p;
+}
+
 bool
 Clipboard::Point::haveLabel() const
 {
@@ -159,6 +186,15 @@
     return m_label;
 }
 
+Clipboard::Point
+Clipboard::Point::withLabel(QString label) const
+{
+    Point p(*this);
+    p.m_haveLabel = true;
+    p.m_label = label;
+    return p;
+}
+
 bool
 Clipboard::Point::haveLevel() const
 {
@@ -171,6 +207,15 @@
     return m_level;
 }
 
+Clipboard::Point
+Clipboard::Point::withLevel(float level) const
+{
+    Point p(*this);
+    p.m_haveLevel = true;
+    p.m_level = level;
+    return p;
+}
+
 bool
 Clipboard::Point::haveReferenceFrame() const
 {
--- a/base/Clipboard.h	Thu Jan 09 21:43:33 2014 +0000
+++ b/base/Clipboard.h	Fri Jan 10 15:21:01 2014 +0000
@@ -34,18 +34,23 @@
 
         bool haveFrame() const;
         long getFrame() const;
+        Point withFrame(long frame) const;
 
         bool haveValue() const;
         float getValue() const;
+        Point withValue(float value) const;
         
         bool haveDuration() const;
         size_t getDuration() const;
+        Point withDuration(size_t duration) const;
         
         bool haveLabel() const;
         QString getLabel() const;
+        Point withLabel(QString label) const;
 
         bool haveLevel() const;
         float getLevel() const;
+        Point withLevel(float level) const;
 
         bool haveReferenceFrame() const;
         bool referenceFrameDiffers() const; // from point frame