diff options
author | David Robillard <d@drobilla.net> | 2010-02-03 04:46:56 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-02-03 04:46:56 +0000 |
commit | 87597f85c5a69a9accd3ce2ed88f2a006173e885 (patch) | |
tree | a3ffa393e9aecbc55dae64bad3bd45ee317e6d26 /src/shared/ResourceImpl.cpp | |
parent | a645d2b8be4d7d31f6eef1649156b166a01e0c31 (diff) | |
download | ingen-87597f85c5a69a9accd3ce2ed88f2a006173e885.tar.gz ingen-87597f85c5a69a9accd3ce2ed88f2a006173e885.tar.bz2 ingen-87597f85c5a69a9accd3ce2ed88f2a006173e885.zip |
Comprehensive use of cached URIs and more advanced Value (Atom) system.
Atoms (e.g. property values or port values) can now be an Atom::DICT, which
maps directly to/from an RDF resource. This is now used to store control
bindings as a port property, eliminating the special API.
Full interned URIs used everywhere, instead of CURIEs pretending to be URIs.
Avoid converting string literals to URIs all over the place.
Support for binding MIDI pitch bender and MIDI channel pressure.
Saving/restoring of MIDI bindings as a free side-effect of the above.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2409 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared/ResourceImpl.cpp')
-rw-r--r-- | src/shared/ResourceImpl.cpp | 71 |
1 files changed, 36 insertions, 35 deletions
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; } } |