#include <stdexcept>
#include "ardour/libardour_visibility.h"
-#include "evoral/types.hpp"
+#include "temporal/beats.h"
#include "pbd/compose.h"
namespace ARDOUR {
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 Temporal::Beats& beats)
: _type(BEATS)
, _beats(beats)
{}
_long = (int64_t)lrint(std::max((double)INT64_MIN,
std::min(value, (double)INT64_MAX)));
break;
+ case BEATS:
+ _beats = Temporal::Beats(value);
+ break;
default:
_type = NOTHING;
_long = 0;
case FLOAT: return _float;
case INT: return _int;
case LONG: return _long;
+ case BEATS: return _beats.to_double();
default: return 0.0;
}
}
return false;
}
- bool operator==(const Evoral::MusicalTime& v) const {
+ bool operator==(const Temporal::Beats& v) const {
return _type == BEATS && _beats == v;
}
- Variant& operator=(Evoral::MusicalTime v) {
+ bool operator!() const { return _type == NOTHING; }
+
+ Variant& operator=(Temporal::Beats v) {
_type = BEATS;
_beats = v;
return *this;
}
- const Evoral::MusicalTime& get_beats() const {
+ const Temporal::Beats& get_beats() const {
ensure_type(BEATS); return _beats;
}
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;
}
}
- Type _type; ///< Type tag
- std::string _string; ///< PATH, STRING, URI
- Evoral::MusicalTime _beats; ///< BEATS
+ Type _type; ///< Type tag
+ std::string _string; ///< PATH, STRING, URI
+ Temporal::Beats _beats; ///< BEATS
// Union of all primitive numeric types
union {