diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/Builder.cpp | 4 | ||||
-rw-r--r-- | src/shared/LV2Object.cpp | 27 | ||||
-rw-r--r-- | src/shared/LV2URIMap.cpp | 87 | ||||
-rw-r--r-- | src/shared/LV2URIMap.hpp | 24 | ||||
-rw-r--r-- | src/shared/ResourceImpl.cpp | 71 |
5 files changed, 133 insertions, 80 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index fd94ddd0..542176d0 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -22,8 +22,6 @@ #include "common/interface/Port.hpp" #include "common/interface/Connection.hpp" #include "common/interface/Plugin.hpp" -#include "module/ingen_module.hpp" -#include "module/World.hpp" #include "shared/LV2URIMap.hpp" #include "Builder.hpp" @@ -43,7 +41,7 @@ Builder::Builder(CommonInterface& interface) void Builder::build(SharedPtr<const GraphObject> object) { - const LV2URIMap& uris = *ingen_get_world()->uris.get(); + const LV2URIMap& uris = Shared::LV2URIMap::instance(); SharedPtr<const Patch> patch = PtrCast<const Patch>(object); if (patch) { if (!object->path().is_root()) { diff --git a/src/shared/LV2Object.cpp b/src/shared/LV2Object.cpp index 193e2c1d..252972ff 100644 --- a/src/shared/LV2Object.cpp +++ b/src/shared/LV2Object.cpp @@ -17,7 +17,6 @@ #include "raul/log.hpp" #include "raul/Atom.hpp" -#include "module/World.hpp" #include "uri-map.lv2/uri-map.h" #include "object.lv2/object.h" #include "LV2Features.hpp" @@ -33,20 +32,20 @@ namespace LV2Object { bool -to_atom(World* world, const LV2_Object* object, Raul::Atom& atom) +to_atom(const LV2_Object* object, Raul::Atom& atom) { - SharedPtr<LV2URIMap> uris = world->uris; + const LV2URIMap& uris = Shared::LV2URIMap::instance(); - if (object->type == uris->object_class_string.id) { + if (object->type == uris.object_class_string.id) { atom = Raul::Atom((char*)(object + 1)); return true; - } else if (object->type == uris->object_class_bool.id) { + } else if (object->type == uris.object_class_bool.id) { atom = Raul::Atom((bool)(int32_t*)(object + 1)); return true; - } else if (object->type == uris->object_class_int32.id) { + } else if (object->type == uris.object_class_int32.id) { atom = Raul::Atom((int32_t*)(object + 1)); return true; - } else if (object->type == uris->object_class_float32.id) { + } else if (object->type == uris.object_class_float32.id) { atom = Raul::Atom((float*)(object + 1)); return true; } @@ -58,24 +57,24 @@ to_atom(World* world, const LV2_Object* object, Raul::Atom& atom) * object->size should be the capacity of the object (not including header) */ bool -from_atom(World* world, const Raul::Atom& atom, LV2_Object* object) +from_atom(const Raul::Atom& atom, LV2_Object* object) { - SharedPtr<LV2URIMap> uris = world->uris; + const LV2URIMap& uris = Shared::LV2URIMap::instance(); char* str; switch (atom.type()) { case Raul::Atom::FLOAT: - object->type = uris->object_class_float32.id; + object->type = uris.object_class_float32.id; object->size = sizeof(float); *(float*)(object + 1) = atom.get_float(); break; case Raul::Atom::INT: - object->type = uris->object_class_int32.id; + object->type = uris.object_class_int32.id; object->size = sizeof(int32_t); *(int32_t*)(object + 1) = atom.get_int32(); break; case Raul::Atom::STRING: - object->type = uris->object_class_string.id; + object->type = uris.object_class_string.id; object->size = std::min((uint16_t)object->size, (uint16_t)(strlen(atom.get_string()) + 1)); str = ((char*)(object + 1)); str[object->size - 1] = '\0'; @@ -83,8 +82,8 @@ from_atom(World* world, const Raul::Atom& atom, LV2_Object* object) break; case Raul::Atom::BLOB: error << "TODO: Blob support" << endl; - /*object->type = uris->object_class_string; - *(uint16_t*)(object + 1) = uris->uri_to_id(NULL, atom.get_blob_type()); + /*object->type = uris.object_class_string; + *(uint16_t*)(object + 1) = uris.uri_to_id(NULL, atom.get_blob_type()); memcpy(((char*)(object + 1) + sizeof(uint32_t)), atom.get_blob(), std::min(atom.data_size(), (size_t)object->size));*/ default: diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index 37856fe6..70ca954f 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -22,6 +22,8 @@ #include "raul/log.hpp" #include "object.lv2/object.h" #include "LV2URIMap.hpp" +#include "module/ingen_module.hpp" +#include "module/World.hpp" using namespace std; using namespace Raul; @@ -36,41 +38,67 @@ LV2URIMap::Quark::Quark(const char* c_str) { } +#define NS_CTX "http://lv2plug.in/ns/dev/contexts#" +#define NS_INGEN "http://drobilla.net/ns/ingen#" +#define NS_INGENUI "http://drobilla.net/ns/ingenuity#" +#define NS_LV2 "http://lv2plug.in/ns/lv2core#" +#define NS_MIDI "http://drobilla.net/ns/dev/midi#" +#define NS_MIDI "http://drobilla.net/ns/dev/midi#" +#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#" +#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#" LV2URIMap::LV2URIMap() - : ctx_context("ctx:context") - , ctx_AudioContext("ctx:AudioContext") - , ctx_MessageContext("ctx:MessageContext") - , doap_name("doap:name") - , ingen_LADSPAPlugin("ingen:LADSPAPlugin") - , ingen_Internal("ingen:Internal") - , ingen_Node("ingen:Node") - , ingen_Patch("ingen:Patch") - , ingen_Port("ingen:Port") - , ingen_broadcast("ingen:broadcast") - , ingen_enabled("ingen:enabled") - , ingen_polyphonic("ingen:polyphonic") - , ingen_polyphony("ingen:polyphony") - , ingen_selected("ingen:selected") - , ingen_value("ingen:value") - , ingenui_canvas_x("ingenui:canvas-x") - , ingenui_canvas_y("ingenui:canvas-y") - , lv2_Plugin("lv2:Plugin") - , lv2_index("lv2:index") - , lv2_maximum("lv2:maximum") - , lv2_minimum("lv2:minimum") - , lv2_name("lv2:name") - , lv2_symbol("lv2:symbol") - , lv2_toggled("lv2:toggled") + : ctx_AudioContext(NS_CTX "AudioContext") + , ctx_MessageContext(NS_CTX "MessageContext") + , ctx_context(NS_CTX "context") + , doap_name("http://usefulinc.com/ns/doap#name") + , ingen_Internal(NS_INGEN "Internal") + , ingen_LADSPAPlugin(NS_INGEN "LADSPAPlugin") + , ingen_Node(NS_INGEN "Node") + , ingen_Patch(NS_INGEN "Patch") + , ingen_Port(NS_INGEN "Port") + , ingen_broadcast(NS_INGEN "broadcast") + , ingen_controlBinding(NS_INGEN "controlBinding") + , ingen_document(NS_INGEN "document") + , ingen_enabled(NS_INGEN "enabled") + , ingen_nil(NS_INGEN "nil") + , ingen_node(NS_INGEN "node") + , ingen_polyphonic(NS_INGEN "polyphonic") + , ingen_polyphony(NS_INGEN "polyphony") + , ingen_selected(NS_INGEN "selected") + , ingen_value(NS_INGEN "value") + , ingenui_canvas_x(NS_INGENUI "canvas-x") + , ingenui_canvas_y(NS_INGENUI "canvas-y") + , lv2_AudioPort(NS_LV2 "AudioPort") + , lv2_ControlPort(NS_LV2 "ControlPort") + , lv2_InputPort(NS_LV2 "InputPort") + , lv2_OutputPort(NS_LV2 "OutputPort") + , lv2_Plugin(NS_LV2 "Plugin") + , lv2_default(NS_LV2 "default") + , lv2_index(NS_LV2 "index") + , lv2_integer(NS_LV2 "integer") + , lv2_maximum(NS_LV2 "maximum") + , lv2_minimum(NS_LV2 "minimum") + , lv2_name(NS_LV2 "name") + , lv2_symbol(NS_LV2 "symbol") + , lv2_toggled(NS_LV2 "toggled") + , lv2ev_EventPort("http://lv2plug.in/ns/ext/event#EventPort") + , midi_Bender(NS_MIDI "Bender") + , midi_ChannelPressure(NS_MIDI "ChannelPressure") + , midi_Controller(NS_MIDI "Controller") + , midi_controllerNumber(NS_MIDI "controllerNumber") , midi_event("http://lv2plug.in/ns/ext/midi#MidiEvent") + , obj_MessagePort("http://lv2plug.in/ns/dev/objects#MessagePort") + , obj_ValuePort("http://lv2plug.in/ns/dev/objects#ValuePort") , object_class_bool(LV2_OBJECT_URI "#Bool") , object_class_float32(LV2_OBJECT_URI "#Float32") , object_class_int32(LV2_OBJECT_URI "#Int32") , object_class_string(LV2_OBJECT_URI "#String") , object_class_vector(LV2_OBJECT_URI "#Vector") , object_transfer(LV2_OBJECT_URI "#ObjectTransfer") - , rdf_instanceOf("rdf:instanceOf") - , rdf_type("rdf:type") + , rdf_instanceOf(NS_RDF "instanceOf") + , rdf_type(NS_RDF "type") + , rdfs_seeAlso(NS_RDFS "seeAlso") , string_transfer("http://lv2plug.in/ns/dev/string-port#StringTransfer") , ui_format_events("http://lv2plug.in/ns/extensions/ui#Events") { @@ -81,6 +109,13 @@ LV2URIMap::LV2URIMap() } +const LV2URIMap& +LV2URIMap::instance() +{ + return *ingen_get_world()->uris; +} + + uint32_t LV2URIMap::uri_to_id(const char* map, const char* uri) diff --git a/src/shared/LV2URIMap.hpp b/src/shared/LV2URIMap.hpp index df9a1358..d773591f 100644 --- a/src/shared/LV2URIMap.hpp +++ b/src/shared/LV2URIMap.hpp @@ -40,6 +40,8 @@ public: uint32_t uri_to_id(const char* map, const char* uri); + static const LV2URIMap& instance(); + private: static uint32_t uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, const char* map, @@ -54,31 +56,48 @@ public: uint32_t id; }; - const Quark ctx_context; const Quark ctx_AudioContext; const Quark ctx_MessageContext; + const Quark ctx_context; const Quark doap_name; - const Quark ingen_LADSPAPlugin; const Quark ingen_Internal; + const Quark ingen_LADSPAPlugin; const Quark ingen_Node; const Quark ingen_Patch; const Quark ingen_Port; const Quark ingen_broadcast; + const Quark ingen_controlBinding; + const Quark ingen_document; const Quark ingen_enabled; + const Quark ingen_nil; + const Quark ingen_node; const Quark ingen_polyphonic; const Quark ingen_polyphony; const Quark ingen_selected; const Quark ingen_value; const Quark ingenui_canvas_x; const Quark ingenui_canvas_y; + const Quark lv2_AudioPort; + const Quark lv2_ControlPort; + const Quark lv2_InputPort; + const Quark lv2_OutputPort; const Quark lv2_Plugin; + const Quark lv2_default; const Quark lv2_index; + const Quark lv2_integer; const Quark lv2_maximum; const Quark lv2_minimum; const Quark lv2_name; const Quark lv2_symbol; const Quark lv2_toggled; + const Quark lv2ev_EventPort; + const Quark midi_Bender; + const Quark midi_ChannelPressure; + const Quark midi_Controller; + const Quark midi_controllerNumber; const Quark midi_event; + const Quark obj_MessagePort; + const Quark obj_ValuePort; const Quark object_class_bool; const Quark object_class_float32; const Quark object_class_int32; @@ -87,6 +106,7 @@ public: const Quark object_transfer; const Quark rdf_instanceOf; const Quark rdf_type; + const Quark rdfs_seeAlso; const Quark string_transfer; const Quark ui_format_events; }; diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 625e8c17..ea64a5d7 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -15,7 +15,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "raul/log.hpp" #include "raul/Atom.hpp" +#include "shared/LV2URIMap.hpp" #include "ResourceImpl.hpp" using namespace std; @@ -99,46 +101,45 @@ ResourceImpl::type( bool& port, bool& is_output, PortType& data_type) { typedef Resource::Properties::const_iterator iterator; - const std::pair<iterator,iterator> types_range = properties.equal_range("rdf:type"); + const LV2URIMap& uris = Shared::LV2URIMap::instance(); + const std::pair<iterator,iterator> types_range = properties.equal_range(uris.rdf_type); patch = node = port = is_output = false; data_type = PortType::UNKNOWN; for (iterator i = types_range.first; i != types_range.second; ++i) { const Atom& atom = i->second; - if (atom.type() == Atom::URI) { - if (!strncmp(atom.get_uri(), "ingen:", 6)) { - const char* suffix = atom.get_uri() + 6; - if (!strcmp(suffix, "Patch")) { - patch = true; - } else if (!strcmp(suffix, "Node")) { - node = true; - } - } else if (!strncmp(atom.get_uri(), "lv2:", 4)) { - const char* suffix = atom.get_uri() + 4; - port = true; - if (!strcmp(suffix, "InputPort")) { - is_output = false; - port = true; - } else if (!strcmp(suffix, "OutputPort")) { - is_output = true; - port = true; - } else if (!strcmp(suffix, "AudioPort")) { - data_type = PortType::AUDIO; - port = true; - } else if (!strcmp(suffix, "ControlPort")) { - data_type = PortType::CONTROL; - port = true; - } - } else if (!strcmp(atom.get_uri(), "lv2ev:EventPort")) { - data_type = PortType::EVENTS; - port = true; - } else if (!strcmp(atom.get_uri(), "obj:ValuePort")) { - data_type = PortType::VALUE; - port = true; - } else if (!strcmp(atom.get_uri(), "obj:MessagePort")) { - data_type = PortType::MESSAGE; - port = true; - } + if (atom.type() != Atom::URI) { + warn << "[ResourceImpl] Non-URI type " << atom << endl; + continue; + } + + if (atom == uris.ingen_Patch) { + patch = true; + } else if (atom == uris.ingen_Node) { + node = true; + } else if (atom == uris.lv2_InputPort) { + port = true; + is_output = false; + } else if (atom == uris.lv2_OutputPort) { + port = true; + is_output = true; + } else if (atom == uris.lv2_AudioPort) { + port = true; + data_type = PortType::AUDIO; + } else if (atom == uris.lv2_ControlPort) { + port = true; + data_type = PortType::CONTROL; + } else if (atom == uris.lv2ev_EventPort) { + data_type = PortType::EVENTS; + port = true; + } else if (atom == uris.obj_ValuePort) { + data_type = PortType::VALUE; + port = true; + } else if (atom == uris.obj_MessagePort) { + data_type = PortType::MESSAGE; + port = true; + } else { + warn << "[ResourceImpl] Unrecognized type " << atom << endl; } } |