From a9bea6c1d981d6bc53817fce6db4c9bc0f1e1e62 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 4 Dec 2011 07:25:09 +0000 Subject: Move module ports down to C level. Add STL-style port iteration API to Module. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3795 a436a847-0d15-0410-975c-d299462d15a1 --- src/PatchageCanvas.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/PatchageCanvas.cpp') diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 36b207d..d20add5 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -132,6 +132,16 @@ struct RemovePortsData { std::set empty; }; +static void +delete_port_if_matches(FlowCanvasPort* port, void* cdata) +{ + RemovePortsData* data = (RemovePortsData*)cdata; + PatchagePort* pport = dynamic_cast(Glib::wrap(port)); + if (pport && data->pred(pport)) { + delete pport; + } +} + static void remove_ports_matching(FlowCanvasNode* node, void* cdata) { @@ -146,14 +156,8 @@ remove_ports_matching(FlowCanvasNode* node, void* cdata) } RemovePortsData* data = (RemovePortsData*)cdata; - - FlowCanvas::Module::Ports ports = pmodule->ports(); // copy - for (FlowCanvas::Module::Ports::iterator p = ports.begin(); - p != ports.end(); ++p) { - if (data->pred(dynamic_cast(*p))) { - delete *p; - } - } + + pmodule->for_each_port(delete_port_if_matches, data); if (pmodule->num_ports() == 0) { data->empty.insert(pmodule); -- cgit v1.2.1