From dd79e76e41446833088482588456afed37231bff Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 12 Aug 2015 04:46:29 +0000 Subject: Server-side presets. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5703 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientStore.cpp | 53 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'src/client/ClientStore.cpp') diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 31ef4d47..5adf7f52 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -136,11 +136,18 @@ ClientStore::remove_object(const Raul::Path& path) SPtr ClientStore::_plugin(const Raul::URI& uri) { - Plugins::iterator i = _plugins->find(uri); - if (i == _plugins->end()) - return SPtr(); - else - return (*i).second; + const Plugins::iterator i = _plugins->find(uri); + return (i == _plugins->end()) ? SPtr() : (*i).second; +} + +SPtr +ClientStore::_plugin(const Atom& uri) +{ + /* FIXME: SHould probably be stored with URIs rather than strings, to make this + a fast case. */ + + const Plugins::iterator i = _plugins->find(Raul::URI(_uris.forge.str(uri, false))); + return (i == _plugins->end()) ? SPtr() : (*i).second; } SPtr @@ -241,17 +248,31 @@ ClientStore::put(const Raul::URI& uri, Resource::type(uris(), properties, is_graph, is_block, is_port, is_output); - // Check if uri is a plugin - Iterator t = properties.find(_uris.rdf_type); - if (t != properties.end() && t->second.type() == _uris.forge.URI) { - const Atom& type(t->second); - const Raul::URI type_uri(type.ptr()); - const Plugin::Type plugin_type(Plugin::type_from_uri(type_uri)); - if (plugin_type == Plugin::Graph) { + // Check for specially handled types + const Iterator t = properties.find(_uris.rdf_type); + if (t != properties.end()) { + const Atom& type(t->second); + if (_uris.pset_Preset == type) { + const Iterator p = properties.find(_uris.lv2_appliesTo); + const Iterator l = properties.find(_uris.rdfs_label); + SPtr plug; + if (p == properties.end()) { + _log.error(fmt("Preset <%1%> with no plugin\n") % uri.c_str()); + } else if (l == properties.end()) { + _log.error(fmt("Preset <%1%> with no label\n") % uri.c_str()); + } else if (l->second.type() != _uris.forge.String) { + _log.error(fmt("Preset <%1%> label is not a string\n") % uri.c_str()); + } else if (!(plug = _plugin(p->second))) { + _log.error(fmt("Preset <%1%> for unknown plugin %2%\n") + % uri.c_str() % _uris.forge.str(p->second)); + } else { + plug->add_preset(uri, l->second.ptr()); + } + return; + } else if (_uris.ingen_Graph == type) { is_graph = true; - } else if (plugin_type != Plugin::NIL) { - SPtr p( - new PluginModel(uris(), uri, type_uri, properties)); + } else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) { + SPtr p(new PluginModel(uris(), uri, type, properties)); add_plugin(p); return; } @@ -292,7 +313,7 @@ ClientStore::put(const Raul::URI& uri, new PluginModel( uris(), Raul::URI(p->second.ptr()), - Raul::URI("http://www.w3.org/2002/07/owl#Nothing"), + Atom(), Resource::Properties())); add_plugin(plug); } -- cgit v1.2.1