diff options
author | David Robillard <d@drobilla.net> | 2009-05-13 06:14:40 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-13 06:14:40 +0000 |
commit | a95e08e48c2d1f68693609627c6d6f52c6982264 (patch) | |
tree | 0feed2d49d10d6e8880bef4a7e88c52584c094cf /src | |
parent | f62ef545425476959b1335f3a303d6d5f80ca0e5 (diff) | |
download | ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.tar.gz ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.tar.bz2 ingen-a95e08e48c2d1f68693609627c6d6f52c6982264.zip |
Generic simple query system for both objects and plugins.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1997 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
25 files changed, 160 insertions, 106 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index f120e7ed..21ace7de 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -185,6 +185,15 @@ ClientStore::object(const Path& path) } } +SharedPtr<Resource> +ClientStore::resource(const URI& uri) +{ + if (uri.scheme() == Path::scheme && Path::is_valid(uri.str())) + return object(uri.str()); + else + return plugin(uri); +} + void ClientStore::add_plugin(SharedPtr<PluginModel> pm) { @@ -353,14 +362,18 @@ ClientStore::clear_patch(const Path& path) void -ClientStore::set_variable(const Path& subject_path, const URI& predicate, const Atom& value) +ClientStore::set_variable(const URI& subject_path, const URI& predicate, const Atom& value) { - SharedPtr<ObjectModel> subject = object(subject_path); + SharedPtr<Resource> subject = resource(subject_path); if (!value.is_valid()) { - cerr << "ERROR: variable '" << predicate << "' has no type" << endl; + cerr << "ERROR: variable '" << predicate << "' is invalid" << endl; } else if (subject) { - subject->set_variable(predicate, value); + SharedPtr<ObjectModel> om = PtrCast<ObjectModel>(subject); + if (om) + om->set_variable(predicate, value); + else + subject->set_property(predicate, value); } else { //add_variable_orphan(subject_path, predicate, value); cerr << "WARNING: variable '" << predicate << "' for unknown object " << subject_path << endl; @@ -369,16 +382,16 @@ ClientStore::set_variable(const Path& subject_path, const URI& predicate, const void -ClientStore::set_property(const Path& subject_path, const URI& predicate, const Atom& value) +ClientStore::set_property(const URI& subject_path, const URI& predicate, const Atom& value) { - if (!value.is_valid()) - cerr << "WARNING: property '" << predicate << "' is NULL" << endl; - - SharedPtr<ObjectModel> obj = object(subject_path); - if (obj) - obj->set_property(predicate, value); - else + SharedPtr<Resource> subject = resource(subject_path); + if (!value.is_valid()) { + cerr << "ERROR: property '" << predicate << "' is invalid" << endl; + } else if (subject) { + subject->set_property(predicate, value); + } else { cerr << "WARNING: property '" << predicate << "' for unknown object " << subject_path << endl; + } } diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index 9fb95b0b..b8451fd2 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -55,8 +55,9 @@ public: ClientStore(SharedPtr<Shared::EngineInterface> engine=SharedPtr<Shared::EngineInterface>(), SharedPtr<SigClientInterface> emitter=SharedPtr<SigClientInterface>()); - SharedPtr<PluginModel> plugin(const Raul::URI& uri); - SharedPtr<ObjectModel> object(const Raul::Path& path); + SharedPtr<PluginModel> plugin(const Raul::URI& uri); + SharedPtr<ObjectModel> object(const Raul::Path& path); + SharedPtr<Shared::Resource> resource(const Raul::URI& uri); void clear(); @@ -72,8 +73,8 @@ public: void new_node(const Raul::Path& path, const Raul::URI& plugin_uri); void new_port(const Raul::Path& path, const Raul::URI& type, uint32_t index, bool is_output); void rename(const Raul::Path& old_path, const Raul::Path& new_path); - void set_variable(const Raul::Path& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - void set_property(const Raul::Path& subject_path, const Raul::URI& predicate, const Raul::Atom& value); + void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); + void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); void set_port_value(const Raul::Path& port_path, const Raul::Atom& value); void set_voice_value(const Raul::Path& port_path, uint32_t voice, const Raul::Atom& value); void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp index 2afa32f1..a03bc26a 100644 --- a/src/client/HTTPEngineSender.cpp +++ b/src/client/HTTPEngineSender.cpp @@ -209,7 +209,7 @@ HTTPEngineSender::midi_learn(const Path& node_path) void -HTTPEngineSender::set_variable(const Path& path, +HTTPEngineSender::set_variable(const URI& path, const URI& predicate, const Atom& value) { @@ -217,7 +217,7 @@ HTTPEngineSender::set_variable(const Path& path, void -HTTPEngineSender::set_property(const Path& path, +HTTPEngineSender::set_property(const URI& path, const URI& predicate, const Atom& value) { diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp index ffe60577..7436040b 100644 --- a/src/client/HTTPEngineSender.hpp +++ b/src/client/HTTPEngineSender.hpp @@ -103,11 +103,11 @@ public: virtual void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp index 45e7f82e..153f8dee 100644 --- a/src/client/OSCEngineSender.cpp +++ b/src/client/OSCEngineSender.cpp @@ -322,7 +322,7 @@ OSCEngineSender::midi_learn(const Path& node_path) void -OSCEngineSender::set_variable(const Path& obj_path, +OSCEngineSender::set_variable(const URI& obj_path, const URI& predicate, const Atom& value) { @@ -336,7 +336,7 @@ OSCEngineSender::set_variable(const Path& obj_path, void -OSCEngineSender::set_property(const Path& obj_path, +OSCEngineSender::set_property(const URI& obj_path, const URI& predicate, const Atom& value) { diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp index 0010a488..ffd8d678 100644 --- a/src/client/OSCEngineSender.hpp +++ b/src/client/OSCEngineSender.hpp @@ -106,11 +106,11 @@ public: virtual void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp index 40b30e47..ee20797a 100644 --- a/src/client/SigClientInterface.hpp +++ b/src/client/SigClientInterface.hpp @@ -62,8 +62,8 @@ public: sigc::signal<void, Raul::Path> signal_object_destroyed; sigc::signal<void, Raul::Path, Raul::Path> signal_connection; sigc::signal<void, Raul::Path, Raul::Path> signal_disconnection; - sigc::signal<void, Raul::Path, Raul::URI, Raul::Atom> signal_variable_change; - sigc::signal<void, Raul::Path, Raul::URI, Raul::Atom> signal_property_change; + sigc::signal<void, Raul::URI, Raul::URI, Raul::Atom> signal_variable_change; + sigc::signal<void, Raul::URI, Raul::URI, Raul::Atom> signal_property_change; sigc::signal<void, Raul::Path, Raul::Atom> signal_port_value; sigc::signal<void, Raul::Path, uint32_t, Raul::Atom> signal_voice_value; sigc::signal<void, Raul::Path> signal_activity; @@ -130,10 +130,10 @@ protected: void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) { if (_enabled) signal_disconnection.emit(src_port_path, dst_port_path); } - void set_variable(const Raul::Path& path, const Raul::URI& key, const Raul::Atom& value) + void set_variable(const Raul::URI& path, const Raul::URI& key, const Raul::Atom& value) { if (_enabled) signal_variable_change.emit(path, key, value); } - void set_property(const Raul::Path& path, const Raul::URI& key, const Raul::Atom& value) + void set_property(const Raul::URI& path, const Raul::URI& key, const Raul::Atom& value) { if (_enabled) signal_property_change.emit(path, key, value); } void set_port_value(const Raul::Path& port_path, const Raul::Atom& value) diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 714465c8..0862bdee 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -121,10 +121,10 @@ public: void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) { push_sig(sigc::bind(disconnection_slot, src_port_path, dst_port_path)); } - void set_variable(const Raul::Path& path, const Raul::URI& key, const Raul::Atom& value) + void set_variable(const Raul::URI& path, const Raul::URI& key, const Raul::Atom& value) { push_sig(sigc::bind(variable_change_slot, path, key, value)); } - void set_property(const Raul::Path& path, const Raul::URI& key, const Raul::Atom& value) + void set_property(const Raul::URI& path, const Raul::URI& key, const Raul::Atom& value) { push_sig(sigc::bind(property_change_slot, path, key, value)); } void set_port_value(const Raul::Path& port_path, const Raul::Atom& value) @@ -168,8 +168,8 @@ private: sigc::slot<void, Raul::Path> object_destroyed_slot; sigc::slot<void, Raul::Path, Raul::Path> object_renamed_slot; sigc::slot<void, Raul::Path, Raul::Path> disconnection_slot; - sigc::slot<void, Raul::Path, Raul::URI, Raul::Atom> variable_change_slot; - sigc::slot<void, Raul::Path, Raul::URI, Raul::Atom> property_change_slot; + sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> variable_change_slot; + sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> property_change_slot; sigc::slot<void, Raul::Path, Raul::Atom> port_value_slot; sigc::slot<void, Raul::Path, uint32_t, Raul::Atom> voice_value_slot; sigc::slot<void, Raul::Path> activity_slot; diff --git a/src/common/interface/CommonInterface.hpp b/src/common/interface/CommonInterface.hpp index aaa06628..d00c7baa 100644 --- a/src/common/interface/CommonInterface.hpp +++ b/src/common/interface/CommonInterface.hpp @@ -67,11 +67,11 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) = 0; - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value) = 0; - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value) = 0; diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index 9238ecdb..638dbbb1 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -167,7 +167,7 @@ ClientBroadcaster::send_disconnection(const Path& src_port_path, const Path& dst * Like control changes, does not send update to client that set the variable, if applicable. */ void -ClientBroadcaster::send_variable_change(const Path& node_path, const URI& key, const Atom& value) +ClientBroadcaster::send_variable_change(const URI& node_path, const URI& key, const Atom& value) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->set_variable(node_path, key, value); @@ -179,7 +179,7 @@ ClientBroadcaster::send_variable_change(const Path& node_path, const URI& key, c * Like control changes, does not send update to client that set the property, if applicable. */ void -ClientBroadcaster::send_property_change(const Path& node_path, const URI& key, const Atom& value) +ClientBroadcaster::send_property_change(const URI& node_path, const URI& key, const Atom& value) { for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->set_property(node_path, key, value); diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp index 33269192..a053e23b 100644 --- a/src/engine/ClientBroadcaster.hpp +++ b/src/engine/ClientBroadcaster.hpp @@ -69,8 +69,8 @@ public: void send_connection(const SharedPtr<const ConnectionImpl> connection); void send_disconnection(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); void send_rename(const Raul::Path& old_path, const Raul::Path& new_path); - void send_variable_change(const Raul::Path& node_path, const Raul::URI& key, const Raul::Atom& value); - void send_property_change(const Raul::Path& node_path, const Raul::URI& key, const Raul::Atom& value); + void send_variable_change(const Raul::URI& node_path, const Raul::URI& key, const Raul::Atom& value); + void send_property_change(const Raul::URI& node_path, const Raul::URI& key, const Raul::Atom& value); void send_port_value(const Raul::Path& port_path, const Raul::Atom& value); void send_activity(const Raul::Path& path); void send_program_add(const Raul::Path& node_path, int bank, int program, const std::string& name); diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index 34357365..2d02ab92 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -103,7 +103,7 @@ HTTPClientSender::disconnect(const Raul::Path& src_path, const Raul::Path& dst_p void -HTTPClientSender::set_variable(const Raul::Path& path, const Raul::URI& key, const Atom& value) +HTTPClientSender::set_variable(const Raul::URI& path, const Raul::URI& key, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); string msg = string( @@ -118,7 +118,7 @@ HTTPClientSender::set_variable(const Raul::Path& path, const Raul::URI& key, con void -HTTPClientSender::set_property(const Raul::Path& path, const Raul::URI& key, const Atom& value) +HTTPClientSender::set_property(const Raul::URI& path, const Raul::URI& key, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); string msg = string( diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index 1a06b7cf..e04e70f7 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -102,11 +102,11 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/LADSPAPlugin.cpp b/src/engine/LADSPAPlugin.cpp index 2f1a7c1f..bc1f02fd 100644 --- a/src/engine/LADSPAPlugin.cpp +++ b/src/engine/LADSPAPlugin.cpp @@ -28,6 +28,16 @@ using namespace std; namespace Ingen { +const Raul::Atom& +LADSPAPlugin::get_property(const Raul::URI& uri) const +{ + if (uri.str() == "doap:name") + return _name; + else + return ResourceImpl::get_property(uri); +} + + NodeImpl* LADSPAPlugin::instantiate(const string& name, bool polyphonic, diff --git a/src/engine/LADSPAPlugin.hpp b/src/engine/LADSPAPlugin.hpp index 1c01e107..1b4897a0 100644 --- a/src/engine/LADSPAPlugin.hpp +++ b/src/engine/LADSPAPlugin.hpp @@ -25,6 +25,7 @@ #include <string> #include <iostream> #include "raul/Path.hpp" +#include "raul/Atom.hpp" #include "PluginImpl.hpp" namespace Ingen { @@ -45,7 +46,7 @@ public: : PluginImpl(Plugin::LADSPA, uri, library_path) , _id(id) , _label(label) - , _name(name) + , _name(Raul::Atom::STRING, name) {} NodeImpl* instantiate(const std::string& name, @@ -56,16 +57,18 @@ public: const std::string& label() const { return _label; } unsigned long id() const { return _id; } const std::string symbol() const { return Raul::Path::nameify(_label); } - const std::string name() const { return _name; } + const std::string name() const { return _name.get_string(); } const std::string library_name() const { return _library_path.substr(_library_path.find_last_of("/")+1); } + const Raul::Atom& get_property(const Raul::URI& uri) const; + private: const unsigned long _id; const std::string _label; - const std::string _name; + const Raul::Atom _name; }; diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 3f54d9ea..9809c0dd 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -215,7 +215,7 @@ OSCClientSender::disconnect(const Path& src_port_path, const Path& dst_port_path * \arg \b value (string)</p> \n \n */ void -OSCClientSender::set_variable(const Path& path, const URI& key, const Atom& value) +OSCClientSender::set_variable(const URI& path, const URI& key, const Atom& value) { lo_message m = lo_message_new(); lo_message_add_string(m, path.c_str()); @@ -232,7 +232,7 @@ OSCClientSender::set_variable(const Path& path, const URI& key, const Atom& valu * \arg \b value (string)</p> \n \n */ void -OSCClientSender::set_property(const Path& path, const URI& key, const Atom& value) +OSCClientSender::set_property(const URI& path, const URI& key, const Atom& value) { lo_message m = lo_message_new(); lo_message_add_string(m, path.c_str()); diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index db8e2ba1..3b677e6d 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -101,11 +101,11 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 5f4082fa..dce860cd 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -263,7 +263,7 @@ QueuedEngineInterface::midi_learn(const Path& node_path) void -QueuedEngineInterface::set_variable(const Path& path, +QueuedEngineInterface::set_variable(const URI& path, const URI& predicate, const Atom& value) { @@ -272,7 +272,7 @@ QueuedEngineInterface::set_variable(const Path& path, void -QueuedEngineInterface::set_property(const Path& path, +QueuedEngineInterface::set_property(const URI& path, const URI& predicate, const Atom& value) { diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index 91fb14b0..2c174641 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -92,11 +92,11 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/events/RequestMetadataEvent.cpp b/src/engine/events/RequestMetadataEvent.cpp index cf8a127a..14cbcfb3 100644 --- a/src/engine/events/RequestMetadataEvent.cpp +++ b/src/engine/events/RequestMetadataEvent.cpp @@ -23,6 +23,7 @@ #include "EngineStore.hpp" #include "ClientBroadcaster.hpp" #include "PortImpl.hpp" +#include "PluginImpl.hpp" #include "AudioBuffer.hpp" using namespace std; @@ -36,15 +37,16 @@ using namespace Shared; RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, - bool property, - const Path& node_path, + bool is_property, + const URI& subject, const URI& key) : QueuedEvent(engine, responder, timestamp) + , _error(NO_ERROR) , _special_type(NONE) - , _path(node_path) - , _property(property) + , _uri(subject) , _key(key) - , _object(NULL) + , _resource(0) + , _is_property(is_property) { } @@ -52,9 +54,14 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, void RequestMetadataEvent::pre_process() { + const bool is_object = (_uri.scheme() == Path::scheme && Path::is_valid(_uri.str())); if (_responder->client()) { - _object = _engine.engine_store()->find_object(_path); - if (_object == NULL) { + if (is_object) + _resource = _engine.engine_store()->find_object(Path(_uri.str())); + else + _resource = _engine.node_factory()->plugin(_uri); + + if (!_resource) { QueuedEvent::pre_process(); return; } @@ -62,10 +69,10 @@ RequestMetadataEvent::pre_process() if (_key.str() == "ingen:value") _special_type = PORT_VALUE; - else if (_property) - _value = _object->get_property(_key); + else if (!is_object || _is_property) + _value = _resource->get_property(_key); else - _value = _object->get_variable(_key); + _value = dynamic_cast<GraphObjectImpl*>(_resource)->get_variable(_key); QueuedEvent::pre_process(); } @@ -76,12 +83,12 @@ RequestMetadataEvent::execute(ProcessContext& context) { QueuedEvent::execute(context); if (_special_type == PORT_VALUE) { - PortImpl* port = dynamic_cast<PortImpl*>(_object); + PortImpl* port = dynamic_cast<PortImpl*>(_resource); if (port) { if (port->type() == DataType::CONTROL || port->type() == DataType::AUDIO) _value = ((AudioBuffer*)port->buffer(0))->value_at(0); // TODO: offset } else { - _object = 0; + _resource = 0; } } } @@ -92,19 +99,19 @@ RequestMetadataEvent::post_process() { if (_responder->client()) { if (_special_type == PORT_VALUE) { - if (_object) { + if (_resource) { _responder->respond_ok(); - _responder->client()->set_port_value(_path, _value); + _responder->client()->set_port_value(_uri.str(), _value); } else { - const string msg = "Get value for non-port " + _path.str(); + const string msg = "Get value for non-port " + _uri.str(); _responder->respond_error(msg); } - } else if (!_object) { - const string msg = "Unable to find variable subject " + _path.str(); + } else if (!_resource) { + const string msg = "Unable to find subject " + _uri.str(); _responder->respond_error(msg); } else { _responder->respond_ok(); - _responder->client()->set_variable(_path, _key, _value); + _responder->client()->set_variable(_uri, _key, _value); } } else { _responder->respond_error("Unknown client"); diff --git a/src/engine/events/RequestMetadataEvent.hpp b/src/engine/events/RequestMetadataEvent.hpp index 5b163500..df1b1acd 100644 --- a/src/engine/events/RequestMetadataEvent.hpp +++ b/src/engine/events/RequestMetadataEvent.hpp @@ -23,7 +23,9 @@ #include "raul/URI.hpp" namespace Ingen { - + +namespace Shared { class ResourceImpl; } + class GraphObjectImpl; @@ -38,7 +40,7 @@ public: SharedPtr<Responder> responder, SampleCount timestamp, bool property, - const Raul::Path& path, + const Raul::URI& path, const Raul::URI& key); void pre_process(); @@ -46,16 +48,17 @@ public: void post_process(); private: + enum { NO_ERROR, NOT_FOUND } _error; enum { NONE, PORT_VALUE } _special_type; - Raul::Path _path; - bool _property; - Raul::URI _key; - Raul::Atom _value; - GraphObjectImpl* _object; + Raul::URI _uri; + Raul::URI _key; + Raul::Atom _value; + Shared::ResourceImpl* _resource; + bool _is_property; }; diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp index a41b866e..ea4e9129 100644 --- a/src/engine/events/SetMetadataEvent.cpp +++ b/src/engine/events/SetMetadataEvent.cpp @@ -24,6 +24,7 @@ #include "ClientBroadcaster.hpp" #include "GraphObjectImpl.hpp" #include "PatchImpl.hpp" +#include "PluginImpl.hpp" #include "EngineStore.hpp" using namespace std; @@ -37,14 +38,14 @@ SetMetadataEvent::SetMetadataEvent( SharedPtr<Responder> responder, SampleCount timestamp, bool property, - const Path& path, + const URI& subject, const URI& key, const Atom& value) : QueuedEvent(engine, responder, timestamp) , _error(NO_ERROR) , _special_type(NONE) , _property(property) - , _path(path) + , _subject(subject) , _key(key) , _value(value) , _object(NULL) @@ -57,7 +58,11 @@ SetMetadataEvent::SetMetadataEvent( void SetMetadataEvent::pre_process() { - _object = _engine.engine_store()->find_object(_path); + if (_subject.scheme() == Path::scheme && Path::is_valid(_subject.str())) + _object = _engine.engine_store()->find_object(Path(_subject.str())); + else + _object = _engine.node_factory()->plugin(_subject); + if (_object == NULL) { _error = NOT_FOUND; QueuedEvent::pre_process(); @@ -67,10 +72,10 @@ SetMetadataEvent::pre_process() /*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ") << _key << " :: " << _value.type() << endl;*/ - if (_property) + if (_property || !dynamic_cast<GraphObjectImpl*>(_object)) _object->set_property(_key, _value); else - _object->set_variable(_key, _value); + dynamic_cast<GraphObjectImpl*>(_object)->set_variable(_key, _value); _patch = dynamic_cast<PatchImpl*>(_object); @@ -111,7 +116,8 @@ SetMetadataEvent::execute(ProcessContext& context) if (_error != NO_ERROR) return; - PortImpl* port = 0; + PortImpl* port = 0; + GraphObjectImpl* object = 0; switch (_special_type) { case ENABLE_BROADCAST: if ((port = dynamic_cast<PortImpl*>(_object))) @@ -127,8 +133,9 @@ SetMetadataEvent::execute(ProcessContext& context) } break; case POLYPHONIC: - if (!_object->set_polyphonic(*_engine.maid(), _value.get_bool())) - _error = INTERNAL; + if ((object = dynamic_cast<GraphObjectImpl*>(_object))) + if (!object->set_polyphonic(*_engine.maid(), _value.get_bool())) + _error = INTERNAL; break; case POLYPHONY: if (!_patch->apply_internal_poly(*_engine.maid(), _value.get_int32())) @@ -149,14 +156,13 @@ SetMetadataEvent::post_process() case NO_ERROR: _responder->respond_ok(); if (_property) - _engine.broadcaster()->send_property_change(_path, _key, _value); + _engine.broadcaster()->send_property_change(_subject, _key, _value); else - _engine.broadcaster()->send_variable_change(_path, _key, _value); + _engine.broadcaster()->send_variable_change(_subject, _key, _value); break; case NOT_FOUND: _responder->respond_error((boost::format( - "Unable to find object '%1%' to set '%2%'") - % _path % _key).str()); + "Unable to find object '%1%' to set '%2%'") % _subject % _key).str()); case INTERNAL: _responder->respond_error("Internal error"); break; diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp index e4f64a11..70292682 100644 --- a/src/engine/events/SetMetadataEvent.hpp +++ b/src/engine/events/SetMetadataEvent.hpp @@ -20,6 +20,7 @@ #include "raul/URI.hpp" #include "raul/Atom.hpp" +#include "shared/ResourceImpl.hpp" #include "QueuedEvent.hpp" namespace Ingen { @@ -40,7 +41,7 @@ public: SharedPtr<Responder> responder, SampleCount timestamp, bool property, - const Raul::Path& path, + const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value); @@ -58,14 +59,14 @@ private: POLYPHONIC } _special_type; - bool _property; - bool _success; - Raul::Path _path; - Raul::URI _key; - Raul::Atom _value; - GraphObjectImpl* _object; - PatchImpl* _patch; - CompiledPatch* _compiled_patch; + bool _property; + bool _success; + Raul::URI _subject; + Raul::URI _key; + Raul::Atom _value; + Shared::ResourceImpl* _object; + PatchImpl* _patch; + CompiledPatch* _compiled_patch; }; diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp index 24569369..4995aa5e 100644 --- a/src/shared/ClashAvoider.cpp +++ b/src/shared/ClashAvoider.cpp @@ -26,7 +26,16 @@ namespace Ingen { namespace Shared { -/** Always returns a valid Raul::Path */ +const URI +ClashAvoider::map_uri(const Raul::URI& in) +{ + if (in.scheme() == Path::scheme && Path::is_valid(in.str())) + return map_path(in.str()); + else + return in; +} + + const Path ClashAvoider::map_path(const Raul::Path& in) { @@ -192,20 +201,20 @@ ClashAvoider::disconnect(const Raul::Path& src_port_path, void -ClashAvoider::set_variable(const Raul::Path& subject_path, +ClashAvoider::set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value) { - _target.set_variable(map_path(subject_path), predicate, value); + _target.set_variable(map_uri(subject_path), predicate, value); } void -ClashAvoider::set_property(const Raul::Path& subject_path, +ClashAvoider::set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value) { - _target.set_property(map_path(subject_path), predicate, value); + _target.set_property(map_uri(subject_path), predicate, value); } diff --git a/src/shared/ClashAvoider.hpp b/src/shared/ClashAvoider.hpp index 0692a59a..0334610d 100644 --- a/src/shared/ClashAvoider.hpp +++ b/src/shared/ClashAvoider.hpp @@ -70,11 +70,11 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::Path& subject_path, + virtual void set_variable(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - virtual void set_property(const Raul::Path& subject_path, + virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); @@ -90,6 +90,7 @@ public: virtual void clear_patch(const Raul::Path& patch_path); private: + const Raul::URI map_uri(const Raul::URI& in); const Raul::Path map_path(const Raul::Path& in); Store& _store; |