diff options
author | David Robillard <d@drobilla.net> | 2007-10-07 22:09:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-07 22:09:40 +0000 |
commit | 288a04a65de1ff86ff0ca6e02e611f83e881d159 (patch) | |
tree | 9d60aa63f3c959a17dfced5b80e71fd507646f10 /src | |
parent | b1406a0e09b0cb27032ade94c58d9a471086b89a (diff) | |
download | ingen-288a04a65de1ff86ff0ca6e02e611f83e881d159.tar.gz ingen-288a04a65de1ff86ff0ca6e02e611f83e881d159.tar.bz2 ingen-288a04a65de1ff86ff0ca6e02e611f83e881d159.zip |
URI-ify DataType and match LV2 port type semantics.
git-svn-id: http://svn.drobilla.net/lad/ingen@839 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/engine/DataType.hpp | 37 |
1 files 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 ""; + } + } }; |