add an plugin API to query generic-gui grid-layout
[ardour.git] / libs / ardour / ardour / variant.h
index d99c0e4fd377baf9805aeed9c4e1ffcc013e7c7f..4cf1df5556490946c857c14bcdd0a52ae7b57ef5 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdexcept>
 
 #include "ardour/libardour_visibility.h"
-#include "evoral/types.hpp"
+#include "evoral/Beats.hpp"
 #include "pbd/compose.h"
 
 namespace ARDOUR {
@@ -49,14 +49,15 @@ public:
                URI      ///< URI string
        };
 
-       explicit Variant()              : _type(NOTHING) { _long   = 0;     }
+       Variant() : _type(NOTHING) { _long = 0; }
+
        explicit Variant(bool    value) : _type(BOOL)    { _bool   = value; }
        explicit Variant(double  value) : _type(DOUBLE)  { _double = value; }
        explicit Variant(float   value) : _type(FLOAT)   { _float  = value; }
        explicit Variant(int32_t value) : _type(INT)     { _int    = value; }
        explicit Variant(int64_t value) : _type(LONG)    { _long   = value; }
 
-       explicit Variant(const Evoral::MusicalTime& beats)
+       explicit Variant(const Evoral::Beats& beats)
                : _type(BEATS)
                , _beats(beats)
        {}
@@ -92,6 +93,9 @@ public:
                        _long = (int64_t)lrint(std::max((double)INT64_MIN,
                                                        std::min(value, (double)INT64_MAX)));
                        break;
+               case BEATS:
+                       _beats = Evoral::Beats(value);
+                       break;
                default:
                        _type = NOTHING;
                        _long = 0;
@@ -106,6 +110,7 @@ public:
                case FLOAT:  return _float;
                case INT:    return _int;
                case LONG:   return _long;
+               case BEATS:  return _beats.to_double();
                default:     return 0.0;
                }
        }
@@ -153,17 +158,19 @@ public:
                return false;
        }
 
-       bool operator==(const Evoral::MusicalTime& v) const {
+       bool operator==(const Evoral::Beats& v) const {
                return _type == BEATS && _beats == v;
        }
 
-       Variant& operator=(Evoral::MusicalTime v) {
+       bool operator!() const { return _type == NOTHING; }
+
+       Variant& operator=(Evoral::Beats v) {
                _type  = BEATS;
                _beats = v;
                return *this;
        }
 
-       const Evoral::MusicalTime& get_beats() const {
+       const Evoral::Beats& get_beats() const {
                ensure_type(BEATS); return _beats;
        }
 
@@ -171,7 +178,7 @@ public:
 
        static bool type_is_numeric(Type type) {
                switch (type) {
-               case BOOL: case DOUBLE: case FLOAT: case INT: case LONG:
+               case BOOL: case DOUBLE: case FLOAT: case INT: case LONG: case BEATS:
                        return true;
                default:
                        return false;
@@ -195,9 +202,9 @@ private:
                }
        }
 
-       Type                _type;    ///< Type tag
-       std::string         _string;  ///< PATH, STRING, URI
-       Evoral::MusicalTime _beats;   ///< BEATS
+       Type          _type;    ///< Type tag
+       std::string   _string;  ///< PATH, STRING, URI
+       Evoral::Beats _beats;   ///< BEATS
 
        // Union of all primitive numeric types
        union {