diff options
author | David Robillard <d@drobilla.net> | 2007-03-12 18:13:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-03-12 18:13:03 +0000 |
commit | 47372f00cc6fe39f65594aa6edf6544157e94ce7 (patch) | |
tree | e1c7a9b1b3d6fe07631a05f3410ea2fa4b21e193 /src/PatchageFlowCanvas.cpp | |
parent | 2834b233eedf0c66f65ac8169264d8359d8fc7c6 (diff) | |
download | patchage-47372f00cc6fe39f65594aa6edf6544157e94ce7.tar.gz patchage-47372f00cc6fe39f65594aa6edf6544157e94ce7.tar.bz2 patchage-47372f00cc6fe39f65594aa6edf6544157e94ce7.zip |
Removed name-based interface for FlowCanvas (using the view as a model = evil), related performance improvements (especially for Machina).
Updates for FlowCanvas API changes.
Machina SMF import performance improvements (temporarily disabled node labels).
git-svn-id: http://svn.drobilla.net/lad/patchage@356 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchageFlowCanvas.cpp')
-rw-r--r-- | src/PatchageFlowCanvas.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/PatchageFlowCanvas.cpp b/src/PatchageFlowCanvas.cpp index bdb5c0a..042d259 100644 --- a/src/PatchageFlowCanvas.cpp +++ b/src/PatchageFlowCanvas.cpp @@ -33,11 +33,24 @@ PatchageFlowCanvas::PatchageFlowCanvas(Patchage* app, int width, int height) } +boost::shared_ptr<Item> +PatchageFlowCanvas::get_item(const string& name) +{ + ItemList::iterator m = _items.begin(); + + for ( ; m != _items.end(); ++m) + if ((*m)->name() == name) + break; + + return (m == _items.end()) ? boost::shared_ptr<Item>() : *m; +} + + boost::shared_ptr<PatchageModule> PatchageFlowCanvas::find_module(const string& name, ModuleType type) { - for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) { - boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>((*m).second); + for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) { + boost::shared_ptr<PatchageModule> pm = boost::dynamic_pointer_cast<PatchageModule>(*m); if (pm && pm->name() == name && pm->type() == type) { return pm; } @@ -52,8 +65,8 @@ boost::shared_ptr<PatchagePort> PatchageFlowCanvas::find_port(const snd_seq_addr_t* alsa_addr) { boost::shared_ptr<PatchagePort> pp; - for (ItemMap::iterator m = _items.begin(); m != _items.end(); ++m) { - SharedPtr<Module> module = PtrCast<Module>(m->second); + for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) { + SharedPtr<Module> module = PtrCast<Module>(*m); if (!module) continue; for (PortVector::const_iterator p = module->ports().begin(); p != module->ports().end(); ++p) { @@ -130,3 +143,21 @@ PatchageFlowCanvas::status_message(const string& msg) _app->status_message(string("[Canvas] ").append(msg)); } + +boost::shared_ptr<Port> +PatchageFlowCanvas::get_port(const string& node_name, const string& port_name) +{ + for (ItemList::iterator i = _items.begin(); i != _items.end(); ++i) { + const boost::shared_ptr<Item> item = *i; + const boost::shared_ptr<Module> module + = boost::dynamic_pointer_cast<Module>(item); + if (!module) + continue; + const boost::shared_ptr<Port> port = module->get_port(port_name); + if (module->name() == node_name && port) + return port; + } + + return boost::shared_ptr<Port>(); +} + |