summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/interface/ClientInterface.hpp4
-rw-r--r--src/common/interface/EventType.hpp21
-rw-r--r--src/common/interface/MessageType.hpp120
-rw-r--r--src/common/interface/Plugin.hpp34
-rw-r--r--src/common/interface/PortType.hpp39
5 files changed, 52 insertions, 166 deletions
diff --git a/src/common/interface/ClientInterface.hpp b/src/common/interface/ClientInterface.hpp
index 676c7eb6..e12788f9 100644
--- a/src/common/interface/ClientInterface.hpp
+++ b/src/common/interface/ClientInterface.hpp
@@ -28,8 +28,6 @@ namespace Raul { class Path; class URI; }
namespace Ingen {
namespace Shared {
-class MessageType;
-
/** The (only) interface the engine uses to communicate with clients.
* Purely virtual (except for the destructor).
*
@@ -56,8 +54,6 @@ public:
virtual void error(const std::string& msg) = 0;
virtual void activity(const Raul::Path& path) = 0;
-
- virtual void binding(const Raul::Path& path, const MessageType& type) = 0;
};
diff --git a/src/common/interface/EventType.hpp b/src/common/interface/EventType.hpp
index 3f3def1d..1e9a1b16 100644
--- a/src/common/interface/EventType.hpp
+++ b/src/common/interface/EventType.hpp
@@ -18,6 +18,8 @@
#ifndef INGEN_INTERFACE_EVENTTYPE_HPP
#define INGEN_INTERFACE_EVENTTYPE_HPP
+#include "raul/URI.hpp"
+
namespace Ingen {
namespace Shared {
@@ -33,7 +35,7 @@ public:
OSC = 2
};
- EventType(const std::string& uri)
+ EventType(const Raul::URI& uri)
: _symbol(UNKNOWN)
{
if (uri == type_uri(MIDI)) {
@@ -47,7 +49,7 @@ public:
: _symbol(symbol)
{}
- inline const char* uri() const { return type_uri(_symbol); }
+ inline const Raul::URI& 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); }
@@ -58,13 +60,14 @@ public:
inline bool is_osc() { return _symbol == OSC; }
private:
-
- static inline const char* type_uri(unsigned symbol_num) {
- switch (symbol_num) {
- case 1: return "ingen:MidiEvent";
- case 2: return "ingen:OSCEvent";
- default: return "";
- }
+ static inline const Raul::URI& type_uri(unsigned symbol_num) {
+ assert(symbol_num <= OSC);
+ static const Raul::URI uris[] = {
+ "http://drobilla.net/ns/ingen#nil",
+ "http://drobilla.net/ns/ingen#MidiEvent",
+ "http://drobilla.net/ns/ingen#OSCEvent"
+ };
+ return uris[symbol_num];
}
Symbol _symbol;
diff --git a/src/common/interface/MessageType.hpp b/src/common/interface/MessageType.hpp
deleted file mode 100644
index 3f18aaac..00000000
--- a/src/common/interface/MessageType.hpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net>
- *
- * Ingen 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.
- *
- * Ingen 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 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.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INGEN_INTERFACE_MESSAGETYPE_HPP
-#define INGEN_INTERFACE_MESSAGETYPE_HPP
-
-#include <cassert>
-#include <iostream>
-#include <string>
-
-namespace Ingen {
-namespace Shared {
-
-
-/** A type of control message that could be bound to a control port.
- *
- * \ingroup interface
- */
-class MessageType
-{
-public:
- enum Type {
- MIDI_PITCH,
- MIDI_CC,
- MIDI_RPN,
- MIDI_NRPN
- };
-
- MessageType(Type type, int16_t num)
- : _type(type)
- {
- switch (type) {
- case MIDI_PITCH:
- break;
- case MIDI_CC:
- assert(num >= 0 && num < 128);
- _id.midi_cc = num;
- break;
- case MIDI_RPN:
- assert(num >= 0 && num < 16384);
- _id.midi_pn = num;
- break;
- case MIDI_NRPN:
- assert(num >= 0 && num < 16384);
- _id.midi_pn = num;
- break;
- }
- }
-
- inline Type type() const { return _type; }
- inline int8_t midi_cc_num() const { assert(_type == MIDI_CC); return _id.midi_cc; }
- inline int8_t midi_rpn_num() const { assert(_type == MIDI_RPN); return _id.midi_pn; }
- inline int8_t midi_nrpn_num() const { assert(_type == MIDI_NRPN); return _id.midi_pn; }
-
- inline int num() const {
- switch (_type) {
- case MIDI_CC:
- return _id.midi_cc;
- case MIDI_RPN:
- case MIDI_NRPN:
- return _id.midi_pn;
- default:
- return -1;
- }
- }
-
- inline const char* type_uri() const {
- switch (_type) {
- case MIDI_PITCH:
- return "midi:PitchBend";
- case MIDI_CC:
- return "midi:Control";
- case MIDI_RPN:
- return "midi:RPN";
- case MIDI_NRPN:
- return "midi:NRPN";
- }
- }
-
-private:
- union {
- int8_t midi_cc; ///< Controller number [0..2^7)
- int16_t midi_pn; ///< RPN or NRPN number [0..2^14)
- } _id;
-
- Type _type;
-};
-
-
-} // namespace Shared
-} // namespace Ingen
-
-
-static inline std::ostream& operator<<(std::ostream& os, const Ingen::Shared::MessageType& type)
-{
- using namespace Ingen::Shared;
- switch (type.type()) {
- case MessageType::MIDI_PITCH: return os << "MIDI Pitch Bender";
- case MessageType::MIDI_CC: return os << "MIDI CC " << type.num();
- case MessageType::MIDI_RPN: return os << "MIDI RPN " << type.num();
- case MessageType::MIDI_NRPN: return os << "MIDI NRPN " << type.num();
- }
- return os;
-}
-
-#endif // INGEN_INTERFACE_MESSAGETYPE_HPP
diff --git a/src/common/interface/Plugin.hpp b/src/common/interface/Plugin.hpp
index d3d74970..22464e91 100644
--- a/src/common/interface/Plugin.hpp
+++ b/src/common/interface/Plugin.hpp
@@ -19,6 +19,7 @@
#define INGEN_INTERFACE_PLUGIN_HPP
#include <string>
+#include "raul/URI.hpp"
#include "interface/Resource.hpp"
namespace Ingen {
@@ -32,26 +33,31 @@ public:
virtual Type type() const = 0;
- inline const char* type_uri() const {
- switch (type()) {
- case LV2: return "lv2:Plugin";
- case LADSPA: return "ingen:LADSPAPlugin";
- case Internal: return "ingen:Internal";
- case Patch: return "ingen:Patch";
- default: return "";
- }
+ static inline const Raul::URI& type_uri(Type type) {
+ static const Raul::URI uris[] = {
+ "http://drobilla.net/ns/ingen#nil",
+ "http://lv2plug.in/ns/lv2core#Plugin",
+ "http://drobilla.net/ns/ingen#LADSPAPlugin",
+ "http://drobilla.net/ns/ingen#Internal",
+ "http://drobilla.net/ns/ingen#Patch"
+ };
+
+ return uris[type];
}
- static inline Type type_from_uri(const std::string& uri) {
- if (uri == "lv2:Plugin")
+ inline const Raul::URI& type_uri() const { return type_uri(type()); }
+
+ static inline Type type_from_uri(const Raul::URI& uri) {
+ if (uri == type_uri(LV2))
return LV2;
- else if (uri == "ingen:LADSPAPlugin")
+ else if (uri == type_uri(LADSPA))
return LADSPA;
- else if (uri == "ingen:Internal")
+ else if (uri == type_uri(Internal))
return Internal;
- else if (uri == "ingen:Patch")
+ else if (uri == type_uri(Patch))
return Patch;
- return NIL;
+ else
+ return NIL;
}
};
diff --git a/src/common/interface/PortType.hpp b/src/common/interface/PortType.hpp
index ca739cb8..e1d51e21 100644
--- a/src/common/interface/PortType.hpp
+++ b/src/common/interface/PortType.hpp
@@ -37,22 +37,22 @@ public:
AUDIO = 1,
CONTROL = 2,
EVENTS = 3,
- VALUE = 7,
- MESSAGE = 8,
+ VALUE = 4,
+ MESSAGE = 5,
};
PortType(const Raul::URI& uri)
: _symbol(UNKNOWN)
{
- if (uri.str() == type_uri(AUDIO)) {
+ if (uri == type_uri(AUDIO)) {
_symbol = AUDIO;
- } else if (uri.str() == type_uri(CONTROL)) {
+ } else if (uri == type_uri(CONTROL)) {
_symbol = CONTROL;
- } else if (uri.str() == type_uri(EVENTS)) {
+ } else if (uri == type_uri(EVENTS)) {
_symbol = EVENTS;
- } else if (uri.str() == type_uri(VALUE)) {
+ } else if (uri == type_uri(VALUE)) {
_symbol = VALUE;
- } else if (uri.str() == type_uri(MESSAGE)) {
+ } else if (uri == type_uri(MESSAGE)) {
_symbol = MESSAGE;
}
}
@@ -61,8 +61,8 @@ public:
: _symbol(symbol)
{}
- inline const char* uri() const { return type_uri(_symbol); }
- inline Symbol symbol() const { return _symbol; }
+ inline const Raul::URI& uri() const { return type_uri(_symbol); }
+ inline 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); }
@@ -76,16 +76,17 @@ public:
inline bool is_message() { return _symbol == MESSAGE; }
private:
-
- static inline const char* type_uri(unsigned symbol_num) {
- switch (symbol_num) {
- case 1: return "lv2:AudioPort";
- case 2: return "lv2:ControlPort";
- case 3: return "lv2ev:EventPort";
- case 7: return "obj:ValuePort";
- case 8: return "obj:MessagePort";
- default: return "";
- }
+ static inline const Raul::URI& type_uri(unsigned symbol_num) {
+ assert(symbol_num <= MESSAGE);
+ static const Raul::URI uris[] = {
+ "http://drobilla.net/ns/ingen#nil",
+ "http://lv2plug.in/ns/lv2core#AudioPort",
+ "http://lv2plug.in/ns/lv2core#ControlPort",
+ "http://lv2plug.in/ns/ext/event#EventPort",
+ "http://lv2plug.in/ns/dev/objects#ValuePort",
+ "http://lv2plug.in/ns/dev/objects#MessagePort"
+ };
+ return uris[symbol_num];
}
Symbol _symbol;