diff options
author | David Robillard <d@drobilla.net> | 2015-08-12 04:46:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-08-12 04:46:29 +0000 |
commit | dd79e76e41446833088482588456afed37231bff (patch) | |
tree | c0f3c5c2fc74b286d529df69ad2206e2fddd96f9 /src/client/ClientStore.cpp | |
parent | 44af7b7b66e2083819103c760ab3bf4980469f86 (diff) | |
download | ingen-dd79e76e41446833088482588456afed37231bff.tar.gz ingen-dd79e76e41446833088482588456afed37231bff.tar.bz2 ingen-dd79e76e41446833088482588456afed37231bff.zip |
Server-side presets.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5703 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client/ClientStore.cpp')
-rw-r--r-- | src/client/ClientStore.cpp | 53 |
1 files changed, 37 insertions, 16 deletions
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<PluginModel> ClientStore::_plugin(const Raul::URI& uri) { - Plugins::iterator i = _plugins->find(uri); - if (i == _plugins->end()) - return SPtr<PluginModel>(); - else - return (*i).second; + const Plugins::iterator i = _plugins->find(uri); + return (i == _plugins->end()) ? SPtr<PluginModel>() : (*i).second; +} + +SPtr<PluginModel> +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<PluginModel>() : (*i).second; } SPtr<const PluginModel> @@ -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<char>()); - 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<PluginModel> 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<char>()); + } + return; + } else if (_uris.ingen_Graph == type) { is_graph = true; - } else if (plugin_type != Plugin::NIL) { - SPtr<PluginModel> p( - new PluginModel(uris(), uri, type_uri, properties)); + } else if (_uris.ingen_Internal == type || _uris.lv2_Plugin == type) { + SPtr<PluginModel> 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<char>()), - Raul::URI("http://www.w3.org/2002/07/owl#Nothing"), + Atom(), Resource::Properties())); add_plugin(plug); } |