From 288a04a65de1ff86ff0ca6e02e611f83e881d159 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 7 Oct 2007 22:09:40 +0000 Subject: URI-ify DataType and match LV2 port type semantics. git-svn-id: http://svn.drobilla.net/lad/ingen@839 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/DataType.hpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/libs/engine/DataType.hpp b/src/libs/engine/DataType.hpp index 1f431edd..d883e95b 100644 --- a/src/libs/engine/DataType.hpp +++ b/src/libs/engine/DataType.hpp @@ -24,27 +24,31 @@ namespace Ingen /** A data type that can be stored in a Port. * - * Eventually the goal is to be able to just have to create a new one of these - * to support a new data type. + * This type refers to the type of the entire buffer, mirroring LV2, + * e.g. :AudioPort and :ControlPort both are really 32-bit floating point, + * but they are different port types. */ class DataType { public: enum Symbol { UNKNOWN = 0, - FLOAT = 1, - MIDI = 2, - OSC = 3 + AUDIO = 1, + CONTROL = 2, + MIDI = 3, + OSC = 4 }; DataType(const std::string& uri) : _symbol(UNKNOWN) { - if (uri == type_uris[FLOAT]) { - _symbol = FLOAT; - } else if (uri == type_uris[MIDI]) { + if (uri == type_uri(AUDIO)) { + _symbol = AUDIO; + } else if (uri == type_uri(CONTROL)) { + _symbol = CONTROL; + } else if (uri == type_uri(MIDI)) { _symbol = MIDI; - } else if (uri == type_uris[OSC]) { + } else if (uri == type_uri(OSC)) { _symbol = OSC; } } @@ -53,8 +57,8 @@ public: : _symbol(symbol) {} - const char* const uri() const { return type_uris[_symbol]; } - const Symbol& symbol() const { return _symbol; } + const char* uri() const { return type_uri(_symbol); } + const Symbol& symbol() const { return _symbol; } inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } @@ -64,8 +68,15 @@ public: private: Symbol _symbol; - // Defined in Port.cpp for no good reason - static const char* const type_uris[4]; + static inline const char* type_uri(unsigned symbol_num) { + switch (symbol_num) { + case 0: return "ingen:AudioPort"; + case 1: return "ingen:ControlPort"; + case 2: return "ingen:MidiPort"; + case 3: return "ingen:OSCPort"; + default: return ""; + } + } }; -- cgit v1.2.1