From c11ecf0fd10641218326ae384e80413ba3cdf46c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 27 May 2009 17:42:51 +0000 Subject: Remove 'new_patch', 'new_node', and 'new_port' from interface in favour of generic 'put'. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2011 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientStore.cpp | 108 ++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 60 deletions(-) (limited to 'src/client/ClientStore.cpp') diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 64b6ae09..c28bdca0 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -45,11 +45,8 @@ ClientStore::ClientStore(SharedPtr engine, SharedPtrsignal_object_destroyed.connect(sigc::mem_fun(this, &ClientStore::destroy)); emitter->signal_object_renamed.connect(sigc::mem_fun(this, &ClientStore::rename)); - emitter->signal_new_object.connect(sigc::mem_fun(this, &ClientStore::new_object)); emitter->signal_new_plugin.connect(sigc::mem_fun(this, &ClientStore::new_plugin)); - emitter->signal_new_patch.connect(sigc::mem_fun(this, &ClientStore::new_patch)); - emitter->signal_new_node.connect(sigc::mem_fun(this, &ClientStore::new_node)); - emitter->signal_new_port.connect(sigc::mem_fun(this, &ClientStore::new_port)); + emitter->signal_put.connect(sigc::mem_fun(this, &ClientStore::put)); emitter->signal_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)); @@ -78,7 +75,6 @@ ClientStore::add_object(SharedPtr object) if (existing != end()) { PtrCast(existing->second)->set(object); } else { - if (!object->path().is_root()) { SharedPtr parent = this->object(object->path().parent()); if (parent) { @@ -271,68 +267,60 @@ ClientStore::new_plugin(const URI& uri, const URI& type_uri, const Symbol& symbo } -bool -ClientStore::new_object(const Shared::GraphObject* object) -{ - using namespace Shared; - - const Patch* patch = dynamic_cast(object); - if (patch) { - new_patch(patch->path(), patch->internal_polyphony()); - return true; - } - - const Node* node = dynamic_cast(object); - if (node) { - new_node(node->path(), node->plugin()->uri()); - return true; - } - - const Port* port = dynamic_cast(object); - if (port) { - new_port(port->path(), port->type().uri(), port->index(), !port->is_input()); - return true; - } - - return false; -} - - void -ClientStore::new_patch(const Path& path, uint32_t poly) +ClientStore::put(const Path& path, const Resource::Properties& properties) { - SharedPtr p(new PatchModel(path, poly)); - add_object(p); -} - - -void -ClientStore::new_node(const Path& path, const URI& plugin_uri) -{ - SharedPtr plug = plugin(plugin_uri); - if (!plug) { - SharedPtr n(new NodeModel(plugin_uri, path)); - //add_plugin_orphan(n); - add_object(n); + typedef Resource::Properties::const_iterator iterator; + cerr << "CLIENT PUT " << path << " {" << endl; + for (iterator i = properties.begin(); i != properties.end(); ++i) + cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; + cerr << "}" << endl; + + bool is_patch, is_node, is_port, is_output; + DataType data_type(DataType::UNKNOWN); + ResourceImpl::type(properties, is_patch, is_node, is_port, is_output, data_type); + + if (is_patch) { + uint32_t poly = 1; + iterator p = properties.find("ingen:polyphony"); + if (p != properties.end() && p->second.is_valid() && p->second.type() == Atom::INT) + poly = p->second.get_int32(); + SharedPtr model(new PatchModel(path, poly)); + model->merge_properties(properties); + add_object(model); + } else if (is_node) { + const Resource::Properties::const_iterator p = properties.find("rdf:instanceOf"); + SharedPtr plug; + if (p->second.is_valid() && p->second.type() == Atom::URI) { + if ((plug = plugin(p->second.get_uri()))) { + SharedPtr n(new NodeModel(plug, path)); + n->merge_properties(properties); + add_object(n); + } else { + SharedPtr n(new NodeModel(p->second.get_uri(), path)); + n->merge_properties(properties); + //add_plugin_orphan(n); + add_object(n); + } + } else { + cerr << "ERROR: Plugin with no type" << endl; + } + } else if (is_port) { + if (data_type != DataType::UNKNOWN) { + PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; + SharedPtr p(new PortModel(path, 0, data_type, pdir)); + p->merge_properties(properties); + add_object(p); + } else { + cerr << "WARNING: Illegal port " << path << endl; + } } else { - SharedPtr n(new NodeModel(plug, path)); - add_object(n); + cerr << "WARNING: Ignoring object " << path << " with unknown type " + << is_patch << " " << is_node << " " << is_port << endl; } } -void -ClientStore::new_port(const Path& path, const URI& type, uint32_t index, bool is_output) -{ - PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT; - - SharedPtr p(new PortModel(path, index, type, pdir)); - add_object(p); - /*if (p->parent()) - resolve_connection_orphans(p);*/ -} - - void ClientStore::clear_patch(const Path& path) { -- cgit v1.2.1