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/client/DeprecatedLoader.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/client/DeprecatedLoader.cpp')
-rw-r--r-- | src/client/DeprecatedLoader.cpp | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp index ec603760..8d774e17 100644 --- a/src/client/DeprecatedLoader.cpp +++ b/src/client/DeprecatedLoader.cpp @@ -29,6 +29,7 @@ #include <libxml/xpath.h> #include "raul/log.hpp" #include "raul/Path.hpp" +#include "shared/LV2URIMap.hpp" #include "interface/EngineInterface.hpp" #include "DeprecatedLoader.hpp" @@ -224,13 +225,15 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, size_t poly = 0; + const LV2URIMap& uris = Shared::LV2URIMap::instance(); + /* Use parameter overridden polyphony, if given */ - GraphObject::Properties::iterator poly_param = initial_data.find("ingen:polyphony"); + GraphObject::Properties::iterator poly_param = initial_data.find(uris.ingen_polyphony); if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT) poly = poly_param->second.get_int32(); - if (initial_data.find("filename") == initial_data.end()) - initial_data.insert(make_pair("filename", Atom(filename.c_str()))); // FIXME: URL? + if (initial_data.find(uris.ingen_document) == initial_data.end()) + initial_data.insert(make_pair(uris.ingen_document, filename)); xmlDocPtr doc = xmlParseFile(filename.c_str()); @@ -294,8 +297,8 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, // Create it, if we're not merging if (!existing && !path.is_root()) { Resource::Properties props; - props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Patch"))); - props.insert(make_pair("ingen:polyphony", Atom((int32_t)poly))); + props.insert(make_pair(uris.rdf_type, uris.ingen_Patch)); + props.insert(make_pair(uris.ingen_polyphony, Atom((int32_t)poly))); _engine->put(path, props); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_property(path, i->first, i->second); @@ -340,7 +343,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, for ( ; i != pm->controls().end(); ++i) { const float value = i->value(); _engine->set_property(translate_load_path(i->port_path().str()), - "ingen:value", Atom(value)); + uris.ingen_value, Atom(value)); } } else { LOG(warn) << "Unknown preset `" << pm->name() << "'" << endl; @@ -357,7 +360,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, // _engine->set_property(subject, i->first, i->second); if (!existing) - _engine->set_property(path, "ingen:enabled", (bool)true); + _engine->set_property(path, uris.ingen_enabled, (bool)true); _load_path_translations.clear(); @@ -451,38 +454,40 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr return false; } + const LV2URIMap& uris = Shared::LV2URIMap::instance(); + // Compatibility hacks for old patches that represent patch ports as nodes if (plugin_uri == "") { bool is_port = false; Resource::Properties props; - props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Patch"))); + props.insert(make_pair(uris.rdf_type, uris.ingen_Patch)); if (plugin_type == "Internal") { is_port = true; if (plugin_label == "audio_input") { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:AudioPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:InputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2_AudioPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); _engine->put(path, props); } else if (plugin_label == "audio_output") { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:AudioPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:OutputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2_AudioPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); _engine->put(path, props); } else if (plugin_label == "control_input") { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:ControlPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:InputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2_ControlPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); _engine->put(path, props); } else if (plugin_label == "control_output" ) { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:ControlPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:OutputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2_ControlPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); _engine->put(path, props); } else if (plugin_label == "midi_input") { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2ev:EventPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:InputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2ev_EventPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_InputPort)); _engine->put(path, props); } else if (plugin_label == "midi_output" ) { - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2ev:EventPort"))); - props.insert(make_pair("rdf:type", Atom(Atom::URI, "lv2:OutputPort"))); + props.insert(make_pair(uris.rdf_type, uris.lv2ev_EventPort)); + props.insert(make_pair(uris.rdf_type, uris.lv2_OutputPort)); _engine->put(path, props); } else { is_port = false; @@ -528,11 +533,11 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr plugin_uri = "om:" + plugin_type + ":" + library_name + ":" + plugin_label; Resource::Properties props; - props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Node"))); - props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, plugin_uri))); + props.insert(make_pair(uris.rdf_type, uris.ingen_Node)); + props.insert(make_pair(uris.rdf_instanceOf, Atom(Atom::URI, plugin_uri))); _engine->put(path, props); - _engine->set_property(path, "ingen:polyphonic", bool(polyphonic)); + _engine->set_property(path, uris.ingen_polyphonic, bool(polyphonic)); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_property(path, i->first, i->second); @@ -543,10 +548,10 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr // Not deprecated } else { Resource::Properties props; - props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Node"))); - props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, plugin_uri))); + props.insert(make_pair(uris.rdf_type, uris.ingen_Node)); + props.insert(make_pair(uris.rdf_instanceOf, Atom(Atom::URI, plugin_uri))); _engine->put(path, props); - _engine->set_property(path, "ingen:polyphonic", bool(polyphonic)); + _engine->set_property(path, uris.ingen_polyphonic, bool(polyphonic)); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_property(path, i->first, i->second); return true; @@ -567,6 +572,7 @@ DeprecatedLoader::load_subpatch(const string& base_filename, const Path& parent, size_t poly = 0; GraphObject::Properties initial_data; + const LV2URIMap& uris = Shared::LV2URIMap::instance(); while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); @@ -574,7 +580,7 @@ DeprecatedLoader::load_subpatch(const string& base_filename, const Path& parent, if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) { name = (const char*)key; } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) { - initial_data.insert(make_pair("ingen::polyphony", (int)poly)); + initial_data.insert(make_pair(uris.ingen_polyphony, (int)poly)); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"filename"))) { filename = base_filename + "/" + (const char*)key; } else { // Don't know what this tag is, add it as variable |