summaryrefslogtreecommitdiffstats
path: root/src/server/PortType.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-11 04:47:21 +0000
committerDavid Robillard <d@drobilla.net>2013-01-11 04:47:21 +0000
commit10e9a3a800a35916872abf9e354be4c554338e4e (patch)
treed6be3ce7993f5d8efd525629fd321b32a6341633 /src/server/PortType.hpp
parent684eaf6b58e41f6758b160b882a6313faf0cff18 (diff)
downloadingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.gz
ingen-10e9a3a800a35916872abf9e354be4c554338e4e.tar.bz2
ingen-10e9a3a800a35916872abf9e354be4c554338e4e.zip
Use type safe enumerations.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4918 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/PortType.hpp')
-rw-r--r--src/server/PortType.hpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/server/PortType.hpp b/src/server/PortType.hpp
index 883b352f..5445d907 100644
--- a/src/server/PortType.hpp
+++ b/src/server/PortType.hpp
@@ -34,7 +34,7 @@ namespace Ingen {
*/
class PortType {
public:
- enum Symbol {
+ enum ID {
UNKNOWN = 0,
AUDIO = 1,
CONTROL = 2,
@@ -43,40 +43,40 @@ public:
};
explicit PortType(const Raul::URI& uri)
- : _symbol(UNKNOWN)
+ : _id(UNKNOWN)
{
if (uri == type_uri(AUDIO)) {
- _symbol = AUDIO;
+ _id = AUDIO;
} else if (uri == type_uri(CONTROL)) {
- _symbol = CONTROL;
+ _id = CONTROL;
} else if (uri == type_uri(CV)) {
- _symbol = CV;
+ _id = CV;
} else if (uri == type_uri(ATOM)) {
- _symbol = ATOM;
+ _id = ATOM;
}
}
- PortType(Symbol symbol)
- : _symbol(symbol)
+ PortType(ID id)
+ : _id(id)
{}
- inline const Raul::URI& uri() const { return type_uri(_symbol); }
- inline Symbol symbol() const { return _symbol; }
+ inline const Raul::URI& uri() const { return type_uri(_id); }
+ inline ID id() const { return _id; }
- inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); }
- inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); }
- inline bool operator==(const PortType& type) const { return (_symbol == type._symbol); }
- inline bool operator!=(const PortType& type) const { return (_symbol != type._symbol); }
- inline bool operator<(const PortType& type) const { return (_symbol < type._symbol); }
+ inline bool operator==(const ID& id) const { return (_id == id); }
+ inline bool operator!=(const ID& id) const { return (_id != id); }
+ inline bool operator==(const PortType& type) const { return (_id == type._id); }
+ inline bool operator!=(const PortType& type) const { return (_id != type._id); }
+ inline bool operator<(const PortType& type) const { return (_id < type._id); }
- inline bool is_audio() { return _symbol == AUDIO; }
- inline bool is_control() { return _symbol == CONTROL; }
- inline bool is_cv() { return _symbol == CV; }
- inline bool is_atom() { return _symbol == ATOM; }
+ inline bool is_audio() { return _id == AUDIO; }
+ inline bool is_control() { return _id == CONTROL; }
+ inline bool is_cv() { return _id == CV; }
+ inline bool is_atom() { return _id == ATOM; }
private:
- static inline const Raul::URI& type_uri(unsigned symbol_num) {
- assert(symbol_num <= ATOM);
+ static inline const Raul::URI& type_uri(unsigned id_num) {
+ assert(id_num <= ATOM);
static const Raul::URI uris[] = {
Raul::URI("http://drobilla.net/ns/ingen#nil"),
Raul::URI(LV2_CORE__AudioPort),
@@ -84,10 +84,10 @@ private:
Raul::URI(LV2_CORE__CVPort),
Raul::URI(LV2_ATOM__AtomPort)
};
- return uris[symbol_num];
+ return uris[id_num];
}
- Symbol _symbol;
+ ID _id;
};
} // namespace Ingen