From 19a9eb15d1c918b10fe169db1b8f4fd0c6ffe8fa Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 7 Oct 2007 23:34:14 +0000 Subject: Move DataType into Shared namespace. git-svn-id: http://svn.drobilla.net/lad/ingen@841 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/DataType.hpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/common/interface') diff --git a/src/common/interface/DataType.hpp b/src/common/interface/DataType.hpp index a2e3ce5a..1eef3171 100644 --- a/src/common/interface/DataType.hpp +++ b/src/common/interface/DataType.hpp @@ -18,8 +18,8 @@ #ifndef DATATYPE_H #define DATATYPE_H -namespace Ingen -{ +namespace Ingen { +namespace Shared { /** A data type that can be stored in a Port. @@ -30,7 +30,7 @@ namespace Ingen */ class DataType { public: - + enum Symbol { UNKNOWN = 0, AUDIO = 1, @@ -38,9 +38,9 @@ public: MIDI = 3, OSC = 4 }; - + DataType(const std::string& uri) - : _symbol(UNKNOWN) + : _symbol(UNKNOWN) { if (uri == type_uri(AUDIO)) { _symbol = AUDIO; @@ -54,20 +54,23 @@ public: } DataType(Symbol symbol) - : _symbol(symbol) + : _symbol(symbol) {} - const char* uri() const { return type_uri(_symbol); } - const Symbol& symbol() const { return _symbol; } + inline const char* uri() const { return type_uri(_symbol); } inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); } inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); } inline bool operator==(const DataType& type) const { return (_symbol == type._symbol); } inline bool operator!=(const DataType& type) const { return (_symbol != type._symbol); } -private: - Symbol _symbol; + inline bool is_audio() { return _symbol == AUDIO; } + inline bool is_control() { return _symbol == CONTROL; } + inline bool is_midi() { return _symbol == MIDI; } + inline bool is_osc() { return _symbol == OSC; } +private: + static inline const char* type_uri(unsigned symbol_num) { switch (symbol_num) { case 1: return "ingen:AudioPort"; @@ -77,10 +80,14 @@ private: default: return ""; } } -}; + Symbol _symbol; +}; +} // namespace Shared } // namespace Ingen +using Ingen::Shared::DataType; + #endif // DATATYPE_H -- cgit v1.2.1