diff options
author | David Robillard <d@drobilla.net> | 2008-11-09 03:45:35 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-11-09 03:45:35 +0000 |
commit | 72ffe8b96f492805b16df8d2ffa452e67046b974 (patch) | |
tree | 4c3e565f34e334c8cc3a58ab052ea2156eb4cfdc /src/client | |
parent | 5d1f579900182f283a1c21ad4e59daf7f035e219 (diff) | |
download | ingen-72ffe8b96f492805b16df8d2ffa452e67046b974.tar.gz ingen-72ffe8b96f492805b16df8d2ffa452e67046b974.tar.bz2 ingen-72ffe8b96f492805b16df8d2ffa452e67046b974.zip |
Add concept of 'Resource' and make plugins a resource (as well as graph objects).
Get rid of crufty imperative Plugin API.
Loading of plugin data from engine over HTTP.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1713 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientStore.cpp | 31 | ||||
-rw-r--r-- | src/client/DeprecatedLoader.cpp | 2 | ||||
-rw-r--r-- | src/client/HTTPClientReceiver.cpp | 8 | ||||
-rw-r--r-- | src/client/ObjectModel.cpp | 47 | ||||
-rw-r--r-- | src/client/ObjectModel.hpp | 10 | ||||
-rw-r--r-- | src/client/PatchModel.cpp | 9 | ||||
-rw-r--r-- | src/client/PatchModel.hpp | 2 | ||||
-rw-r--r-- | src/client/PluginModel.cpp | 21 | ||||
-rw-r--r-- | src/client/PluginModel.hpp | 24 |
9 files changed, 76 insertions, 78 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 8c54e96e..31ecbd3e 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -182,7 +182,7 @@ ClientStore::add_variable_orphan(const Path& subject_path, const string& predica Raul::PathTable<list<std::pair<string, Atom> > >::iterator orphans = _variable_orphans.find(subject_path); - _engine->request_object(subject_path); + //_engine->request_object(subject_path); if (orphans != _variable_orphans.end()) { orphans->second.push_back(std::pair<string, Atom>(predicate, value)); @@ -420,7 +420,9 @@ ClientStore::rename(const Path& old_path, const Path& new_path) void ClientStore::new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name) { - SharedPtr<PluginModel> p(new PluginModel(uri, type_uri, symbol, name)); + SharedPtr<PluginModel> p(new PluginModel(uri, type_uri)); + p->set_property("lv2:symbol", Atom(Atom::STRING, symbol)); + p->set_property("doap:name", Atom(Atom::STRING, name)); add_plugin(p); resolve_plugin_orphans(p); } @@ -508,15 +510,26 @@ ClientStore::set_variable(const string& subject_path, const string& predicate, c void ClientStore::set_property(const string& subject_path, const string& predicate, const Atom& value) { - SharedPtr<ObjectModel> subject = object(subject_path); + if (!value.is_valid()) + cerr << "WARNING: property '" << predicate << "' is NULL" << endl; - if (!value.is_valid()) { - cerr << "ERROR: property '" << predicate << "' has no type" << endl; - } else if (subject) { - subject->set_property(predicate, value); + if (Path::is_valid(subject_path)) { + SharedPtr<ObjectModel> obj = object(subject_path); + if (obj) + obj->set_property(predicate, value); + else + cerr << "WARNING: property for unknown object " << subject_path + << ". Refresh!" << endl; } else { - cerr << "WARNING: property for unknown object " << subject_path - << " lost. Client must refresh!" << endl; + if (subject_path.find(":") != string::npos + && predicate == "rdf:type" && value.type() == Atom::URI) { + const std::string& type = value.get_uri(); + if ( (type == "http://drobilla.net/ns/ingen#LADSPAPlugin") + || (type == "http://drobilla.net/ns/ingen#Internal") + || (type == "http://lv2plug.in/ns/lv2core#Plugin")) { + add_plugin(SharedPtr<PluginModel>(new PluginModel(subject_path, type))); + } + } } } diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp index 84f47aeb..256b2947 100644 --- a/src/client/DeprecatedLoader.cpp +++ b/src/client/DeprecatedLoader.cpp @@ -177,7 +177,7 @@ DeprecatedLoader::add_variable(GraphObject::Variables& data, string old_key, str if (endptr != c_val && *endptr == '\0') data[key] = Atom(fval); else - data[key] = Atom(value); + data[key] = Atom(Atom::STRING, value); free(c_val); } diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index 5d4a8660..624a7786 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -53,16 +53,13 @@ void HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, void* ptr) { HTTPClientReceiver* me = (HTTPClientReceiver*)ptr; - //cout << "RECEIVED ASYNC MESSAGE: " << msg->response_body->data << endl; const string path = soup_message_get_uri(msg)->path; if (path == "/") { - cout << "RECEIVED ROOT" << endl; me->_target->response_ok(0); me->_target->enable(); } else if (path == "/plugins") { - cout << "RECIEVED PLUGINS" << endl; if (msg->response_body->data == NULL) { - cout << "NO RESPONSE?!" << endl; + cout << "ERROR: Empty response" << endl; } else { me->_target->response_ok(0); me->_target->enable(); @@ -71,9 +68,8 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi Glib::ustring("."), Glib::ustring("")); } } else if (path == "/patch") { - cout << "RECEIVED OBJECTS" << endl; if (msg->response_body->data == NULL) { - cout << "NO RESPONSE?!" << endl; + cout << "ERROR: Empty response" << endl; } else { me->_target->response_ok(0); me->_target->enable(); diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index b1a0169f..80460547 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -27,7 +27,8 @@ namespace Client { ObjectModel::ObjectModel(const Path& path) - : _path(path) + : ResourceImpl(string("patch/") + path) + , _path(path) { } @@ -71,45 +72,11 @@ ObjectModel::get_variable( string& key) } -/** Get a property of this object. - * - * @return Metadata value with key @a key, empty string otherwise. - */ -const Atom& -ObjectModel::get_property(const string& key) const -{ - static const Atom null_atom; - - Properties::const_iterator i = _properties.find(key); - if (i != _properties.end()) - return i->second; - else - return null_atom; -} - - -/** Get a property of this object. - * - * @return Metadata value with key @a key, empty string otherwise. - */ -Atom& -ObjectModel::get_property(const string& key) -{ - static Atom null_atom; - - Properties::iterator i = _properties.find(key); - if (i != _properties.end()) - return i->second; - else - return null_atom; -} - - bool ObjectModel::polyphonic() const { - Properties::const_iterator i = _properties.find("ingen:polyphonic"); - return (i != _properties.end() && i->second.type() == Atom::BOOL && i->second.get_bool()); + const Raul::Atom& polyphonic = get_property("ingen:polyphonic"); + return (polyphonic.is_valid() && polyphonic.get_bool()); } @@ -134,10 +101,10 @@ ObjectModel::set(SharedPtr<ObjectModel> o) } for (Properties::const_iterator v = o->properties().begin(); v != o->properties().end(); ++v) { - Properties::const_iterator mine = _properties.find(v->first); - if (mine != _properties.end()) + const Raul::Atom& mine = get_property(v->first); + if (mine.is_valid()) cerr << "WARNING: " << _path << "Client/Server property mismatch: " << v->first << endl; - _properties[v->first] = v->second; + ResourceImpl::set_property(v->first, v->second); signal_variable.emit(v->first, v->second); } } diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index ac54ff98..843b14de 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -30,6 +30,7 @@ #include "raul/SharedPtr.hpp" #include "raul/PathTable.hpp" #include "interface/GraphObject.hpp" +#include "shared/ResourceImpl.hpp" using Raul::PathTable; using std::string; @@ -55,25 +56,19 @@ class ClientStore; * \ingroup IngenClient */ class ObjectModel : virtual public Ingen::Shared::GraphObject + , public Ingen::Shared::ResourceImpl { public: virtual ~ObjectModel(); const Atom& get_variable(const string& key) const; Atom& get_variable( string& key); - const Atom& get_property(const string& key) const; - Atom& get_property(const string& key); virtual void set_variable(const string& key, const Atom& value) { _variables[key] = value; signal_variable.emit(key, value); } - - virtual void set_property(const string& key, const Atom& value) - { _properties[key] = value; signal_property.emit(key, value); } const Variables& variables() const { return _variables; } - const Properties& properties() const { return _properties; } Variables& variables() { return _variables; } - Properties& properties() { return _properties; } const Path path() const { return _path; } const Symbol symbol() const { return _path.name(); } SharedPtr<ObjectModel> parent() const { return _parent; } @@ -105,7 +100,6 @@ protected: SharedPtr<ObjectModel> _parent; Variables _variables; - Properties _properties; }; diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index d9f62b45..b79c8edd 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -163,15 +163,14 @@ PatchModel::remove_connection(const string& src_port_path, const string& dst_por bool PatchModel::enabled() const { - Properties::const_iterator i = _properties.find("ingen:enabled"); - return (i != _properties.end() && i->second.type() == Atom::BOOL && i->second.get_bool()); + const Raul::Atom& enabled = get_property("ingen:enabled"); + return (enabled.is_valid() && enabled.get_bool()); } - void -PatchModel::set_property(const string& key, const Atom& value) +PatchModel::set(const string& key, const Atom& value) { - ObjectModel::set_property(key, value); + ResourceImpl::set_property(key, value); if (key == "ingen:polyphony") _poly = value.get_int32(); } diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 64ceaddf..4e5890ef 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -64,7 +64,7 @@ public: signal_editable.emit(e); } } - virtual void set_property(const string& key, const Atom& value); + virtual void set(const string& key, const Atom& value); // Signals sigc::signal<void, SharedPtr<NodeModel> > signal_new_node; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 2b824034..16e09414 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -35,6 +35,21 @@ SLV2Plugins PluginModel::_slv2_plugins = NULL; Redland::World* PluginModel::_rdf_world = NULL; +PluginModel::PluginModel(const string& uri, const string& type_uri) + : ResourceImpl(uri) + , _type(type_from_uri(_rdf_world->prefixes().qualify(type_uri))) +{ + Glib::Mutex::Lock lock(_rdf_world->mutex()); + assert(_rdf_world); + set_property("rdf:type", Raul::Atom(Raul::Atom::URI, this->type_uri())); +#ifdef HAVE_SLV2 + SLV2Value plugin_uri = slv2_value_new_uri(_slv2_world, uri.c_str()); + _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri); + slv2_value_free(plugin_uri); +#endif +} + + string PluginModel::default_node_symbol() { @@ -45,14 +60,20 @@ PluginModel::default_node_symbol() string PluginModel::human_name() { + const Atom& name_atom = get_property("doap:name"); + if (name_atom.type() == Atom::STRING) + return name_atom.get_string(); + #ifdef HAVE_SLV2 if (_slv2_plugin) { SLV2Value name = slv2_plugin_get_name(_slv2_plugin); string ret = slv2_value_as_string(name); slv2_value_free(name); + set_property("doap:name", Raul::Atom(Raul::Atom::STRING, ret.c_str())); return ret; } #endif + return default_node_symbol(); } diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index 3d25cb5e..62ee13a8 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -30,6 +30,7 @@ #include "interface/EngineInterface.hpp" #include "interface/Plugin.hpp" #include "module/World.hpp" +#include "shared/ResourceImpl.hpp" using std::string; @@ -46,11 +47,12 @@ class PluginUI; * \ingroup IngenClient */ class PluginModel : public Ingen::Shared::Plugin + , public Ingen::Shared::ResourceImpl { public: - PluginModel(const string& uri, const string& type_uri, const string& symbol, const string& name) - : _type(type_from_uri(type_uri)) - , _uri(uri) + /*PluginModel(const string& uri, const string& type_uri, const string& symbol, const string& name) + : ResourceImpl(uri) + , _type(type_from_uri(type_uri)) , _symbol(symbol) , _name(name) { @@ -60,12 +62,19 @@ public: _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, plugin_uri); slv2_value_free(plugin_uri); #endif - } + }*/ + PluginModel(const string& uri, const string& type_uri); - Type type() const { return _type; } - const string& uri() const { return _uri; } - const string& name() const { return _name; } + Type type() const { return _type; } + const string name() const { + const Raul::Atom& name_atom = get_property("doap:name"); + if (name_atom.type() == Raul::Atom::STRING) + return name_atom.get_string(); + else + return ""; + } + string default_node_symbol(); string human_name(); string port_human_name(uint32_t index); @@ -102,7 +111,6 @@ public: private: const Type _type; - const string _uri; const string _symbol; const string _name; |