From 2f595631859574bfa7779ebb42f42b8590f5424c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 27 May 2009 23:21:34 +0000 Subject: Remove 'property' vs 'variable' dichotomy in favour of 'meta objects' (to match serialisation). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2016 a436a847-0d15-0410-975c-d299462d15a1 --- src/bindings/Client.hpp | 4 +- src/client/ClientStore.cpp | 40 +++++++--------- src/client/ClientStore.hpp | 3 +- src/client/DeprecatedLoader.cpp | 16 +++---- src/client/HTTPEngineSender.cpp | 12 +---- src/client/HTTPEngineSender.hpp | 8 +--- src/client/OSCClientReceiver.cpp | 26 ++-------- src/client/OSCClientReceiver.hpp | 1 - src/client/OSCEngineSender.cpp | 20 ++------ src/client/OSCEngineSender.hpp | 6 +-- src/client/ObjectModel.cpp | 18 +++---- src/client/ObjectModel.hpp | 10 ++-- src/client/PatchModel.cpp | 4 +- src/client/PatchModel.hpp | 2 +- src/client/SigClientInterface.hpp | 11 ++--- src/client/ThreadedSigClientInterface.hpp | 11 ++--- src/common/interface/CommonInterface.hpp | 8 +--- src/common/interface/GraphObject.hpp | 6 +-- src/engine/ClientBroadcaster.cpp | 16 +------ src/engine/GraphObjectImpl.cpp | 38 ++++++++++----- src/engine/GraphObjectImpl.hpp | 38 ++++++--------- src/engine/HTTPClientSender.cpp | 29 +++-------- src/engine/HTTPClientSender.hpp | 6 +-- src/engine/LADSPANode.cpp | 6 +-- src/engine/OSCClientSender.cpp | 21 +------- src/engine/OSCClientSender.hpp | 8 +--- src/engine/OSCEngineReceiver.cpp | 25 ---------- src/engine/ObjectSender.cpp | 36 ++++---------- src/engine/QueuedEngineInterface.cpp | 24 +++++----- src/engine/QueuedEngineInterface.hpp | 6 +-- src/engine/events/CreateNodeEvent.cpp | 2 +- src/engine/events/CreatePatchEvent.cpp | 4 +- src/engine/events/CreatePortEvent.cpp | 7 ++- src/engine/events/RequestMetadataEvent.cpp | 21 ++++---- src/engine/events/RequestMetadataEvent.hpp | 4 +- src/engine/events/SetMetadataEvent.cpp | 77 ++++++++++++++++-------------- src/engine/events/SetMetadataEvent.hpp | 6 +-- src/gui/Controls.cpp | 4 +- src/gui/Controls.hpp | 2 +- src/gui/LoadPluginWindow.cpp | 4 +- src/gui/NewSubpatchWindow.cpp | 4 +- src/gui/NodeModule.cpp | 15 +++--- src/gui/ObjectMenu.cpp | 6 +-- src/gui/ObjectMenu.hpp | 3 +- src/gui/PatchCanvas.cpp | 36 ++++---------- src/gui/PatchPortModule.cpp | 3 +- src/gui/PatchTreeWindow.cpp | 8 ++-- src/gui/PatchTreeWindow.hpp | 2 +- src/gui/PatchView.cpp | 5 +- src/gui/PatchWindow.cpp | 2 +- src/gui/Port.cpp | 4 +- src/gui/Port.hpp | 3 +- src/gui/PortPropertiesWindow.cpp | 16 ++----- src/gui/PortPropertiesWindow.hpp | 2 +- src/serialisation/Parser.cpp | 40 ++++++++-------- src/serialisation/Parser.hpp | 2 +- src/serialisation/Serialiser.cpp | 22 +++++---- src/serialisation/Serialiser.hpp | 6 +-- src/shared/Builder.cpp | 14 ++---- src/shared/ClashAvoider.cpp | 17 ++----- src/shared/ClashAvoider.hpp | 6 +-- src/shared/ResourceImpl.cpp | 7 +++ src/shared/ResourceImpl.hpp | 9 ++-- 63 files changed, 312 insertions(+), 510 deletions(-) (limited to 'src') diff --git a/src/bindings/Client.hpp b/src/bindings/Client.hpp index ca717df0..2c681f6e 100644 --- a/src/bindings/Client.hpp +++ b/src/bindings/Client.hpp @@ -42,7 +42,7 @@ public: const std::string& type_uri, const std::string& symbol) {} - void put(const Path& path, + void put(const URI& path, const Resource::Properties& properties) {} virtual void clear_patch(const std::string& path) {} @@ -56,7 +56,7 @@ public: virtual void disconnect(const std::string& src_port_path, const std::string& dst_port_path) {} - virtual void set_variable(const std::string& subject_path, + virtual void set_property(const std::string& subject_path, const std::string& predicate, const Raul::Atom& value) {} diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 10a5ac9b..7774e9c3 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -50,7 +50,6 @@ ClientStore::ClientStore(SharedPtr engine, SharedPtrsignal_clear_patch.connect(sigc::mem_fun(this, &ClientStore::clear_patch)); emitter->signal_connection.connect(sigc::mem_fun(this, &ClientStore::connect)); emitter->signal_disconnection.connect(sigc::mem_fun(this, &ClientStore::disconnect)); - emitter->signal_variable_change.connect(sigc::mem_fun(this, &ClientStore::set_variable)); emitter->signal_property_change.connect(sigc::mem_fun(this, &ClientStore::set_property)); emitter->signal_port_value.connect(sigc::mem_fun(this, &ClientStore::set_port_value)); emitter->signal_voice_value.connect(sigc::mem_fun(this, &ClientStore::set_voice_value)); @@ -87,7 +86,7 @@ ClientStore::add_object(SharedPtr object) signal_new_object.emit(object); #if 0 - resolve_variable_orphans(parent); + resolve_property_orphans(parent); resolve_orphans(parent); SharedPtr port = PtrCast(object); @@ -268,10 +267,14 @@ ClientStore::new_plugin(const URI& uri, const URI& type_uri, const Symbol& symbo void -ClientStore::put(const Path& path, const Resource::Properties& properties) +ClientStore::put(const URI& uri, const Resource::Properties& properties) { + size_t hash = uri.find("#"); + bool meta = (hash != string::npos); + Path path(meta ? (string("/") + uri.chop_start("#")) : uri.str()); + typedef Resource::Properties::const_iterator iterator; - cerr << "CLIENT PUT " << path << " {" << endl; + cerr << "CLIENT PUT " << uri << " (" << path << ") {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; cerr << "}" << endl; @@ -349,35 +352,24 @@ ClientStore::clear_patch(const Path& path) } -void -ClientStore::set_variable(const URI& subject_path, const URI& predicate, const Atom& value) -{ - SharedPtr subject = resource(subject_path); - - if (!value.is_valid()) { - cerr << "ERROR: variable '" << predicate << "' is invalid" << endl; - } else if (subject) { - SharedPtr om = PtrCast(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; - } -} - - void ClientStore::set_property(const URI& subject_path, const URI& predicate, const Atom& value) { SharedPtr subject = resource(subject_path); + + size_t hash = subject_path.find("#"); if (!value.is_valid()) { cerr << "ERROR: property '" << predicate << "' is invalid" << endl; } else if (subject) { subject->set_property(predicate, value); + } else if (hash != string::npos) { + cerr << "META OBJECT " << subject_path << " PROPERTY " << predicate << endl; + Path instance_path = string("/") + subject_path.chop_start("#"); + SharedPtr om = PtrCast(subject); + if (om) + om->meta().set_property(predicate, value); } else { + //add_property_orphan(subject_path, predicate, value); cerr << "WARNING: property '" << predicate << "' for unknown object " << subject_path << endl; } } diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index 6688bc23..00069701 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -69,9 +69,8 @@ public: // CommonInterface void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol); bool new_object(const Shared::GraphObject* object); - void put(const Raul::Path& path, const Shared::Resource::Properties& properties); + void put(const Raul::URI& path, const Shared::Resource::Properties& properties); void move(const Raul::Path& old_path, const Raul::Path& new_path); - 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); diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp index f593c3be..61e80b82 100644 --- a/src/client/DeprecatedLoader.cpp +++ b/src/client/DeprecatedLoader.cpp @@ -297,7 +297,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, props.insert(make_pair("ingen:polyphony", Atom((int32_t)poly))); _engine->put(path, props); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) - _engine->set_variable(path, i->first, i->second); + _engine->set_property(path, i->first, i->second); } // Load nodes @@ -352,10 +352,10 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, // Done above.. late enough? //for (Properties::const_iterator i = data.begin(); i != data.end(); ++i) - // _engine->set_variable(subject, i->first, i->second); + // _engine->set_property(subject, i->first, i->second); if (!existing) - _engine->set_variable(path, "ingen:enabled", (bool)true); + _engine->set_property(path, "ingen:enabled", (bool)true); _load_path_translations.clear(); @@ -507,7 +507,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr _engine->put(path, props); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) - _engine->set_variable(path, i->first, i->second); + _engine->set_property(path, i->first, i->second); return SharedPtr(); @@ -530,10 +530,10 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, plugin_uri))); _engine->put(path, props); - _engine->set_variable(path, "ingen:polyphonic", bool(polyphonic)); + _engine->set_property(path, "ingen:polyphonic", bool(polyphonic)); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) - _engine->set_variable(path, i->first, i->second); + _engine->set_property(path, i->first, i->second); return true; } @@ -544,9 +544,9 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Node"))); props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, plugin_uri))); _engine->put(path, props); - _engine->set_variable(path, "ingen:polyphonic", bool(polyphonic)); + _engine->set_property(path, "ingen:polyphonic", bool(polyphonic)); for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) - _engine->set_variable(path, i->first, i->second); + _engine->set_property(path, i->first, i->second); return true; } diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp index 48b861d5..18b92cad 100644 --- a/src/client/HTTPEngineSender.cpp +++ b/src/client/HTTPEngineSender.cpp @@ -105,7 +105,7 @@ HTTPEngineSender::quit() void -HTTPEngineSender::put(const Raul::Path& path, +HTTPEngineSender::put(const Raul::URI& path, const Shared::Resource::Properties& properties) { } @@ -173,15 +173,7 @@ HTTPEngineSender::midi_learn(const Path& node_path) void -HTTPEngineSender::set_variable(const URI& path, - const URI& predicate, - const Atom& value) -{ -} - - -void -HTTPEngineSender::set_property(const URI& path, +HTTPEngineSender::set_property(const URI& subject, const URI& predicate, const Atom& value) { diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp index c284995e..ee27e1de 100644 --- a/src/client/HTTPEngineSender.hpp +++ b/src/client/HTTPEngineSender.hpp @@ -74,7 +74,7 @@ public: // Object commands - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -93,11 +93,7 @@ public: virtual void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - - virtual void set_property(const Raul::URI& subject_path, + virtual void set_property(const Raul::URI& subject, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp index ec1f1378..e30ff7c4 100644 --- a/src/client/OSCClientReceiver.cpp +++ b/src/client/OSCClientReceiver.cpp @@ -150,7 +150,6 @@ OSCClientReceiver::setup_callbacks() lo_server_thread_add_method(_st, "/ingen/new_connection", "ss", connection_cb, this); lo_server_thread_add_method(_st, "/ingen/disconnection", "ss", disconnection_cb, this); lo_server_thread_add_method(_st, "/ingen/new_port", "sisi", new_port_cb, this); - lo_server_thread_add_method(_st, "/ingen/set_variable", NULL, set_variable_cb, this); lo_server_thread_add_method(_st, "/ingen/set_property", NULL, set_property_cb, this); lo_server_thread_add_method(_st, "/ingen/set_port_value", "sf", set_port_value_cb, this); lo_server_thread_add_method(_st, "/ingen/set_voice_value", "sif", set_voice_value_cb, this); @@ -216,25 +215,6 @@ OSCClientReceiver::_disconnection_cb(const char* path, const char* types, lo_arg } -/** Notification of a new or updated variable. - */ -int -OSCClientReceiver::_set_variable_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) -{ - if (argc != 3 || types[0] != 's' || types[1] != 's') - return 1; - - const char* obj_path = &argv[0]->s; - const char* key = &argv[1]->s; - - Atom value = AtomLiblo::lo_arg_to_atom(types[2], argv[2]); - - _target->set_variable(obj_path, key, value); - - return 0; -} - - /** Notification of a new or updated property. */ int @@ -243,12 +223,12 @@ OSCClientReceiver::_set_property_cb(const char* path, const char* types, lo_arg* if (argc != 3 || types[0] != 's' || types[1] != 's') return 1; - const char* obj_path = &argv[0]->s; - const char* key = &argv[1]->s; + const char* obj_uri = &argv[0]->s; + const char* key = &argv[1]->s; Atom value = AtomLiblo::lo_arg_to_atom(types[2], argv[2]); - _target->set_property(obj_path, key, value); + _target->set_property(obj_uri, key, value); return 0; } diff --git a/src/client/OSCClientReceiver.hpp b/src/client/OSCClientReceiver.hpp index d44c4ddb..a42a7ee0 100644 --- a/src/client/OSCClientReceiver.hpp +++ b/src/client/OSCClientReceiver.hpp @@ -91,7 +91,6 @@ private: LO_HANDLER(disconnection); LO_HANDLER(new_port); LO_HANDLER(put); - LO_HANDLER(set_variable); LO_HANDLER(set_property); LO_HANDLER(set_port_value); LO_HANDLER(set_voice_value); diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp index ac0d948c..3bc872f7 100644 --- a/src/client/OSCEngineSender.cpp +++ b/src/client/OSCEngineSender.cpp @@ -133,7 +133,7 @@ OSCEngineSender::quit() void -OSCEngineSender::put(const Raul::Path& path, +OSCEngineSender::put(const Raul::URI& path, const Shared::Resource::Properties& properties) { cerr << "OSC ENGINE PUT " << path << endl; @@ -249,27 +249,13 @@ OSCEngineSender::midi_learn(const Path& node_path) void -OSCEngineSender::set_variable(const URI& obj_path, +OSCEngineSender::set_property(const URI& subject, const URI& predicate, const Atom& value) { lo_message m = lo_message_new(); lo_message_add_int32(m, next_id()); - lo_message_add_string(m, obj_path.c_str()); - lo_message_add_string(m, predicate.c_str()); - Raul::AtomLiblo::lo_message_add_atom(m, value); - send_message("/ingen/set_variable", m); -} - - -void -OSCEngineSender::set_property(const URI& obj_path, - const URI& predicate, - const Atom& value) -{ - lo_message m = lo_message_new(); - lo_message_add_int32(m, next_id()); - lo_message_add_string(m, obj_path.c_str()); + lo_message_add_string(m, subject.c_str()); lo_message_add_string(m, predicate.c_str()); Raul::AtomLiblo::lo_message_add_atom(m, value); send_message("/ingen/set_property", m); diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp index a7479f70..187093d3 100644 --- a/src/client/OSCEngineSender.hpp +++ b/src/client/OSCEngineSender.hpp @@ -77,7 +77,7 @@ public: // Object commands - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -96,10 +96,6 @@ public: virtual void disconnect_all(const Raul::Path& parent_patch_path, const Raul::Path& path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 2d3251c6..367237c0 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -29,6 +29,7 @@ namespace Client { ObjectModel::ObjectModel(const Path& path) : ResourceImpl(path) + , _meta(std::string("meta:#") + path.chop_start("/")) , _path(path) { } @@ -93,20 +94,13 @@ ObjectModel::set(SharedPtr o) if (o->_parent) _parent = o->_parent; + for (Properties::const_iterator v = o->meta().properties().begin(); v != o->meta().properties().end(); ++v) { + o->meta().set_property(v->first, v->second); + signal_property.emit(v->first, v->second); + } for (Properties::const_iterator v = o->properties().begin(); v != o->properties().end(); ++v) { - const Raul::Atom& mine = get_property(v->first); - if (mine.is_valid()) - cerr << "WARNING: " << _path << "Client/Server property mismatch: " << v->first << endl; ResourceImpl::set_property(v->first, v->second); - signal_variable.emit(v->first, v->second); - } - - for (Properties::const_iterator v = o->variables().begin(); v != o->variables().end(); ++v) { - Properties::const_iterator mine = _variables.find(v->first); - if (mine != _variables.end()) - cerr << "WARNING: " << _path << "Client/Server variable mismatch: " << v->first << endl; - _variables.insert(make_pair(v->first, v->second)); - signal_variable.emit(v->first, v->second); + signal_property.emit(v->first, v->second); } } diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index f47bdfa6..321555fd 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -62,11 +62,13 @@ public: signal_property.emit(key, value); } - virtual void set_variable(const Raul::URI& key, const Raul::Atom& value) { - _variables.insert(make_pair(key, value)); - signal_variable.emit(key, value); + virtual void set_meta_property(const Raul::URI& key, const Raul::Atom& value) { + _meta.set_property(key, value); + signal_property.emit(key, value); } + Resource& meta() { return _meta; } + const Resource& meta() const { return _meta; } const Properties& variables() const { return _variables; } Properties& variables() { return _variables; } const Raul::Path path() const { return _path; } @@ -79,7 +81,6 @@ public: // Signals sigc::signal > signal_new_child; sigc::signal > signal_removed_child; - sigc::signal signal_variable; sigc::signal signal_property; sigc::signal signal_destroyed; sigc::signal signal_moved; @@ -96,6 +97,7 @@ protected: virtual void set(SharedPtr model); + ResourceImpl _meta; Raul::Path _path; SharedPtr _parent; diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index bdffed43..b64b9e50 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -170,9 +170,9 @@ PatchModel::enabled() const void -PatchModel::set_variable(const Raul::URI& key, const Atom& value) +PatchModel::set_meta_property(const Raul::URI& key, const Atom& value) { - NodeModel::set_variable(key, value); + NodeModel::set_meta_property(key, value); if (key.str() == "ingen:polyphony") _poly = value.get_int32(); } diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 4b036fbc..b52a4f8d 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -60,7 +60,7 @@ public: signal_editable.emit(e); } } - virtual void set_variable(const Raul::URI& key, const Raul::Atom& value); + virtual void set_meta_property(const Raul::URI& key, const Raul::Atom& value); // Signals sigc::signal > signal_new_node; diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp index 6038ad9e..857c575d 100644 --- a/src/client/SigClientInterface.hpp +++ b/src/client/SigClientInterface.hpp @@ -53,7 +53,7 @@ public: sigc::signal signal_new_plugin; sigc::signal signal_new_patch; sigc::signal signal_new_port; - sigc::signal signal_put; + sigc::signal signal_put; sigc::signal signal_clear_patch; sigc::signal signal_object_moved; sigc::signal signal_object_deleted; @@ -98,7 +98,7 @@ protected: void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol) { if (_enabled) signal_new_plugin.emit(uri, type_uri, symbol); } - void put(const Raul::Path& path, const Shared::Resource::Properties& properties) + void put(const Raul::URI& path, const Shared::Resource::Properties& properties) { if (_enabled) signal_put.emit(path, properties); } void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) @@ -116,11 +116,8 @@ 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::URI& path, const Raul::URI& key, const Raul::Atom& value) - { if (_enabled) signal_variable_change.emit(path, key, 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_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + { if (_enabled) signal_property_change.emit(subject, key, value); } void set_port_value(const Raul::Path& port_path, const Raul::Atom& value) { if (_enabled) signal_port_value.emit(port_path, value); } diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 21b92d56..d83e3334 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -92,7 +92,7 @@ public: void new_plugin(const Raul::URI& uri, const Raul::URI& type_uri, const Raul::Symbol& symbol) { push_sig(sigc::bind(new_plugin_slot, uri, type_uri, symbol)); } - void put(const Raul::Path& path, const Shared::Resource::Properties& properties) + void put(const Raul::URI& path, const Shared::Resource::Properties& properties) { push_sig(sigc::bind(put_slot, path, properties)); } void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) @@ -110,11 +110,8 @@ 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::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::URI& path, const Raul::URI& key, const Raul::Atom& value) - { push_sig(sigc::bind(property_change_slot, path, key, value)); } + void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) + { push_sig(sigc::bind(property_change_slot, subject, key, value)); } void set_port_value(const Raul::Path& port_path, const Raul::Atom& value) { push_sig(sigc::bind(port_value_slot, port_path, value)); } @@ -144,7 +141,7 @@ private: sigc::slot error_slot; sigc::slot new_plugin_slot; sigc::slot new_port_slot; - sigc::slot put_slot; + sigc::slot put_slot; sigc::slot connection_slot; sigc::slot clear_patch_slot; sigc::slot object_deleted_slot; diff --git a/src/common/interface/CommonInterface.hpp b/src/common/interface/CommonInterface.hpp index 89a96978..e3c5998d 100644 --- a/src/common/interface/CommonInterface.hpp +++ b/src/common/interface/CommonInterface.hpp @@ -45,7 +45,7 @@ public: /** End (and send) an atomic bundle */ virtual void bundle_end() = 0; - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& uri, const Resource::Properties& properties) = 0; virtual void move(const Raul::Path& old_path, @@ -59,11 +59,7 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) = 0; - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value) = 0; - - virtual void set_property(const Raul::URI& subject_path, + virtual void set_property(const Raul::URI& subject, const Raul::URI& predicate, const Raul::Atom& value) = 0; diff --git a/src/common/interface/GraphObject.hpp b/src/common/interface/GraphObject.hpp index edc1787e..fa2b75c6 100644 --- a/src/common/interface/GraphObject.hpp +++ b/src/common/interface/GraphObject.hpp @@ -45,15 +45,15 @@ class GraphObject : public Raul::Deletable public: typedef Raul::PathTable< SharedPtr >::const_iterator const_iterator; + virtual const Resource& meta() const = 0; + virtual Resource& meta() = 0; + virtual void set_path(const Raul::Path& path) = 0; virtual const Raul::Path path() const = 0; virtual const Raul::Symbol symbol() const = 0; - virtual const Properties& variables() const = 0; - virtual Properties& variables() = 0; virtual bool polyphonic() const = 0; - // FIXME: return WeakPtr, and stupid name virtual GraphObject* graph_parent() const = 0; }; diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index c0f107de..8aaffe94 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -162,27 +162,15 @@ ClientBroadcaster::send_disconnection(const Path& src_port_path, const Path& dst } -/** Send notification of a variable update. - * - * Like control changes, does not send update to client that set the variable, if applicable. - */ -void -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); -} - - /** Send notification of a property update. * * Like control changes, does not send update to client that set the property, if applicable. */ void -ClientBroadcaster::send_property_change(const URI& node_path, const URI& key, const Atom& value) +ClientBroadcaster::send_property_change(const URI& subject, 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); + (*i).second->set_property(subject, key, value); } diff --git a/src/engine/GraphObjectImpl.cpp b/src/engine/GraphObjectImpl.cpp index ef4e2cd4..40cdc792 100644 --- a/src/engine/GraphObjectImpl.cpp +++ b/src/engine/GraphObjectImpl.cpp @@ -27,26 +27,38 @@ namespace Ingen { using namespace Shared; + +GraphObjectImpl::GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic) + : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name) + , _parent(parent) + , _name(name) + , _meta(std::string("meta:#") + path().chop_start("/")) + , _polyphonic(polyphonic) +{ + assert(parent == NULL || _name.length() > 0); + assert(_name.find("/") == std::string::npos); +} + + +void +GraphObjectImpl::add_meta_property(const Raul::URI& key, const Atom& value) +{ + _meta.add_property(key, value); +} + + void -GraphObjectImpl::set_variable(const Raul::URI& key, const Atom& value) +GraphObjectImpl::set_meta_property(const Raul::URI& key, const Atom& value) { - // Ignore duplicate statements - typedef Resource::Properties::const_iterator iterator; - const std::pair range = _variables.equal_range(key); - for (iterator i = range.first; i != range.second; ++i) - if (i->second == value) - return; - - _variables.insert(make_pair(key, value)); + _meta.set_property(key, value); } const Atom& -GraphObjectImpl::get_variable(const Raul::URI& key) +GraphObjectImpl::get_property(const Raul::URI& key) const { - static const Atom null_atom; - Properties::iterator i = _variables.find(key); - return (i != _variables.end()) ? (*i).second : null_atom; + Resource::Properties::const_iterator i = properties().find(key); + return (i != properties().end()) ? i->second : _meta.get_property(key); } diff --git a/src/engine/GraphObjectImpl.hpp b/src/engine/GraphObjectImpl.hpp index a6f6b532..c8b0c13c 100644 --- a/src/engine/GraphObjectImpl.hpp +++ b/src/engine/GraphObjectImpl.hpp @@ -49,15 +49,17 @@ class GraphObjectImpl : virtual public Ingen::Shared::GraphObject public: virtual ~GraphObjectImpl() {} + const Raul::URI meta_uri() const { return _meta.uri(); } + const Raul::URI uri() const { return path(); } + const Raul::Symbol symbol() const { return _name; } + bool polyphonic() const { return _polyphonic; } virtual bool set_polyphonic(Raul::Maid& maid, bool p) { _polyphonic = p; return true; } - GraphObject* graph_parent() const { return _parent; } - - const Raul::URI uri() const { return path(); } - - inline GraphObjectImpl* parent() const { return _parent; } - const Raul::Symbol symbol() const { return _name; } + GraphObject* graph_parent() const { return _parent; } + GraphObjectImpl* parent() const { return _parent; } + Resource& meta() { return _meta; } + const Resource& meta() const { return _meta; } virtual void process(ProcessContext& context) = 0; @@ -68,18 +70,16 @@ public: assert(_name.find("/") == std::string::npos); } - const Raul::Atom& get_variable(const Raul::URI& key); - void set_variable(const Raul::URI& key, const Raul::Atom& value); - - const Properties& variables() const { return _variables; } - Properties& variables() { return _variables; } + const Raul::Atom& get_property(const Raul::URI& key) const; + void add_meta_property(const Raul::URI& key, const Raul::Atom& value); + void set_meta_property(const Raul::URI& key, const Raul::Atom& value); /** The Patch this object is a child of. */ virtual PatchImpl* parent_patch() const; /** Raul::Path is dynamically generated from parent to ease renaming */ const Raul::Path path() const { - if (_parent == NULL) + if (!_parent) return Raul::Path(std::string("/").append(_name)); else if (_parent->path().is_root()) return Raul::Path(std::string("/").append(_name)); @@ -90,22 +90,12 @@ public: SharedPtr find_child(const std::string& name) const; protected: - GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false) - : ResourceImpl((parent ? parent->path().base() : Raul::Path::root_uri) + name) - , _parent(parent) - , _name(name) - , _polyphonic(polyphonic) - { - assert(parent == NULL || _name.length() > 0); - assert(_name.find("/") == std::string::npos); - } + GraphObjectImpl(GraphObjectImpl* parent, const std::string& name, bool polyphonic=false); GraphObjectImpl* _parent; std::string _name; + ResourceImpl _meta; bool _polyphonic; - -private: - Properties _variables; }; diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index 83d3f1b2..fa6421b9 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -50,7 +50,7 @@ HTTPClientSender::error(const std::string& msg) void -HTTPClientSender::put(const Path& path, +HTTPClientSender::put(const URI& path, const Shared::Resource::Properties& properties) { cerr << "HTTP CLIENT PUT " << path << endl; @@ -75,7 +75,7 @@ HTTPClientSender::clear_patch(const Path& patch_path) void HTTPClientSender::connect(const Path& src_path, const Path& dst_path) { - string msg = string( + const string msg = string( "@prefix rdf: .\n" "@prefix ingen: .\n" "@prefix lv2var: .\n\n<").append( @@ -94,30 +94,15 @@ HTTPClientSender::disconnect(const Path& src_path, const Path& dst_path) void -HTTPClientSender::set_variable(const URI& path, const URI& key, const Atom& value) +HTTPClientSender::set_property(const URI& subject, const URI& key, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( - "@prefix rdf: .\n" - "@prefix ingenuity: .\n" - "@prefix lv2var: .\n\n<").append( - path.str()).append("> lv2var:variable [\n" - "rdf:predicate ").append(key.str()).append(" ;\n" - "rdf:value ").append(node.to_string()).append("\n] .\n"); - send_chunk(msg); -} - - -void -HTTPClientSender::set_property(const URI& path, const URI& key, const Atom& value) -{ - Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( + const string msg = string( "@prefix rdf: .\n" "@prefix ingen: .\n" "@prefix ingenuity: .\n" "@prefix lv2var: .\n\n<").append( - path.str()).append("> ingen:property [\n" + subject.str()).append("> ingen:property [\n" "rdf:predicate ").append(key.str()).append(" ;\n" "rdf:value ").append(node.to_string()).append("\n] .\n"); send_chunk(msg); @@ -128,7 +113,7 @@ void HTTPClientSender::set_port_value(const Path& port_path, const Atom& value) { Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world, value); - string msg = string( + const string msg = string( "@prefix ingen: .\n\n<").append( port_path.str()).append("> ingen:value ").append(node.to_string()).append(" .\n"); send_chunk(msg); @@ -148,7 +133,7 @@ HTTPClientSender::set_voice_value(const Path& port_path, uint32_t voice, const A void HTTPClientSender::activity(const Path& path) { - string msg = string( + const string msg = string( "@prefix ingen: .\n\n<").append( path.str()).append("> ingen:activity true .\n"); send_chunk(msg); diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index fb045194..9a7948ff 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -78,7 +78,7 @@ public: const Raul::URI& type_uri, const Raul::Symbol& symbol); - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -94,10 +94,6 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/LADSPANode.cpp b/src/engine/LADSPANode.cpp index 4431065a..e761ff60 100644 --- a/src/engine/LADSPANode.cpp +++ b/src/engine/LADSPANode.cpp @@ -241,11 +241,11 @@ LADSPANode::instantiate() if (port->is_input() && port->buffer_size() == 1) { if (min) - port->set_variable("lv2:minimum", min.get()); + port->set_meta_property("lv2:minimum", min.get()); if (max) - port->set_variable("lv2:maximum", max.get()); + port->set_meta_property("lv2:maximum", max.get()); if (default_val) - port->set_variable("lv2:default", default_val.get()); + port->set_meta_property("lv2:default", default_val.get()); } } diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 594266aa..5a941dc2 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -105,7 +105,7 @@ OSCClientSender::error(const std::string& msg) * PUT a set of properties to a path (see \ref methods). */ void -OSCClientSender::put(const Raul::Path& path, +OSCClientSender::put(const Raul::URI& path, const Shared::Resource::Properties& properties) { cerr << "OSC CLIENT PUT " << path << endl; @@ -182,25 +182,6 @@ OSCClientSender::disconnect(const Path& src_port_path, const Path& dst_port_path } -/** \page client_osc_namespace - *

/ingen/set_variable

- * \arg \b path (string) - Path of the object associated with variable (node, patch, or port) - * \arg \b key (string) - * \arg \b value (string) - * , - * Notification of a variable. - */ -void -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()); - lo_message_add_string(m, key.c_str()); - AtomLiblo::lo_message_add_atom(m, value); - send_message("/ingen/set_variable", m); -} - - /** \page client_osc_namespace *

/ingen/set_property

* \arg \b path (string) - Path of the object associated with property (node, patch, or port) diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index 4a0742eb..333fee49 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -75,7 +75,7 @@ public: const Raul::URI& type_uri, const Raul::Symbol& symbol); - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void clear_patch(const Raul::Path& path); @@ -91,11 +91,7 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - - virtual void set_property(const Raul::URI& subject_path, + virtual void set_property(const Raul::URI& subject, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp index 21a9b898..6cdc4ea2 100644 --- a/src/engine/OSCEngineReceiver.cpp +++ b/src/engine/OSCEngineReceiver.cpp @@ -640,31 +640,6 @@ OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg** } -/** \page engine_osc_namespace - *

/ingen/set_variable

- * \arg \b response-id (integer) - * \arg \b object-path (string) - Full path of object to associate variable with - * \arg \b key (string) - Key (index/predicate/ID) for new variable - * \arg \b value (string) - Value of new variable - * - * Set a variable, associated with a graph object. - */ -int -OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) -{ - if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's') - return 1; - - const char* object_path = &argv[1]->s; - const char* key = &argv[2]->s; - - Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]); - - set_variable(object_path, key, value); - return 0; -} - - /** \page engine_osc_namespace *

/ingen/set_property

* \arg \b response-id (integer) diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp index 9bf70cbf..072d6c52 100644 --- a/src/engine/ObjectSender.cpp +++ b/src/engine/ObjectSender.cpp @@ -62,14 +62,10 @@ ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool r if (bundle) client->transfer_begin(); - client->put(patch->path(), patch->properties()); + client->put(patch->meta_uri(), patch->meta().properties()); + client->put(patch->path(), patch->properties()); if (recursive) { - // Send variables - const GraphObjectImpl::Properties& data = patch->variables(); - for (GraphObjectImpl::Properties::const_iterator j = data.begin(); j != data.end(); ++j) - client->set_variable(patch->path(), (*j).first, (*j).second); - // Send nodes for (List::const_iterator j = patch->nodes().begin(); j != patch->nodes().end(); ++j) { @@ -113,12 +109,7 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu if (bundle) client->transfer_begin(); - client->put(node->path(), node->variables()); - - // Send variables - const GraphObjectImpl::Properties& prop = node->variables(); - for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j) - client->set_variable(node->path(), (*j).first, (*j).second); + client->put(node->path(), node->properties()); if (recursive) { // Send ports @@ -139,26 +130,19 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port, bool bund if (bundle) client->bundle_begin(); - client->put(port->path(), port->properties()); - PatchImpl* graph_parent = dynamic_cast(port->parent_node()); - if (graph_parent && graph_parent->internal_polyphony() > 1) - client->set_variable(port->path(), "ingen:polyphonic", bool(port->polyphonic())); - // Send variables - const GraphObjectImpl::Properties& data = port->variables(); - for (GraphObjectImpl::Properties::const_iterator j = data.begin(); j != data.end(); ++j) - client->set_variable(port->path(), (*j).first, (*j).second); + if (graph_parent) + client->put(port->meta_uri(), port->meta().properties()); + + client->put(port->path(), port->properties()); - // Send properties - const GraphObjectImpl::Properties& prop = port->properties(); - for (GraphObjectImpl::Properties::const_iterator j = prop.begin(); j != prop.end(); ++j) - client->set_property(port->path(), (*j).first, (*j).second); + if (graph_parent && graph_parent->internal_polyphony() > 1) + client->set_property(port->meta_uri(), "ingen:polyphonic", bool(port->polyphonic())); // Send control value if (port->type() == DataType::CONTROL) { - const Sample value = dynamic_cast(port->buffer(0))->value_at(0); - //cerr << port->path() << " sending default value " << default_value << endl; + const Sample& value = dynamic_cast(port->buffer(0))->value_at(0); client->set_port_value(port->path(), value); } diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 7c9c2c1a..4b2926e7 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -152,11 +152,15 @@ QueuedEngineInterface::bundle_end() void -QueuedEngineInterface::put(const Path& path, +QueuedEngineInterface::put(const URI& uri, const Resource::Properties& properties) { + size_t hash = uri.find("#"); + bool meta = (hash != string::npos); + Path path(meta ? (string("/") + uri.chop_start("#")) : uri.str()); + typedef Resource::Properties::const_iterator iterator; - cerr << "ENGINE PUT " << path << " {" << endl; + cerr << "ENGINE PUT " << path << " (" << path << ") {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; cerr << "}" << endl; @@ -255,20 +259,14 @@ QueuedEngineInterface::midi_learn(const Path& node_path) void -QueuedEngineInterface::set_variable(const URI& path, - const URI& predicate, - const Atom& value) -{ - push_queued(new SetMetadataEvent(_engine, _responder, now(), false, path, predicate, value)); -} - - -void -QueuedEngineInterface::set_property(const URI& path, +QueuedEngineInterface::set_property(const URI& uri, const URI& predicate, const Atom& value) { - push_queued(new SetMetadataEvent(_engine, _responder, now(), true, path, predicate, value)); + size_t hash = uri.find("#"); + bool meta = (hash != string::npos); + Path path = meta ? (string("/") + path.chop_start("/")) : uri.str(); + push_queued(new SetMetadataEvent(_engine, _responder, now(), meta, path, predicate, value)); } // Requests // diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index 2a94abff..43237ac8 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -71,7 +71,7 @@ public: // CommonInterface object commands - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Shared::Resource::Properties& properties); virtual void move(const Raul::Path& old_path, @@ -83,10 +83,6 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/engine/events/CreateNodeEvent.cpp b/src/engine/events/CreateNodeEvent.cpp index 6f3ed834..718a94a3 100644 --- a/src/engine/events/CreateNodeEvent.cpp +++ b/src/engine/events/CreateNodeEvent.cpp @@ -89,7 +89,7 @@ CreateNodeEvent::pre_process() if (_patch && plugin) { _node = plugin->instantiate(_path.name(), _polyphonic, _patch, _engine); - _node->variables().insert(_properties.begin(), _properties.end()); + _node->properties().insert(_properties.begin(), _properties.end()); if (_node != NULL) { _node->activate(); diff --git a/src/engine/events/CreatePatchEvent.cpp b/src/engine/events/CreatePatchEvent.cpp index f4a60760..16f749a3 100644 --- a/src/engine/events/CreatePatchEvent.cpp +++ b/src/engine/events/CreatePatchEvent.cpp @@ -83,7 +83,9 @@ CreatePatchEvent::pre_process() poly = _poly; _patch = new PatchImpl(_engine, path.name(), poly, _parent, _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size(), _poly); - _patch->properties().insert(_properties.begin(), _properties.end()); + _patch->meta().properties().insert(_properties.begin(), _properties.end()); + _patch->set_property("rdf:type", Atom(Atom::URI, "ingen:Node")); + _patch->set_property("rdf:instanceOf", Atom(Atom::URI, _patch->meta_uri().str())); if (_parent != NULL) { _parent->add_node(new PatchImpl::Nodes::Node(_patch)); diff --git a/src/engine/events/CreatePortEvent.cpp b/src/engine/events/CreatePortEvent.cpp index 38c3587c..e954c56d 100644 --- a/src/engine/events/CreatePortEvent.cpp +++ b/src/engine/events/CreatePortEvent.cpp @@ -15,10 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "raul/Path.hpp" #include "raul/Array.hpp" +#include "raul/Atom.hpp" #include "raul/List.hpp" #include "raul/Maid.hpp" +#include "raul/Path.hpp" #include "Responder.hpp" #include "CreatePortEvent.hpp" #include "PatchImpl.hpp" @@ -35,6 +36,7 @@ #include "DuplexPort.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -96,7 +98,8 @@ CreatePortEvent::pre_process() const uint32_t old_num_ports = _patch->num_ports(); _patch_port = _patch->create_port(_path.name(), _data_type, buffer_size, _is_output); - _patch_port->properties().insert(_properties.begin(), _properties.end()); + _patch_port->set_property("rdf:instanceOf", Atom(Atom::URI, _patch_port->meta_uri().str())); + _patch_port->meta().properties().insert(_properties.begin(), _properties.end()); if (_patch_port) { diff --git a/src/engine/events/RequestMetadataEvent.cpp b/src/engine/events/RequestMetadataEvent.cpp index fe1f0cab..5d0b15bc 100644 --- a/src/engine/events/RequestMetadataEvent.cpp +++ b/src/engine/events/RequestMetadataEvent.cpp @@ -37,7 +37,7 @@ using namespace Shared; RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, - bool is_property, + bool is_meta, const URI& subject, const URI& key) : QueuedEvent(engine, responder, timestamp) @@ -46,7 +46,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, , _uri(subject) , _key(key) , _resource(0) - , _is_property(is_property) + , _is_meta(is_meta) { } @@ -67,12 +67,17 @@ RequestMetadataEvent::pre_process() } } - if (_key.str() == "ingen:value") - _special_type = PORT_VALUE; - else if (!is_object || _is_property) + GraphObjectImpl* obj = dynamic_cast(_resource); + if (obj) { + if (_key.str() == "ingen:value") + _special_type = PORT_VALUE; + else if (_is_meta) + _value = obj->meta().get_property(_key); + else + _value = obj->get_property(_key); + } else { _value = _resource->get_property(_key); - else - _value = dynamic_cast(_resource)->get_variable(_key); + } QueuedEvent::pre_process(); } @@ -111,7 +116,7 @@ RequestMetadataEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _responder->client()->set_variable(_uri, _key, _value); + _responder->client()->set_property(_uri, _key, _value); } } else { _responder->respond_error("Unknown client"); diff --git a/src/engine/events/RequestMetadataEvent.hpp b/src/engine/events/RequestMetadataEvent.hpp index 1445f83d..9d1c6bf0 100644 --- a/src/engine/events/RequestMetadataEvent.hpp +++ b/src/engine/events/RequestMetadataEvent.hpp @@ -39,7 +39,7 @@ public: RequestMetadataEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, - bool property, + bool meta, const Raul::URI& path, const Raul::URI& key); @@ -58,7 +58,7 @@ private: Raul::URI _key; Raul::Atom _value; Shared::ResourceImpl* _resource; - bool _is_property; + bool _is_meta; }; diff --git a/src/engine/events/SetMetadataEvent.cpp b/src/engine/events/SetMetadataEvent.cpp index af36b5d3..482656ca 100644 --- a/src/engine/events/SetMetadataEvent.cpp +++ b/src/engine/events/SetMetadataEvent.cpp @@ -37,20 +37,21 @@ SetMetadataEvent::SetMetadataEvent( Engine& engine, SharedPtr responder, SampleCount timestamp, - bool property, + bool meta, const URI& subject, const URI& key, const Atom& value) : QueuedEvent(engine, responder, timestamp) , _error(NO_ERROR) , _special_type(NONE) - , _property(property) , _subject(subject) , _key(key) , _value(value) , _object(NULL) , _patch(NULL) , _compiled_patch(NULL) + , _is_meta(meta) + , _success(false) { } @@ -70,40 +71,45 @@ SetMetadataEvent::pre_process() } /*cerr << "SET " << _object->path() << (_property ? " PROP " : " VAR ") - << _key << " :: " << _value.type() << endl;*/ + << _key << " :: " << _value.type() << endl;*/ - if (_property || !dynamic_cast(_object)) - _object->set_property(_key, _value); - else - dynamic_cast(_object)->set_variable(_key, _value); - - _patch = dynamic_cast(_object); - - if (_key.str() == "ingen:broadcast") { - _special_type = ENABLE_BROADCAST; - } else if (_patch) { - if (!_property && _key.str() == "ingen:enabled") { - if (_value.type() == Atom::BOOL) { - _special_type = ENABLE; - if (_value.get_bool() && !_patch->compiled_patch()) - _compiled_patch = _patch->compile(); - } else { - _error = BAD_TYPE; - } - } else if (!_property && _key.str() == "ingen:polyphonic") { - if (_value.type() == Atom::BOOL) { - _special_type = POLYPHONIC; - } else { - _error = BAD_TYPE; - } - } else if (_property && _key.str() == "ingen:polyphony") { - if (_value.type() == Atom::INT) { - _special_type = POLYPHONY; - _patch->prepare_internal_poly(_value.get_int32()); - } else { - _error = BAD_TYPE; + GraphObjectImpl* obj = dynamic_cast(_object); + if (obj) { + if (_is_meta) + obj->meta().set_property(_key, _value); + else + obj->set_property(_key, _value); + + _patch = dynamic_cast(_object); + + if (_key.str() == "ingen:broadcast") { + _special_type = ENABLE_BROADCAST; + } else if (_patch) { + if (_key.str() == "ingen:enabled") { + if (_value.type() == Atom::BOOL) { + _special_type = ENABLE; + if (_value.get_bool() && !_patch->compiled_patch()) + _compiled_patch = _patch->compile(); + } else { + _error = BAD_TYPE; + } + } else if (_key.str() == "ingen:polyphonic") { + if (_value.type() == Atom::BOOL) { + _special_type = POLYPHONIC; + } else { + _error = BAD_TYPE; + } + } else if (_key.str() == "ingen:polyphony") { + if (_value.type() == Atom::INT) { + _special_type = POLYPHONY; + _patch->prepare_internal_poly(_value.get_int32()); + } else { + _error = BAD_TYPE; + } } } + } else { + _object->set_property(_key, _value); } QueuedEvent::pre_process(); @@ -155,10 +161,7 @@ SetMetadataEvent::post_process() switch (_error) { case NO_ERROR: _responder->respond_ok(); - if (_property) - _engine.broadcaster()->send_property_change(_subject, _key, _value); - else - _engine.broadcaster()->send_variable_change(_subject, _key, _value); + _engine.broadcaster()->send_property_change(_subject, _key, _value); break; case NOT_FOUND: _responder->respond_error((boost::format( diff --git a/src/engine/events/SetMetadataEvent.hpp b/src/engine/events/SetMetadataEvent.hpp index 944091b0..b33cc9ca 100644 --- a/src/engine/events/SetMetadataEvent.hpp +++ b/src/engine/events/SetMetadataEvent.hpp @@ -40,7 +40,7 @@ public: SetMetadataEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, - bool property, + bool meta, const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value); @@ -59,14 +59,14 @@ private: POLYPHONIC } _special_type; - bool _property; - bool _success; Raul::URI _subject; Raul::URI _key; Raul::Atom _value; Shared::ResourceImpl* _object; PatchImpl* _patch; CompiledPatch* _compiled_patch; + bool _is_meta; + bool _success; }; diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 20f2f208..a6a2ead3 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -137,7 +137,7 @@ SliderControl::init(ControlPanel* panel, SharedPtr pm) _slider->set_increments(0, 0); } - pm->signal_variable.connect(sigc::mem_fun(this, &SliderControl::port_variable_change)); + pm->signal_property.connect(sigc::mem_fun(this, &SliderControl::port_property_change)); _slider->set_range(std::min(min, pm->value().get_float()), std::max(max, pm->value().get_float())); //_value_spinner->set_range(min, max); @@ -188,7 +188,7 @@ SliderControl::set_value(const Atom& atom) void -SliderControl::port_variable_change(const URI& key, const Atom& value) +SliderControl::port_property_change(const URI& key, const Atom& value) { _enable_signal = false; diff --git a/src/gui/Controls.hpp b/src/gui/Controls.hpp index 63bc4ceb..9a6a13f5 100644 --- a/src/gui/Controls.hpp +++ b/src/gui/Controls.hpp @@ -87,7 +87,7 @@ private: void set_value(const Raul::Atom& value); void set_range(float min, float max); - void port_variable_change(const Raul::URI& key, const Raul::Atom& value); + void port_property_change(const Raul::URI& key, const Raul::Atom& value); void update_range(); void update_value_from_slider(); diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 2382cac0..03966964 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -347,10 +347,10 @@ LoadPluginWindow::add_clicked() props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Node"))); props.insert(make_pair("rdf:instanceOf", Atom(Atom::URI, plugin->uri().str()))); App::instance().engine()->put(path, props); - App::instance().engine()->set_variable(path, "ingen:polyphonic", bool(polyphonic)); + App::instance().engine()->set_property(path, "ingen:polyphonic", bool(polyphonic)); for (GraphObject::Properties::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) - App::instance().engine()->set_variable(path, i->first, i->second); + App::instance().engine()->set_property(path, i->first, i->second); _node_name_entry->set_text(generate_module_name(++_plugin_name_offset)); // Cascade diff --git a/src/gui/NewSubpatchWindow.cpp b/src/gui/NewSubpatchWindow.cpp index 46663f2c..0a0f11f5 100644 --- a/src/gui/NewSubpatchWindow.cpp +++ b/src/gui/NewSubpatchWindow.cpp @@ -100,9 +100,9 @@ NewSubpatchWindow::ok_clicked() App::instance().engine()->put(path, props); for (GraphObject::Properties::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) - App::instance().engine()->set_variable(path, i->first, i->second); + App::instance().engine()->set_property(path, i->first, i->second); - App::instance().engine()->set_variable(path, "ingen:enabled", (bool)true); + App::instance().engine()->set_property(path, "ingen:enabled", (bool)true); hide(); } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 74f3bc9e..b507bba7 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -52,7 +52,6 @@ NodeModule::NodeModule(boost::shared_ptr canvas, SharedPtrsignal_new_port.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true)); node->signal_removed_port.connect(sigc::hide_return(sigc::mem_fun(this, &NodeModule::remove_port))); - node->signal_variable.connect(sigc::mem_fun(this, &NodeModule::set_property)); node->signal_property.connect(sigc::mem_fun(this, &NodeModule::set_property)); node->signal_moved.connect(sigc::mem_fun(this, &NodeModule::rename)); } @@ -201,7 +200,7 @@ NodeModule::embed_gui(bool embed) for (NodeModel::Ports::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) if ((*p)->type().is_control() && (*p)->is_output()) - App::instance().engine()->set_variable((*p)->path(), "ingen:broadcast", true); + App::instance().engine()->set_property((*p)->path(), "ingen:broadcast", true); } } else { // un-embed @@ -211,7 +210,7 @@ NodeModule::embed_gui(bool embed) for (NodeModel::Ports::const_iterator p = _node->ports().begin(); p != _node->ports().end(); ++p) if ((*p)->type().is_control() && (*p)->is_output()) - App::instance().engine()->set_variable((*p)->path(), "ingen:broadcast", false); + App::instance().engine()->set_property((*p)->path(), "ingen:broadcast", false); } if (embed && _embed_item) { @@ -362,13 +361,13 @@ NodeModule::store_location() const float x = static_cast(property_x()); const float y = static_cast(property_y()); - const Atom& existing_x = _node->get_variable("ingenuity:canvas-x"); - const Atom& existing_y = _node->get_variable("ingenuity:canvas-y"); + const Atom& existing_x = _node->get_property("ingenuity:canvas-x"); + const Atom& existing_y = _node->get_property("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_variable(_node->path(), "ingenuity:canvas-x", Atom(x)); - App::instance().engine()->set_variable(_node->path(), "ingenuity:canvas-y", Atom(y)); + App::instance().engine()->set_property(_node->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_property(_node->path(), "ingenuity:canvas-y", Atom(y)); } } @@ -406,7 +405,7 @@ NodeModule::set_selected(bool b) if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_variable(_node->path(), "ingen:selected", b); + App::instance().engine()->set_property(_node->path(), "ingen:selected", b); } } diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index 6096ec7c..261cbd44 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -70,7 +70,7 @@ ObjectMenu::init(SharedPtr object) _properties_menuitem->signal_activate().connect( sigc::mem_fun(this, &ObjectMenu::on_menu_properties)); - object->signal_variable.connect(sigc::mem_fun(this, &ObjectMenu::variable_changed)); + object->signal_property.connect(sigc::mem_fun(this, &ObjectMenu::property_changed)); _enable_signal = true; } @@ -80,13 +80,13 @@ void ObjectMenu::on_menu_polyphonic() { if (_enable_signal) - App::instance().engine()->set_variable( + App::instance().engine()->set_property( _object->path(), "ingen:polyphonic", bool(_polyphonic_menuitem->get_active())); } void -ObjectMenu::variable_changed(const URI& predicate, const Atom& value) +ObjectMenu::property_changed(const URI& predicate, const Atom& value) { _enable_signal = false; if (predicate.str() == "ingen:polyphonic" && value.type() == Atom::BOOL) diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp index f39240d0..1a722581 100644 --- a/src/gui/ObjectMenu.hpp +++ b/src/gui/ObjectMenu.hpp @@ -44,13 +44,12 @@ public: void init(SharedPtr object); protected: - virtual void on_menu_disconnect() = 0; void on_menu_polyphonic(); void on_menu_destroy(); void on_menu_properties(); - void variable_changed(const Raul::URI& predicate, const Raul::Atom& value); + void property_changed(const Raul::URI& predicate, const Raul::Atom& value); bool _enable_signal; SharedPtr _object; diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 6bc9cbad..827a181b 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -490,27 +490,7 @@ PatchCanvas::connect(boost::shared_ptr src_port, // Midi binding/learn shortcut if (src->model()->type().is_event() && dst->model()->type().is_control()) { - cerr << "[PatchCanvas] FIXME: MIDI binding shortcut" << endl; -#if 0 - SharedPtr pm(new PluginModel(PluginModel::Internal, "", "midi_control_in", "")); - SharedPtr nm(new NodeModel(pm, _patch->path().base() - + src->name() + "-" + dst->name(), false)); - nm->set_variable("canvas-x", Atom((float) - (dst->module()->property_x() - dst->module()->width() - 20))); - nm->set_variable("canvas-y", Atom((float) - (dst->module()->property_y()))); - App::instance().engine()->create_node_from_model(nm.get()); - App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In"); - App::instance().engine()->connect(nm->path() + "/Out_(CR)", dst->model()->path()); - App::instance().engine()->midi_learn(nm->path()); - - // Set control node range to port's user range - - App::instance().engine()->set_port_value_queued(nm->path().base() + "Min", - dst->model()->get_variable("user-min").get_float()); - App::instance().engine()->set_port_value_queued(nm->path().base() + "Max", - dst->model()->get_variable("user-max").get_float()); -#endif + cerr << "[PatchCanvas] TODO: MIDI binding shortcut" << endl; } else { App::instance().engine()->connect(src->model()->path(), dst->model()->path()); } @@ -700,18 +680,18 @@ PatchCanvas::paste() //cout << "Skipping root" << endl; continue; } - GraphObject::Properties::iterator x = i->second->variables().find("ingenuity:canvas-x"); - if (x != i->second->variables().end()) + GraphObject::Properties::iterator x = i->second->properties().find("ingenuity:canvas-x"); + if (x != i->second->properties().end()) x->second = x->second.get_float() + (20.0f * _paste_count); - GraphObject::Properties::iterator y = i->second->variables().find("ingenuity:canvas-y"); - if (y != i->second->variables().end()) + GraphObject::Properties::iterator y = i->second->properties().find("ingenuity:canvas-y"); + if (y != i->second->properties().end()) y->second = y->second.get_float() + (20.0f * _paste_count); if (i->first.parent().is_root()) { - GraphObject::Properties::iterator s = i->second->variables().find("ingen:selected"); - if (s != i->second->variables().end()) + GraphObject::Properties::iterator s = i->second->properties().find("ingen:selected"); + if (s != i->second->properties().end()) s->second = true; else - i->second->variables().insert(make_pair("ingen:selected", true)); + i->second->properties().insert(make_pair("ingen:selected", true)); } builder.build(i->second); } diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 09b7dd4a..bdd93f63 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -48,7 +48,6 @@ PatchPortModule::PatchPortModule(boost::shared_ptr canvas, SharedPt set_stacked_border(model->polyphonic()); - model->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); model->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); } @@ -171,7 +170,7 @@ PatchPortModule::set_selected(bool b) if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_variable(_model->path(), "ingen:selected", b); + App::instance().engine()->set_property(_model->path(), "ingen:selected", b); } } diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp index efbbd78f..a7fb4495 100644 --- a/src/gui/PatchTreeWindow.cpp +++ b/src/gui/PatchTreeWindow.cpp @@ -111,8 +111,8 @@ PatchTreeWindow::add_patch(SharedPtr pm) } } - pm->signal_variable.connect(sigc::bind( - sigc::mem_fun(this, &PatchTreeWindow::patch_variable_changed), + pm->signal_property.connect(sigc::bind( + sigc::mem_fun(this, &PatchTreeWindow::patch_property_changed), pm->path())); pm->signal_destroyed.connect(sigc::bind( @@ -197,12 +197,12 @@ PatchTreeWindow::event_patch_enabled_toggled(const Glib::ustring& path_str) assert(pm); if (_enable_signal) - App::instance().engine()->set_variable(pm->path(), "ingen:enabled", (bool)!pm->enabled()); + App::instance().engine()->set_property(pm->path(), "ingen:enabled", (bool)!pm->enabled()); } void -PatchTreeWindow::patch_variable_changed(const URI& key, const Atom& value, const Path& path) +PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, const Path& path) { _enable_signal = false; if (key.str() == "ingen:enabled" && value.type() == Atom::BOOL) { diff --git a/src/gui/PatchTreeWindow.hpp b/src/gui/PatchTreeWindow.hpp index 915b11d4..0a71309c 100644 --- a/src/gui/PatchTreeWindow.hpp +++ b/src/gui/PatchTreeWindow.hpp @@ -46,7 +46,7 @@ public: void new_object(SharedPtr object); - void patch_variable_changed(const Raul::URI& key, const Raul::Atom& value, const Raul::Path& path); + void patch_property_changed(const Raul::URI& key, const Raul::Atom& value, const Raul::Path& path); void patch_moved(const Raul::Path& old_path, const Raul::Path& new_path); void add_patch(SharedPtr pm); diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index e0c97bcf..812c3115 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -90,7 +90,6 @@ PatchView::set_patch(SharedPtr patch) property_changed(i->first, i->second); // Connect model signals to track state - patch->signal_variable.connect(sigc::mem_fun(this, &PatchView::property_changed)); patch->signal_property.connect(sigc::mem_fun(this, &PatchView::property_changed)); // Connect widget signals to do things @@ -201,7 +200,7 @@ PatchView::process_toggled() if (!_enable_signal) return; - App::instance().engine()->set_variable(_patch->path(), "ingen:enabled", + App::instance().engine()->set_property(_patch->path(), "ingen:enabled", (bool)_process_but->get_active()); } @@ -209,7 +208,7 @@ PatchView::process_toggled() void PatchView::poly_changed() { - App::instance().engine()->set_property(_patch->path(), "ingen:polyphony", + App::instance().engine()->set_property(_patch->meta().uri(), "ingen:polyphony", _poly_spin->get_value_as_int()); } diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index d03f35ae..3984c9be 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -477,7 +477,7 @@ PatchWindow::event_save_as() if (confirm) { const Glib::ustring uri = Glib::filename_to_uri(filename); App::instance().loader()->save_patch(_patch, uri); - _patch->set_variable("ingen:document", Atom(uri.c_str())); + _patch->set_property("ingen:document", Atom(uri.c_str())); _status_bar->push( (boost::format("Wrote %1% to %2%") % _patch->path() % uri).str(), STATUS_CONTEXT_PATCH); diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 6283df86..ddefd0e2 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -69,7 +69,7 @@ Port::Port( set_control_min(min); set_control_max(max); - pm->signal_variable.connect(sigc::mem_fun(this, &Port::variable_changed)); + pm->signal_property.connect(sigc::mem_fun(this, &Port::property_changed)); pm->signal_value_changed.connect(sigc::mem_fun(this, &Port::value_changed)); } @@ -138,7 +138,7 @@ Port::set_control(float value, bool signal) void -Port::variable_changed(const URI& key, const Atom& value) +Port::property_changed(const URI& key, const Atom& value) { if (value.type() == Atom::FLOAT) { if ((key.str() == "lv2:minimum")) diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 763cfd7b..db511041 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -57,8 +57,7 @@ public: void activity(); private: - - void variable_changed(const Raul::URI& key, const Raul::Atom& value); + void property_changed(const Raul::URI& key, const Raul::Atom& value); void moved(); diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp index 425c5c08..045e8840 100644 --- a/src/gui/PortPropertiesWindow.cpp +++ b/src/gui/PortPropertiesWindow.cpp @@ -82,8 +82,8 @@ PortPropertiesWindow::present(SharedPtr pm) _connections.push_back(_max_spinner->signal_value_changed().connect( sigc::mem_fun(*this, &PortPropertiesWindow::max_changed))); - _connections.push_back(pm->signal_variable.connect( - sigc::mem_fun(this, &PortPropertiesWindow::variable_change))); + _connections.push_back(pm->signal_property.connect( + sigc::mem_fun(this, &PortPropertiesWindow::property_change))); //_enable_signal = true; @@ -92,7 +92,7 @@ PortPropertiesWindow::present(SharedPtr pm) void -PortPropertiesWindow::variable_change(const URI& key, const Atom& value) +PortPropertiesWindow::property_change(const URI& key, const Atom& value) { //_enable_signal = false; @@ -123,9 +123,6 @@ PortPropertiesWindow::min_changed() max = min + 1.0; _max_spinner->set_value(max); } - - //if (_enable_signal) - // App::instance().engine()->set_variable(_port_model->path(), "lv2:minimum", min); } @@ -145,9 +142,6 @@ PortPropertiesWindow::max_changed() min = max - 1.0; _min_spinner->set_value(min); } - - //if (_enable_signal) - // App::instance().engine()->set_variable(_port_model->path(), "lv2:maximum", max); } @@ -164,8 +158,8 @@ PortPropertiesWindow::ok() const float min = _min_spinner->get_value(); const float max = _max_spinner->get_value(); - App::instance().engine()->set_variable(_port_model->path(), "lv2:minimum", min); - App::instance().engine()->set_variable(_port_model->path(), "lv2:maximum", max); + App::instance().engine()->set_property(_port_model->meta().uri(), "lv2:minimum", min); + App::instance().engine()->set_property(_port_model->meta().uri(), "lv2:maximum", max); hide(); } diff --git a/src/gui/PortPropertiesWindow.hpp b/src/gui/PortPropertiesWindow.hpp index e49e2f10..a9bfbc33 100644 --- a/src/gui/PortPropertiesWindow.hpp +++ b/src/gui/PortPropertiesWindow.hpp @@ -41,7 +41,7 @@ public: void present(SharedPtr port_model); private: - void variable_change(const Raul::URI& key, const Raul::Atom& value); + void property_change(const Raul::URI& key, const Raul::Atom& value); void min_changed(); void max_changed(); diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 3b1e2d47..d1e16664 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -158,7 +158,7 @@ Parser::parse_document( = parse(world, target, model, document_uri, data_path, parent, symbol, data); if (parsed_path) { - target->set_variable(*parsed_path, "ingen:document", Atom(document_uri.c_str())); + target->set_property(*parsed_path, "ingen:document", Atom(document_uri.c_str())); } else { cerr << "WARNING: document URI lost" << endl; } @@ -218,22 +218,20 @@ Parser::parse_update( // Variable settings query = Redland::Query(*world->rdf_world, - "SELECT DISTINCT ?path ?varkey ?varval WHERE {\n" - "?path lv2var:variable ?variable .\n" - "?variable rdf:predicate ?varkey ;\n" - " rdf:value ?varval .\n" + "SELECT DISTINCT ?s ?p ?o WHERE {\n" + "?s ?p ?o .\n" "}"); results = Redland::Query::Results(query.run(*world->rdf_world, model, base_uri)); for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Glib::Mutex::Lock lock(world->rdf_world->mutex()); - const string obj_path = (*i)["path"].to_string(); - const string key = world->rdf_world->prefixes().qualify((*i)["varkey"].to_string()); - const Redland::Node& val_node = (*i)["varval"]; - const Atom a(AtomRDF::node_to_atom(val_node)); + const string obj_uri((*i)["s"].to_string()); + const string key(world->rdf_world->prefixes().qualify((*i)["p"].to_string())); + const Redland::Node& val_node((*i)["o"]); + const Atom a(AtomRDF::node_to_atom(val_node)); if (key != "") - target->set_variable(obj_path, key, a); + target->set_property(obj_uri, key, a); } @@ -514,7 +512,7 @@ Parser::parse_patch( Glib::Mutex::Lock lock(world->rdf_world->mutex()); for (Properties::iterator j = i->second.begin(); j != i->second.end(); ++j) { const string key = world->rdf_world->prefixes().qualify(j->first); - target->set_variable(node_path, key, AtomRDF::node_to_atom(j->second)); + target->set_property(node_path, key, AtomRDF::node_to_atom(j->second)); } } @@ -531,7 +529,7 @@ Parser::parse_patch( Glib::Mutex::Lock lock(world->rdf_world->mutex()); for (Properties::iterator j = i->second.begin(); j != i->second.end(); ++j) { const string key = world->rdf_world->prefixes().qualify(j->first); - target->set_variable(node_path, key, AtomRDF::node_to_atom(j->second)); + target->set_property(node_path, key, AtomRDF::node_to_atom(j->second)); } } @@ -560,7 +558,7 @@ Parser::parse_patch( if (key == "ingen:value") { target->set_port_value(port_path, AtomRDF::node_to_atom((*i)["val"])); } else { - target->set_variable(port_path, key, AtomRDF::node_to_atom((*i)["val"])); + target->set_property(port_path, key, AtomRDF::node_to_atom((*i)["val"])); } } @@ -637,7 +635,7 @@ Parser::parse_patch( } parse_connections(world, target, model, subject, "/"); - parse_variables(world, target, model, subject_node, patch_path, data); + parse_properties(world, target, model, subject_node, patch_path, data); /* Enable */ @@ -651,7 +649,7 @@ Parser::parse_patch( Glib::Mutex::Lock lock(world->rdf_world->mutex()); const Redland::Node& enabled_node = (*i)["enabled"]; if (enabled_node.is_bool() && enabled_node) { - target->set_variable(patch_path, "ingen:enabled", (bool)true); + target->set_property(patch_path, "ingen:enabled", (bool)true); break; } else { cerr << "WARNING: Unknown type for ingen:enabled" << endl; @@ -696,7 +694,7 @@ Parser::parse_node( props.insert(make_pair("rdf:instanceOf", Raul::Atom(Raul::Atom::URI, plugin_uri))); target->put(path, props); - parse_variables(world, target, model, subject, path, data); + parse_properties(world, target, model, subject, path, data); return path; } @@ -737,7 +735,7 @@ Parser::parse_port( target->set_port_value(path, AtomRDF::node_to_atom(val_node)); } - parse_variables(world, target, model, subject_node, path, data); + parse_properties(world, target, model, subject_node, path, data); return path; #endif cerr << "PARSE PORT" << endl; @@ -780,7 +778,7 @@ Parser::parse_connections( bool -Parser::parse_variables( +Parser::parse_properties( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, Redland::Model& model, @@ -801,14 +799,14 @@ Parser::parse_variables( const string key = world->rdf_world->prefixes().qualify(string((*i)["key"])); const Redland::Node& val = (*i)["val"]; if (key != "") - target->set_variable(path, key, AtomRDF::node_to_atom(val)); + target->set_property(path, key, AtomRDF::node_to_atom(val)); } - // Set passed variables last to override any loaded values + // Set passed properties last to override any loaded values if (data) for (GraphObject::Properties::const_iterator i = data.get().begin(); i != data.get().end(); ++i) - target->set_variable(path, i->first, i->second); + target->set_property(path, i->first, i->second); return true; } diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index 61281339..b980a4fc 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -103,7 +103,7 @@ private: const Raul::Path& path, boost::optional data=boost::optional()); - bool parse_variables( + bool parse_properties( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, Redland::Model& model, diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index ac18455e..231d19fa 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -316,7 +316,7 @@ Serialiser::serialise_patch(SharedPtr patch, const Redland::Node& cerr << "WARNING: Patch has no lv2:symbol" << endl; } - serialise_properties(patch_id, patch->properties()); + serialise_meta_properties(patch_id, patch->properties()); for (GraphObject::const_iterator n = _store->children_begin(patch); n != _store->children_end(patch); ++n) { @@ -354,7 +354,7 @@ Serialiser::serialise_patch(SharedPtr patch, const Redland::Node& p->set_property("lv2:name", Atom(Atom::STRING, p->symbol())); _model->add_statement(patch_id, "lv2:port", port_id); - serialise_port_class(p, port_id); + serialise_port_meta(p, port_id); } for (Shared::Patch::Connections::const_iterator c = patch->connections().begin(); @@ -394,7 +394,7 @@ Serialiser::serialise_node(SharedPtr node, _model->add_statement(node_id, "lv2:port", port_id); } - serialise_variables(node_id, node->variables()); + serialise_properties(node_id, node->properties()); } @@ -420,13 +420,13 @@ Serialiser::serialise_port(const Port* port, const Redland::Node& port_id) _model->add_statement(port_id, "ingen:value", AtomRDF::atom_to_node(_model->world(), Atom(port->value()))); - serialise_variables(port_id, port->variables()); + serialise_properties(port_id, port->properties()); } /** Serialise a port on a Patch */ void -Serialiser::serialise_port_class(const Port* port, const Redland::Node& port_id) +Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id) { if (port->is_input()) _model->add_statement(port_id, "rdf:type", @@ -452,7 +452,7 @@ Serialiser::serialise_port_class(const Port* port, const Redland::Node& port_id) } } - serialise_properties(port_id, port->properties()); + serialise_meta_properties(port_id, port->properties()); } @@ -480,7 +480,9 @@ Serialiser::serialise_connection(SharedPtr parent, void -Serialiser::serialise_properties(Redland::Node subject, const GraphObject::Properties& properties) +Serialiser::serialise_meta_properties( + Redland::Node subject, + const GraphObject::Properties& properties) { for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) { if (v->first.find(":") && v->second.is_valid()) { @@ -494,9 +496,11 @@ Serialiser::serialise_properties(Redland::Node subject, const GraphObject::Prope void -Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Properties& variables) +Serialiser::serialise_properties( + Redland::Node subject, + const GraphObject::Properties& properties) { - for (GraphObject::Properties::const_iterator v = variables.begin(); v != variables.end(); ++v) { + for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) { if (v->first.find(":") && v->first.str() != "ingen:document") { if (v->second.is_valid()) { const Redland::Resource key(_model->world(), v->first.str()); diff --git a/src/serialisation/Serialiser.hpp b/src/serialisation/Serialiser.hpp index 6ecfec46..4264f05e 100644 --- a/src/serialisation/Serialiser.hpp +++ b/src/serialisation/Serialiser.hpp @@ -97,10 +97,10 @@ private: void serialise_node(SharedPtr n, const Redland::Node& class_id, const Redland::Node& id); void serialise_port(const Shared::Port* p, const Redland::Node& id); - void serialise_port_class(const Shared::Port* p, const Redland::Node& id); + void serialise_port_meta(const Shared::Port* p, const Redland::Node& id); - void serialise_properties(Redland::Node subject, const Properties& properties); - void serialise_variables(Redland::Node subject, const Properties& variables); + void serialise_meta_properties(Redland::Node subject, const Properties& properties); + void serialise_properties(Redland::Node subject, const Properties& variables); Redland::Node instance_rdf_node(const Raul::Path& path); Redland::Node class_rdf_node(const Raul::Path& path); diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index ba26d962..37c193fb 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -93,16 +93,12 @@ Builder::connect(SharedPtr object) void Builder::build_object(SharedPtr object) { - for (GraphObject::Properties::const_iterator i = object->variables().begin(); - i != object->variables().end(); ++i) - _interface.set_variable(object->path(), i->first, i->second); - - for (GraphObject::Properties::const_iterator i = object->properties().begin(); - i != object->properties().end(); ++i) { - if (object->path().is_root()) - continue; + typedef GraphObject::Properties::const_iterator iterator; + iterator i = object->meta().properties().begin(); + for (; i != object->meta().properties().end(); ++i) + _interface.set_property(object->meta().uri(), i->first, i->second); + for (i = object->properties().begin(); i != object->properties().end(); ++i) _interface.set_property(object->path(), i->first, i->second); - } } diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp index c7e08269..408f303a 100644 --- a/src/shared/ClashAvoider.cpp +++ b/src/shared/ClashAvoider.cpp @@ -143,10 +143,10 @@ ClashAvoider::exists(const Raul::Path& path) const void -ClashAvoider::put(const Raul::Path& path, +ClashAvoider::put(const Raul::URI& path, const Shared::Resource::Properties& properties) { - _target.put(map_path(path), properties); + _target.put(map_uri(path), properties); } @@ -175,20 +175,11 @@ ClashAvoider::disconnect(const Raul::Path& src_port_path, void -ClashAvoider::set_variable(const Raul::URI& subject_path, +ClashAvoider::set_property(const Raul::URI& subject, const Raul::URI& predicate, const Raul::Atom& value) { - _target.set_variable(map_uri(subject_path), predicate, value); -} - - -void -ClashAvoider::set_property(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value) -{ - _target.set_property(map_uri(subject_path), predicate, value); + _target.set_property(map_uri(subject), predicate, value); } diff --git a/src/shared/ClashAvoider.hpp b/src/shared/ClashAvoider.hpp index 2fc4b13b..81c21f45 100644 --- a/src/shared/ClashAvoider.hpp +++ b/src/shared/ClashAvoider.hpp @@ -48,7 +48,7 @@ public: // Object commands - virtual void put(const Raul::Path& path, + virtual void put(const Raul::URI& path, const Resource::Properties& properties); virtual void move(const Raul::Path& old_path, @@ -60,10 +60,6 @@ public: virtual void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - virtual void set_variable(const Raul::URI& subject_path, - const Raul::URI& predicate, - const Raul::Atom& value); - virtual void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 27a33e07..69d294a4 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -25,6 +25,13 @@ namespace Ingen { namespace Shared { +const Raul::URI +ResourceImpl::meta_uri(const Raul::URI& base, const Raul::URI& uri) +{ + return string("#") + uri.chop_start("/"); +} + + void ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value) { diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index b436ddc9..1f8dbedd 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -32,7 +32,7 @@ class ResourceImpl : virtual public Resource public: ResourceImpl(const Raul::URI& uri) : _uri(uri) {} - virtual const Raul::URI uri() const { return _uri.str(); } + virtual const Raul::URI uri() const { return _uri.str(); } const Properties& properties() const { return _properties; } Properties& properties() { return _properties; } @@ -40,6 +40,9 @@ public: const Raul::Atom& get_property(const Raul::URI& uri) const; void set_property(const Raul::URI& uri, const Raul::Atom& value); void add_property(const Raul::URI& uri, const Raul::Atom& value); + void merge_properties(const Properties& p); + + sigc::signal signal_property; /** Get the ingen type from a set of Properties. * If some coherent ingen type is found, true is returned and the appropriate @@ -51,9 +54,7 @@ public: bool& node, bool& port, bool& is_output, DataType& data_type); - void merge_properties(const Properties& p); - - sigc::signal signal_property; + static const Raul::URI meta_uri(const Raul::URI& base, const Raul::URI& uri); private: Raul::URI _uri; -- cgit v1.2.1