From 698c38587bd4f0133a132dc363098ff8298ec47b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 11 May 2009 18:05:24 +0000 Subject: * New ontology. * Display human names on patch ports on creation, if enabled. * Fix copy/paste of subpatches. * Split properties into "properties" (class properties) and "variables" (instance properties). * Names are kind of a legacy leftover... * Remove special set poly / enable / etc events in favour of just setting properties (less API, extensible, RDF compatible). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1973 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/DeprecatedLoader.cpp | 28 ++++++++++++++-------------- src/client/DeprecatedLoader.hpp | 4 ++-- src/client/ObjectModel.cpp | 22 +++++++++++----------- src/client/ObjectModel.hpp | 6 +++--- src/client/PatchModel.cpp | 9 +++++---- src/client/PatchModel.hpp | 2 +- 6 files changed, 36 insertions(+), 35 deletions(-) (limited to 'src/client') diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp index 794816bb..ac693421 100644 --- a/src/client/DeprecatedLoader.cpp +++ b/src/client/DeprecatedLoader.cpp @@ -140,12 +140,12 @@ DeprecatedLoader::translate_load_path(const string& path) } -/** Add a piece of data to a Variables, translating from deprecated unqualified keys +/** Add a piece of data to a Properties, translating from deprecated unqualified keys * * Adds a namespace prefix for known keys, and ignores the rest. */ void -DeprecatedLoader::add_variable(GraphObject::Variables& data, string old_key, string value) +DeprecatedLoader::add_variable(GraphObject::Properties& data, string old_key, string value) { string key = ""; if (old_key == "module-x") @@ -207,7 +207,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, bool merge, boost::optional parent_path, boost::optional name, - GraphObject::Variables initial_data, + GraphObject::Properties initial_data, bool existing) { cerr << "[DeprecatedLoader] Loading patch " << filename << " under " @@ -222,7 +222,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, size_t poly = 0; /* Use parameter overridden polyphony, if given */ - GraphObject::Variables::iterator poly_param = initial_data.find("ingen:polyphony"); + GraphObject::Properties::iterator poly_param = initial_data.find("ingen:polyphony"); if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT) poly = poly_param->second.get_int32(); @@ -291,7 +291,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, // Create it, if we're not merging if (!existing && path != "/") { _engine->new_patch(path, poly); - for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_variable(path, i->first, i->second); } @@ -346,11 +346,11 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, xmlCleanupParser(); // Done above.. late enough? - //for (Variables::const_iterator i = data.begin(); i != data.end(); ++i) + //for (Properties::const_iterator i = data.begin(); i != data.end(); ++i) // _engine->set_variable(subject, i->first, i->second); if (!existing) - _engine->set_property(path, "ingen:enabled", (bool)true); + _engine->set_variable(path, "ingen:enabled", (bool)true); _load_path_translations.clear(); @@ -375,7 +375,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr string library_name; // deprecated string plugin_label; // deprecated - GraphObject::Variables initial_data; + GraphObject::Properties initial_data; while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); @@ -489,7 +489,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr path = new_path; - for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_variable(path, i->first, i->second); return SharedPtr(); @@ -510,9 +510,9 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr else _engine->new_node_deprecated(path, plugin_type, library_name, plugin_label); - _engine->set_property(path, "ingen:polyphonic", polyphonic); + _engine->set_variable(path, "ingen:polyphonic", bool(polyphonic)); - for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + for (GraphObject::Properties::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) _engine->set_variable(path, i->first, i->second); return true; @@ -521,8 +521,8 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr // Not deprecated } else { _engine->new_node(path, plugin_uri); - _engine->set_property(path, "ingen:polyphonic", polyphonic); - for (GraphObject::Variables::const_iterator i = initial_data.begin(); i != initial_data.end(); ++i) + _engine->set_variable(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); return true; } @@ -541,7 +541,7 @@ DeprecatedLoader::load_subpatch(const string& base_filename, const Path& parent, string filename = ""; size_t poly = 0; - GraphObject::Variables initial_data; + GraphObject::Properties initial_data; while (cur != NULL) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); diff --git a/src/client/DeprecatedLoader.hpp b/src/client/DeprecatedLoader.hpp index 37d31f3f..dd391ca1 100644 --- a/src/client/DeprecatedLoader.hpp +++ b/src/client/DeprecatedLoader.hpp @@ -67,11 +67,11 @@ public: bool merge, boost::optional parent_path, boost::optional name, - GraphObject::Variables initial_data, + GraphObject::Properties initial_data, bool existing = false); private: - void add_variable(GraphObject::Variables& data, string key, string value); + void add_variable(GraphObject::Properties& data, string key, string value); string nameify_if_invalid(const string& name); string translate_load_path(const string& path); diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 80460547..f5972af5 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -47,7 +47,7 @@ ObjectModel::get_variable(const string& key) const { static const Atom null_atom; - Variables::const_iterator i = _variables.find(key); + Properties::const_iterator i = _variables.find(key); if (i != _variables.end()) return i->second; else @@ -64,7 +64,7 @@ ObjectModel::get_variable( string& key) { static Atom null_atom; - Variables::iterator i = _variables.find(key); + Properties::iterator i = _variables.find(key); if (i != _variables.end()) return i->second; else @@ -75,7 +75,7 @@ ObjectModel::get_variable( string& key) bool ObjectModel::polyphonic() const { - const Raul::Atom& polyphonic = get_property("ingen:polyphonic"); + const Raul::Atom& polyphonic = get_variable("ingen:polyphonic"); return (polyphonic.is_valid() && polyphonic.get_bool()); } @@ -91,14 +91,6 @@ ObjectModel::set(SharedPtr o) assert(_path == o->path()); if (o->_parent) _parent = o->_parent; - - for (Variables::const_iterator v = o->variables().begin(); v != o->variables().end(); ++v) { - Variables::const_iterator mine = _variables.find(v->first); - if (mine != _variables.end()) - cerr << "WARNING: " << _path << "Client/Server variable mismatch: " << v->first << endl; - _variables[v->first] = v->second; - signal_variable.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); @@ -107,6 +99,14 @@ ObjectModel::set(SharedPtr o) 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[v->first] = v->second; + signal_variable.emit(v->first, v->second); + } } diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index f1850d94..4d02e546 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -70,8 +70,8 @@ public: virtual void set_variable(const string& key, const Atom& value) { _variables[key] = value; signal_variable.emit(key, value); } - const Variables& variables() const { return _variables; } - Variables& variables() { return _variables; } + const Properties& variables() const { return _variables; } + Properties& variables() { return _variables; } const Path path() const { return _path; } const Symbol symbol() const { return _path.name(); } SharedPtr parent() const { return _parent; } @@ -102,7 +102,7 @@ protected: Path _path; SharedPtr _parent; - Variables _variables; + Properties _variables; }; diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index c27ff718..980a902c 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -163,14 +163,15 @@ PatchModel::remove_connection(const string& src_port_path, const string& dst_por bool PatchModel::enabled() const { - const Raul::Atom& enabled = get_property("ingen:enabled"); + const Raul::Atom& enabled = get_variable("ingen:enabled"); return (enabled.is_valid() && enabled.get_bool()); } - + + void -PatchModel::set_property(const std::string& key, const Atom& value) +PatchModel::set_variable(const std::string& key, const Atom& value) { - ResourceImpl::set_property(key, value); + NodeModel::set_variable(key, value); if (key == "ingen:polyphony") _poly = value.get_int32(); } diff --git a/src/client/PatchModel.hpp b/src/client/PatchModel.hpp index 35b11e15..4a8b3ee7 100644 --- a/src/client/PatchModel.hpp +++ b/src/client/PatchModel.hpp @@ -63,7 +63,7 @@ public: signal_editable.emit(e); } } - virtual void set_property(const string& key, const Atom& value); + virtual void set_variable(const string& key, const Atom& value); // Signals sigc::signal > signal_new_node; -- cgit v1.2.1