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 /ingen | |
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 'ingen')
-rw-r--r-- | ingen/Forge.hpp | 3 | ||||
-rw-r--r-- | ingen/Node.hpp | 9 | ||||
-rw-r--r-- | ingen/Plugin.hpp | 70 | ||||
-rw-r--r-- | ingen/Resource.hpp | 44 | ||||
-rw-r--r-- | ingen/URIs.hpp | 22 | ||||
-rw-r--r-- | ingen/client/BlockModel.hpp | 4 | ||||
-rw-r--r-- | ingen/client/ClientStore.hpp | 1 | ||||
-rw-r--r-- | ingen/client/PluginModel.hpp | 27 |
8 files changed, 89 insertions, 91 deletions
diff --git a/ingen/Forge.hpp b/ingen/Forge.hpp index 83a94319..683c0041 100644 --- a/ingen/Forge.hpp +++ b/ingen/Forge.hpp @@ -22,6 +22,7 @@ #include "ingen/Atom.hpp" #include "ingen/ingen.h" #include "lv2/lv2plug.in/ns/ext/atom/forge.h" +#include "raul/URI.hpp" namespace Ingen { @@ -46,6 +47,8 @@ public: Atom make_urid(int32_t v) { return Atom(sizeof(int32_t), URID, &v); } + Atom make_urid(const Raul::URI& u); + Atom alloc(uint32_t size, uint32_t type, const void* val) { return Atom(size, type, val); } diff --git a/ingen/Node.hpp b/ingen/Node.hpp index 181a9c53..4c7c453a 100644 --- a/ingen/Node.hpp +++ b/ingen/Node.hpp @@ -31,7 +31,6 @@ class Symbol; namespace Ingen { class Arc; -class Plugin; class Store; /** An object on the audio graph. @@ -63,9 +62,9 @@ public: const Arcs& arcs() const { return _arcs; } // Blocks and graphs only - virtual uint32_t num_ports() const { return 0; } - virtual Node* port(uint32_t index) const { return NULL; } - virtual const Plugin* plugin() const { return NULL; } + virtual uint32_t num_ports() const { return 0; } + virtual Node* port(uint32_t index) const { return NULL; } + virtual const Resource* plugin() const { return NULL; } // All objects virtual GraphType graph_type() const = 0; @@ -101,7 +100,7 @@ protected: friend class Store; virtual void set_path(const Raul::Path& p) = 0; - Node(URIs& uris, const Raul::Path& path) + Node(const URIs& uris, const Raul::Path& path) : Resource(uris, path_to_uri(path)) {} diff --git a/ingen/Plugin.hpp b/ingen/Plugin.hpp deleted file mode 100644 index cb873d20..00000000 --- a/ingen/Plugin.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2015 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef INGEN_PLUGIN_HPP -#define INGEN_PLUGIN_HPP - -#include "raul/URI.hpp" - -#include "ingen/Resource.hpp" -#include "ingen/ingen.h" - -#include "lv2/lv2plug.in/ns/lv2core/lv2.h" - -namespace Ingen { - -/** A plugin which instantiates to a Block. - * @ingroup Ingen - */ -class INGEN_API Plugin : public Resource -{ -public: - Plugin(URIs& uris, const Raul::URI& uri) - : Resource(uris, uri) - {} - - enum Type { NIL, LV2, Internal, Graph }; - - virtual Type type() const = 0; - - static inline const Raul::URI& type_uri(Type type) { - static const Raul::URI uris[] = { - Raul::URI("http://www.w3.org/2002/07/owl#Nothing"), - Raul::URI(LV2_CORE__Plugin), - Raul::URI(INGEN__Internal), - Raul::URI(INGEN__Graph) - }; - - return uris[type]; - } - - inline const Raul::URI& type_uri() const { return type_uri(type()); } - - static inline Type type_from_uri(const Raul::URI& uri) { - if (uri == type_uri(LV2)) - return LV2; - else if (uri == type_uri(Internal)) - return Internal; - else if (uri == type_uri(Graph)) - return Graph; - else - return NIL; - } -}; - -} // namespace Ingen - -#endif // INGEN_PLUGIN_HPP diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp index c4626a13..d798b009 100644 --- a/ingen/Resource.hpp +++ b/ingen/Resource.hpp @@ -34,11 +34,20 @@ namespace Ingen { class INGEN_API Resource : public Raul::Deletable { public: - Resource(URIs& uris, const Raul::URI& uri) + Resource(const URIs& uris, const Raul::URI& uri) : _uris(uris) , _uri(uri) {} + Resource& operator=(const Resource& rhs) { + assert(&rhs._uris == &_uris); + if (&rhs != this) { + _uri = rhs._uri; + _properties = rhs._properties; + } + return *this; + } + enum class Graph { DEFAULT, EXTERNAL, @@ -76,6 +85,11 @@ public: , _ctx(ctx) {} + Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT) + : Atom(quark.urid) + , _ctx(ctx) + {} + Graph context() const { return _ctx; } void set_context(Graph ctx) { _ctx = ctx; } @@ -104,6 +118,16 @@ public: const Atom& value, Graph ctx = Graph::DEFAULT); + /** Set (replace) a property value. + * + * This will first erase any properties with the given `uri`, so after + * this call exactly one property with predicate `uri` will be set. + */ + virtual const Atom& set_property( + const Raul::URI& uri, + const URIs::Quark& value, + Graph ctx = Graph::DEFAULT); + /** Add a property value. * * This will not remove any existing values, so if properties with @@ -122,10 +146,22 @@ public: virtual void remove_property(const Raul::URI& uri, const Atom& value); - /** Return true iff a property is set. */ + /** Remove a property. + * + * If `value` is patch:wildcard then any property with `uri` for a + * predicate will be removed. + */ + virtual void remove_property(const Raul::URI& uri, + const URIs::Quark& value); + + /** Return true iff a property is set with a specific value. */ virtual bool has_property(const Raul::URI& uri, const Atom& value) const; + /** Return true iff a property is set with a specific value. */ + virtual bool has_property(const Raul::URI& uri, + const URIs::Quark& value) const; + /** Set (replace) several properties at once. * * This will erase all properties with keys in `p`, though multiple values @@ -177,7 +213,7 @@ public: /** Get all the properties with a given context. */ Properties properties(Resource::Graph ctx) const; - URIs& uris() const { return _uris; } + const URIs& uris() const { return _uris; } const Raul::URI& uri() const { return _uri; } const Properties& properties() const { return _properties; } Properties& properties() { return _properties; } @@ -185,7 +221,7 @@ public: protected: const Atom& set_property(const Raul::URI& uri, const Atom& value) const; - URIs& _uris; + const URIs& _uris; private: Raul::URI _uri; diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp index 3696aba2..a10cd30c 100644 --- a/ingen/URIs.hpp +++ b/ingen/URIs.hpp @@ -46,10 +46,21 @@ public: struct Quark : public Raul::URI { Quark(Ingen::Forge& forge, URIMap* map, const char* str); - operator LV2_URID() const { return id; } - operator Atom() const { return atom; } - uint32_t id; - Atom atom; + + operator LV2_URID() const { return urid.get<LV2_URID>(); } + operator Atom() const { return urid; } + + inline bool operator==(const Atom& rhs) const { + if (rhs.type() == urid.type()) { + return rhs == urid; + } else if (rhs.type() == uri.type()) { + return rhs == uri; + } + return false; + } + + Atom urid; + Atom uri; }; Ingen::Forge& forge; @@ -105,6 +116,7 @@ public: const Quark lv2_InputPort; const Quark lv2_OutputPort; const Quark lv2_Plugin; + const Quark lv2_appliesTo; const Quark lv2_binary; const Quark lv2_connectionOptional; const Quark lv2_default; @@ -151,10 +163,12 @@ public: const Quark patch_subject; const Quark patch_value; const Quark patch_wildcard; + const Quark pset_Preset; const Quark pset_preset; const Quark pprops_logarithmic; const Quark rdf_type; const Quark rdfs_Class; + const Quark rdfs_label; const Quark rdfs_seeAlso; const Quark rsz_minimumSize; const Quark time_Position; diff --git a/ingen/client/BlockModel.hpp b/ingen/client/BlockModel.hpp index 93dcb1a7..e689414c 100644 --- a/ingen/client/BlockModel.hpp +++ b/ingen/client/BlockModel.hpp @@ -59,8 +59,8 @@ public: Node* port(uint32_t index) const; const Raul::URI& plugin_uri() const { return _plugin_uri; } - const Plugin* plugin() const { return _plugin.get(); } - Plugin* plugin() { return _plugin.get(); } + const Resource* plugin() const { return _plugin.get(); } + Resource* plugin() { return _plugin.get(); } SPtr<PluginModel> plugin_model() const { return _plugin; } uint32_t num_ports() const { return _ports.size(); } const Ports& ports() const { return _ports; } diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp index 9ba4aa26..e9fda479 100644 --- a/ingen/client/ClientStore.hpp +++ b/ingen/client/ClientStore.hpp @@ -113,6 +113,7 @@ public: private: SPtr<ObjectModel> _object(const Raul::Path& path); SPtr<PluginModel> _plugin(const Raul::URI& uri); + SPtr<PluginModel> _plugin(const Atom& uri); SPtr<Resource> _resource(const Raul::URI& uri); void add_object(SPtr<ObjectModel> object); diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp index bbc6308d..e468aede 100644 --- a/ingen/client/PluginModel.hpp +++ b/ingen/client/PluginModel.hpp @@ -18,11 +18,10 @@ #define INGEN_CLIENT_PLUGINMODEL_HPP #include <list> +#include <map> #include <string> #include <utility> -#include "ingen/Plugin.hpp" -#include "ingen/Resource.hpp" #include "ingen/Resource.hpp" #include "ingen/World.hpp" #include "ingen/client/signal.hpp" @@ -46,15 +45,20 @@ class PluginUI; * * @ingroup IngenClient */ -class INGEN_API PluginModel : public Ingen::Plugin +class INGEN_API PluginModel : public Ingen::Resource { public: PluginModel(URIs& uris, const Raul::URI& uri, - const Raul::URI& type_uri, + const Atom& type, const Ingen::Resource::Properties& properties); - Type type() const { return _type; } + const Atom& type() const { return _type; } + const Raul::URI type_uri() const { + return Raul::URI(_type.is_valid() + ? _uris.forge.str(_type) + : "http://www.w3.org/2002/07/owl#Nothing"); + } virtual const Atom& get_property(const Raul::URI& key) const; @@ -65,6 +69,9 @@ public: typedef std::map<float, std::string> ScalePoints; ScalePoints port_scale_points(uint32_t i) const; + typedef std::map<Raul::URI, std::string> Presets; + const Presets& presets() const { return _presets; } + static LilvWorld* lilv_world() { return _lilv_world; } const LilvPlugin* lilv_plugin() const { return _lilv_plugin; } @@ -89,11 +96,17 @@ public: // Signals INGEN_SIGNAL(changed, void); INGEN_SIGNAL(property, void, const Raul::URI&, const Atom&); + INGEN_SIGNAL(preset, void, const Raul::URI&, const std::string&); + + bool fetched() const { return _fetched; } + void set_fetched(bool f) { _fetched = f; } protected: friend class ClientStore; void set(SPtr<PluginModel> p); + void add_preset(const Raul::URI& uri, const std::string& label); + private: std::string get_documentation(const LilvNode* subject, bool html) const; @@ -101,8 +114,10 @@ private: static LilvWorld* _lilv_world; static const LilvPlugins* _lilv_plugins; - Type _type; + Atom _type; const LilvPlugin* _lilv_plugin; + Presets _presets; + bool _fetched; }; } // namespace Client |