summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/amp.h2
-rw-r--r--libs/ardour/ardour/automatable_sequence.h1
-rw-r--r--libs/ardour/ardour/automation_control.h22
-rw-r--r--libs/ardour/ardour/event_type_map.h12
-rw-r--r--libs/ardour/ardour/lv2_plugin.h45
-rw-r--r--libs/ardour/ardour/midi_buffer.h6
-rw-r--r--libs/ardour/ardour/midi_track.h2
-rw-r--r--libs/ardour/ardour/pan_controllable.h6
-rw-r--r--libs/ardour/ardour/parameter_descriptor.h22
-rw-r--r--libs/ardour/ardour/parameter_types.h66
-rw-r--r--libs/ardour/ardour/plugin.h12
-rw-r--r--libs/ardour/ardour/plugin_insert.h29
-rw-r--r--libs/ardour/ardour/types.h1
-rw-r--r--libs/ardour/ardour/uri_map.h40
-rw-r--r--libs/ardour/ardour/variant.h66
15 files changed, 272 insertions, 60 deletions
diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h
index c0e9dbc5b5..b70cd0095c 100644
--- a/libs/ardour/ardour/amp.h
+++ b/libs/ardour/ardour/amp.h
@@ -79,7 +79,7 @@ public:
struct GainControl : public AutomationControl {
GainControl (std::string name, Session& session, Amp* a, const Evoral::Parameter &param,
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>() )
- : AutomationControl (session, param, al, name)
+ : AutomationControl (session, param, ParameterDescriptor(param), al, name)
, _amp (a) {
set_flags (Controllable::Flag (flags() | Controllable::GainLike));
alist()->reset_default (1.0);
diff --git a/libs/ardour/ardour/automatable_sequence.h b/libs/ardour/ardour/automatable_sequence.h
index b0003189a4..0d3871eb17 100644
--- a/libs/ardour/ardour/automatable_sequence.h
+++ b/libs/ardour/ardour/automatable_sequence.h
@@ -22,6 +22,7 @@
#include "evoral/Sequence.hpp"
#include "ardour/automatable.h"
+#include "ardour/event_type_map.h"
namespace ARDOUR {
diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h
index 3603ea2e72..639c5b5287 100644
--- a/libs/ardour/ardour/automation_control.h
+++ b/libs/ardour/ardour/automation_control.h
@@ -29,6 +29,7 @@
#include "ardour/libardour_visibility.h"
#include "ardour/automation_list.h"
+#include "ardour/parameter_descriptor.h"
namespace ARDOUR {
@@ -42,11 +43,12 @@ class LIBARDOUR_API AutomationControl : public PBD::Controllable, public Evoral:
{
public:
AutomationControl(ARDOUR::Session&,
- const Evoral::Parameter& parameter,
- boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
- const std::string& name="");
+ const Evoral::Parameter& parameter,
+ const ParameterDescriptor& desc,
+ boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
+ const std::string& name="");
- ~AutomationControl ();
+ ~AutomationControl ();
boost::shared_ptr<AutomationList> alist() const {
return boost::dynamic_pointer_cast<AutomationList>(_list);
@@ -78,16 +80,20 @@ public:
void set_value (double);
double get_value () const;
- double lower() const { return parameter().min(); }
- double upper() const { return parameter().max(); }
- double normal() const { return parameter().normal(); }
- bool toggled() const { return parameter().toggled(); }
+ double lower() const { return _desc.lower; }
+ double upper() const { return _desc.upper; }
+ double normal() const { return _desc.normal; }
+ bool toggled() const { return _desc.toggled; }
+
+ const ParameterDescriptor& desc() const { return _desc; }
const ARDOUR::Session& session() const { return _session; }
protected:
ARDOUR::Session& _session;
+
+ const ParameterDescriptor _desc;
};
diff --git a/libs/ardour/ardour/event_type_map.h b/libs/ardour/ardour/event_type_map.h
index fbfd9ec73c..f69d20b773 100644
--- a/libs/ardour/ardour/event_type_map.h
+++ b/libs/ardour/ardour/event_type_map.h
@@ -29,11 +29,15 @@
namespace ARDOUR {
+class URIMap;
+
/** This is the interface Ardour provides to Evoral about what
* parameter and event types/ranges/names etc. to use.
*/
class LIBARDOUR_API EventTypeMap : public Evoral::TypeMap {
public:
+ static EventTypeMap& instance();
+
bool type_is_midi(uint32_t type) const;
uint8_t parameter_midi_type(const Evoral::Parameter& param) const;
uint32_t midi_event_type(uint8_t status) const;
@@ -46,10 +50,14 @@ public:
bool is_midi_parameter(const Evoral::Parameter& param);
- static EventTypeMap& instance() { return event_type_map; }
+ URIMap& uri_map() { return _uri_map; }
private:
- static EventTypeMap event_type_map;
+ EventTypeMap(URIMap& uri_map) : _uri_map(uri_map) {}
+
+ URIMap& _uri_map;
+
+ static EventTypeMap* event_type_map;
};
} // namespace ARDOUR
diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h
index 82912a947d..9696784f01 100644
--- a/libs/ardour/ardour/lv2_plugin.h
+++ b/libs/ardour/ardour/lv2_plugin.h
@@ -146,42 +146,16 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
Worker* worker() { return _worker; }
+ URIMap& uri_map() { return _uri_map; }
+ const URIMap& uri_map() const { return _uri_map; }
+
int work(uint32_t size, const void* data);
int work_response(uint32_t size, const void* data);
- void set_property(uint32_t key, const Variant& value);
- void get_supported_properties(std::vector<ParameterDescriptor>& descs);
- void announce_property_values();
-
- static URIMap _uri_map;
-
- struct URIDs {
- uint32_t atom_Chunk;
- uint32_t atom_Path;
- uint32_t atom_Sequence;
- uint32_t atom_eventTransfer;
- uint32_t atom_URID;
- uint32_t atom_Blank;
- uint32_t atom_Object;
- uint32_t log_Error;
- uint32_t log_Note;
- uint32_t log_Warning;
- uint32_t midi_MidiEvent;
- uint32_t time_Position;
- uint32_t time_bar;
- uint32_t time_barBeat;
- uint32_t time_beatUnit;
- uint32_t time_beatsPerBar;
- uint32_t time_beatsPerMinute;
- uint32_t time_frame;
- uint32_t time_speed;
- uint32_t patch_Get;
- uint32_t patch_Set;
- uint32_t patch_property;
- uint32_t patch_value;
- };
-
- static URIDs urids;
+ void set_property(uint32_t key, const Variant& value);
+ const PropertyDescriptors& get_supported_properties() const { return _property_descriptors; }
+ const ParameterDescriptor& get_property_descriptor(uint32_t id) const;
+ void announce_property_values();
private:
struct Impl;
@@ -203,6 +177,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
PBD::ID _insert_id;
uint32_t _patch_port_in_index;
uint32_t _patch_port_out_index;
+ URIMap& _uri_map;
friend const void* lv2plugin_get_port_value(const char* port_symbol,
void* user_data,
@@ -227,6 +202,8 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
std::vector<size_t> _port_minimumSize;
std::map<std::string,uint32_t> _port_indices;
+ PropertyDescriptors _property_descriptors;
+
/// Message send to/from UI via ports
struct UIMessage {
uint32_t index;
@@ -283,6 +260,8 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
void allocate_atom_event_buffers ();
void run (pframes_t nsamples);
+ void load_supported_properties(PropertyDescriptors& descs);
+
void latency_compute_run ();
std::string do_save_preset (std::string);
void do_remove_preset (std::string);
diff --git a/libs/ardour/ardour/midi_buffer.h b/libs/ardour/ardour/midi_buffer.h
index f0c76ca86c..2923b784a9 100644
--- a/libs/ardour/ardour/midi_buffer.h
+++ b/libs/ardour/ardour/midi_buffer.h
@@ -23,7 +23,7 @@
#include "evoral/midi_util.h"
#include "midi++/event.h"
#include "ardour/buffer.h"
-#include "ardour/event_type_map.h"
+#include "ardour/parameter_types.h"
namespace ARDOUR {
@@ -77,7 +77,7 @@ public:
uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
int event_size = Evoral::midi_event_size(ev_start);
assert(event_size >= 0);
- return EventType(EventTypeMap::instance().midi_event_type(*ev_start),
+ return EventType(midi_parameter_type(*ev_start),
*((TimeType*)(buffer->_data + offset)),
event_size, ev_start);
}
@@ -86,7 +86,7 @@ public:
uint8_t* ev_start = buffer->_data + offset + sizeof(TimeType);
int event_size = Evoral::midi_event_size(ev_start);
assert(event_size >= 0);
- return EventType(EventTypeMap::instance().midi_event_type(*ev_start),
+ return EventType(midi_parameter_type(*ev_start),
*(reinterpret_cast<TimeType*>((uintptr_t)(buffer->_data + offset))),
event_size, ev_start);
}
diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h
index cea3af5aed..3db16937fc 100644
--- a/libs/ardour/ardour/midi_track.h
+++ b/libs/ardour/ardour/midi_track.h
@@ -84,7 +84,7 @@ public:
struct MidiControl : public AutomationControl {
MidiControl(MidiTrack* route, const Evoral::Parameter& param,
boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>())
- : AutomationControl (route->session(), param, al)
+ : AutomationControl (route->session(), param, ParameterDescriptor(param), al)
, _route (route)
{}
diff --git a/libs/ardour/ardour/pan_controllable.h b/libs/ardour/ardour/pan_controllable.h
index 9abbec42ab..63ee9d3b8c 100644
--- a/libs/ardour/ardour/pan_controllable.h
+++ b/libs/ardour/ardour/pan_controllable.h
@@ -38,7 +38,11 @@ class LIBARDOUR_API PanControllable : public AutomationControl
{
public:
PanControllable (Session& s, std::string name, Pannable* o, Evoral::Parameter param)
- : AutomationControl (s, param, boost::shared_ptr<AutomationList>(new AutomationList(param)), name)
+ : AutomationControl (s,
+ param,
+ ParameterDescriptor(param),
+ boost::shared_ptr<AutomationList>(new AutomationList(param)),
+ name)
, owner (o)
{}
diff --git a/libs/ardour/ardour/parameter_descriptor.h b/libs/ardour/ardour/parameter_descriptor.h
index a6315ae429..8916f081a3 100644
--- a/libs/ardour/ardour/parameter_descriptor.h
+++ b/libs/ardour/ardour/parameter_descriptor.h
@@ -21,6 +21,7 @@
#define __ardour_parameter_descriptor_h__
#include "ardour/variant.h"
+#include "evoral/Parameter.hpp"
namespace ARDOUR {
@@ -32,9 +33,29 @@ typedef std::map<const std::string, const float> ScalePoints;
*/
struct ParameterDescriptor
{
+ ParameterDescriptor(const Evoral::Parameter& parameter)
+ : key((uint32_t)-1)
+ , datatype(Variant::VOID)
+ , normal(parameter.normal())
+ , lower(parameter.min())
+ , upper(parameter.max())
+ , step(0)
+ , smallstep((upper - lower) / 100.0)
+ , largestep((upper - lower) / 10.0)
+ , integer_step(false)
+ , toggled(parameter.toggled())
+ , logarithmic(false)
+ , sr_dependent(false)
+ , min_unbound(0)
+ , max_unbound(0)
+ , enumeration(false)
+ , midinote(false)
+ {}
+
ParameterDescriptor()
: key((uint32_t)-1)
, datatype(Variant::VOID)
+ , normal(0)
, lower(0)
, upper(0)
, step(0)
@@ -54,6 +75,7 @@ struct ParameterDescriptor
boost::shared_ptr<ScalePoints> scale_points;
uint32_t key; ///< for properties
Variant::Type datatype; ///< for properties
+ float normal;
float lower; ///< for frequencies, this is in Hz (not a fraction of the sample rate)
float upper; ///< for frequencies, this is in Hz (not a fraction of the sample rate)
float step;
diff --git a/libs/ardour/ardour/parameter_types.h b/libs/ardour/ardour/parameter_types.h
new file mode 100644
index 0000000000..8442d1f1bf
--- /dev/null
+++ b/libs/ardour/ardour/parameter_types.h
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2014 Paul Davis
+ Author: David Robillard
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __ardour_parameter_types_h__
+#define __ardour_parameter_types_h__
+
+#include <stdint.h>
+
+#include "ardour/types.h"
+#include "evoral/midi_events.h"
+
+namespace ARDOUR {
+
+inline uint8_t
+parameter_midi_type(AutomationType type)
+{
+ switch (type) {
+ case MidiCCAutomation: return MIDI_CMD_CONTROL; break;
+ case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break;
+ case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break;
+ case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break;
+ case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX; break;
+ default: return 0;
+ }
+}
+
+inline AutomationType
+midi_parameter_type(uint8_t status)
+{
+ switch (status & 0xF0) {
+ case MIDI_CMD_CONTROL: return MidiCCAutomation; break;
+ case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break;
+ case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break;
+ case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break;
+ case MIDI_CMD_COMMON_SYSEX: return MidiSystemExclusiveAutomation; break;
+ default: return NullAutomation;
+ }
+}
+
+inline bool
+parameter_is_midi(AutomationType type)
+{
+ return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation);
+}
+
+} // namespace ARDOUR
+
+#endif /* __ardour_parameter_types_h__ */
+
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index dc7dbf68e1..be109885d7 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -231,6 +231,8 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
void set_cycles (uint32_t c) { _cycles = c; }
cycles_t cycles() const { return _cycles; }
+ typedef std::map<uint32_t, ParameterDescriptor> PropertyDescriptors;
+
/** Get a descrption of all properties supported by this plugin.
*
* Properties are distinct from parameters in that they are potentially
@@ -239,7 +241,15 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
* For LV2 plugins, properties are implemented by sending/receiving set/get
* messages to/from the plugin via event ports.
*/
- virtual void get_supported_properties(std::vector<ParameterDescriptor>& descs) {}
+ virtual const PropertyDescriptors& get_supported_properties() const {
+ static const PropertyDescriptors nothing;
+ return nothing;
+ }
+
+ virtual const ParameterDescriptor& get_property_descriptor(uint32_t id) const {
+ static const ParameterDescriptor nothing;
+ return nothing;
+ }
/** Set a property from the UI.
*
diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h
index f1c03a79d2..6571732bb9 100644
--- a/libs/ardour/ardour/plugin_insert.h
+++ b/libs/ardour/ardour/plugin_insert.h
@@ -28,6 +28,7 @@
#include "ardour/ardour.h"
#include "ardour/libardour_visibility.h"
#include "ardour/types.h"
+#include "ardour/parameter_descriptor.h"
#include "ardour/processor.h"
#include "ardour/automation_control.h"
@@ -81,10 +82,13 @@ class LIBARDOUR_API PluginInsert : public Processor
void realtime_locate ();
void monitoring_changed ();
+ /** A control that manipulates a plugin parameter (control port). */
struct PluginControl : public AutomationControl
{
- PluginControl (PluginInsert* p, const Evoral::Parameter &param,
- boost::shared_ptr<AutomationList> list = boost::shared_ptr<AutomationList>());
+ PluginControl (PluginInsert* p,
+ const Evoral::Parameter& param,
+ const ParameterDescriptor& desc,
+ boost::shared_ptr<AutomationList> list=boost::shared_ptr<AutomationList>());
void set_value (double val);
double get_value (void) const;
@@ -95,9 +99,24 @@ class LIBARDOUR_API PluginInsert : public Processor
private:
PluginInsert* _plugin;
- bool _logarithmic;
- bool _sr_dependent;
- bool _toggled;
+ };
+
+ /** A control that manipulates a plugin property (message). */
+ struct PluginPropertyControl : public AutomationControl
+ {
+ PluginPropertyControl (PluginInsert* p,
+ const Evoral::Parameter& param,
+ const ParameterDescriptor& desc,
+ boost::shared_ptr<AutomationList> list=boost::shared_ptr<AutomationList>());
+
+ void set_value (const Variant& val);
+ void set_value (double val);
+ double get_value (void) const;
+ XMLNode& get_state();
+
+ private:
+ PluginInsert* _plugin;
+ Variant _value;
};
boost::shared_ptr<Plugin> plugin(uint32_t num=0) const {
diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h
index af56e12a5b..7444a54a7c 100644
--- a/libs/ardour/ardour/types.h
+++ b/libs/ardour/ardour/types.h
@@ -127,6 +127,7 @@ namespace ARDOUR {
PanFrontBackAutomation,
PanLFEAutomation,
PluginAutomation,
+ PluginPropertyAutomation,
SoloAutomation,
MuteAutomation,
MidiCCAutomation,
diff --git a/libs/ardour/ardour/uri_map.h b/libs/ardour/ardour/uri_map.h
index a948ea4002..d745ad58e7 100644
--- a/libs/ardour/ardour/uri_map.h
+++ b/libs/ardour/ardour/uri_map.h
@@ -24,6 +24,8 @@
#include <boost/utility.hpp>
+#include <glibmm/threads.h>
+
#include "lv2.h"
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
@@ -39,6 +41,8 @@ namespace ARDOUR {
*/
class LIBARDOUR_API URIMap : public boost::noncopyable {
public:
+ static URIMap& instance();
+
URIMap();
LV2_Feature* uri_map_feature() { return &_uri_map_feature; }
@@ -51,6 +55,38 @@ public:
uint32_t uri_to_id(const char* uri);
const char* id_to_uri(uint32_t id) const;
+ // Cached URIDs for use in real-time code
+ struct URIDs {
+ void init(URIMap& uri_map);
+
+ uint32_t atom_Chunk;
+ uint32_t atom_Path;
+ uint32_t atom_Sequence;
+ uint32_t atom_eventTransfer;
+ uint32_t atom_URID;
+ uint32_t atom_Blank;
+ uint32_t atom_Object;
+ uint32_t atom_Float;
+ uint32_t log_Error;
+ uint32_t log_Note;
+ uint32_t log_Warning;
+ uint32_t midi_MidiEvent;
+ uint32_t time_Position;
+ uint32_t time_bar;
+ uint32_t time_barBeat;
+ uint32_t time_beatUnit;
+ uint32_t time_beatsPerBar;
+ uint32_t time_beatsPerMinute;
+ uint32_t time_frame;
+ uint32_t time_speed;
+ uint32_t patch_Get;
+ uint32_t patch_Set;
+ uint32_t patch_property;
+ uint32_t patch_value;
+ };
+
+ URIDs urids;
+
private:
typedef std::map<const std::string, uint32_t> Map;
typedef std::map<uint32_t, const std::string> Unmap;
@@ -64,6 +100,10 @@ private:
LV2_URID_Map _urid_map_feature_data;
LV2_Feature _urid_unmap_feature;
LV2_URID_Unmap _urid_unmap_feature_data;
+
+ mutable Glib::Threads::Mutex _lock;
+
+ static URIMap* uri_map;
};
} // namespace ARDOUR
diff --git a/libs/ardour/ardour/variant.h b/libs/ardour/ardour/variant.h
index 1e9dda179a..cc483e3cdf 100644
--- a/libs/ardour/ardour/variant.h
+++ b/libs/ardour/ardour/variant.h
@@ -21,7 +21,9 @@
#define __ardour_variant_h__
#include <stdint.h>
+#include <limits.h>
+#include <algorithm>
#include <stdexcept>
#include "ardour/libardour_visibility.h"
@@ -45,17 +47,62 @@ public:
URI ///< URI string
};
- 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(int value) : _type(INT) { _int = value; }
- explicit Variant(long value) : _type(LONG) { _long = value; }
+ explicit Variant() : _type(VOID) { _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; }
+ /** Make a variant of a specific string type (string types only) */
Variant(Type type, const std::string& value)
: _type(type)
, _string(value)
{}
+ /** Make a numeric variant from a double (numeric types only).
+ *
+ * If conversion is impossible, the variant will have type VOID.
+ */
+ Variant(Type type, double value)
+ : _type(type)
+ {
+ switch (type) {
+ case BOOL:
+ _bool = value != 0.0;
+ break;
+ case DOUBLE:
+ _double = (double)value;
+ break;
+ case FLOAT:
+ _float = (float)value;
+ break;
+ case INT:
+ _int = (int32_t)lrint(std::max((double)INT32_MIN,
+ std::min(value, (double)INT32_MAX)));
+ break;
+ case LONG:
+ _long = (int64_t)lrint(std::max((double)INT64_MIN,
+ std::min(value, (double)INT64_MAX)));
+ break;
+ default:
+ _type = VOID;
+ _long = 0;
+ }
+ }
+
+ /** Convert a numeric variant to a double. */
+ double to_double() const {
+ switch (_type) {
+ case BOOL: return _bool;
+ case DOUBLE: return _double;
+ case FLOAT: return _float;
+ case INT: return _int;
+ case LONG: return _long;
+ default: return 0.0;
+ }
+ }
+
bool get_bool() const { ensure_type(BOOL); return _bool; }
double get_double() const { ensure_type(DOUBLE); return _double; }
float get_float() const { ensure_type(FLOAT); return _float; }
@@ -68,6 +115,15 @@ public:
Type type() const { return _type; }
+ static bool type_is_numeric(Type type) {
+ switch (type) {
+ case BOOL: case DOUBLE: case FLOAT: case INT: case LONG:
+ return true;
+ default:
+ return false;
+ }
+ }
+
private:
static const char* type_name(const Type type) {
static const char* names[] = {