From 55fb6e1bb15ca16f551162e9d081ad395c346b43 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 1 Nov 2018 14:02:35 +0000 Subject: [PATCH] AudioProcessorGraph: Allow extracting nodes --- .../processors/juce_AudioProcessorGraph.cpp | 13 +++++++------ .../processors/juce_AudioProcessorGraph.h | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp index 82d922262a..7d2ac0047d 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.cpp @@ -961,31 +961,32 @@ AudioProcessorGraph::Node::Ptr AudioProcessorGraph::addNode (std::unique_ptr AudioProcessorGraph::removeNode (NodeID nodeId) { const ScopedLock sl (getCallbackLock()); for (int i = nodes.size(); --i >= 0;) { - if (nodes.getUnchecked(i)->nodeID == nodeId) + if (nodes.getUnchecked (i)->nodeID == nodeId) { disconnectNode (nodeId); + auto internalProcessor = nodes[i] != nullptr ? std::move (nodes[i]->processor) : nullptr; nodes.remove (i); topologyChanged(); - return true; + return internalProcessor; } } - return false; + return nullptr; } -bool AudioProcessorGraph::removeNode (Node* node) +std::unique_ptr AudioProcessorGraph::removeNode (Node* node) { if (node != nullptr) return removeNode (node->nodeID); jassertfalse; - return false; + return nullptr; } //============================================================================== diff --git a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h index bf669dbc5c..93b2d75a41 100644 --- a/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h +++ b/modules/juce_audio_processors/processors/juce_AudioProcessorGraph.h @@ -135,7 +135,7 @@ public: bool operator== (const Connection&) const noexcept; }; - const std::unique_ptr processor; + std::unique_ptr processor; Array inputs, outputs; bool isPrepared = false; std::atomic bypassed { false }; @@ -231,12 +231,12 @@ public: /** Deletes a node within the graph which has the specified ID. This will also delete any connections that are attached to this node. */ - bool removeNode (NodeID); + std::unique_ptr removeNode (NodeID); /** Deletes a node within the graph. This will also delete any connections that are attached to this node. */ - bool removeNode (Node*); + std::unique_ptr removeNode (Node*); /** Returns the list of connections in the graph. */ std::vector getConnections() const;