summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events/DisconnectNodeEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-06-10 17:41:26 +0000
committerDavid Robillard <d@drobilla.net>2008-06-10 17:41:26 +0000
commit6ed65a4a3b14d204a24ab63fa907f8e9adce01dc (patch)
tree52ec9bafe242c976b70f8422f1a33f9e78d9ab16 /src/libs/engine/events/DisconnectNodeEvent.cpp
parent43dc73756cf97b4e4bc2ebdec59f3cb15f99750b (diff)
downloadingen-6ed65a4a3b14d204a24ab63fa907f8e9adce01dc.tar.gz
ingen-6ed65a4a3b14d204a24ab63fa907f8e9adce01dc.tar.bz2
ingen-6ed65a4a3b14d204a24ab63fa907f8e9adce01dc.zip
Fix 'disconnect' operation for all objects (inc. patch ports).
Fixes ticket #147. git-svn-id: http://svn.drobilla.net/lad/ingen@1265 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events/DisconnectNodeEvent.cpp')
-rw-r--r--src/libs/engine/events/DisconnectNodeEvent.cpp135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp
deleted file mode 100644
index 4fa92af0..00000000
--- a/src/libs/engine/events/DisconnectNodeEvent.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <raul/Array.hpp>
-#include <raul/List.hpp>
-#include <raul/Maid.hpp>
-#include <raul/Path.hpp>
-#include "ClientBroadcaster.hpp"
-#include "ConnectionImpl.hpp"
-#include "DisconnectNodeEvent.hpp"
-#include "DisconnectionEvent.hpp"
-#include "Engine.hpp"
-#include "InputPort.hpp"
-#include "NodeImpl.hpp"
-#include "ObjectStore.hpp"
-#include "OutputPort.hpp"
-#include "PatchImpl.hpp"
-#include "PortImpl.hpp"
-#include "Responder.hpp"
-#include "util.hpp"
-
-namespace Ingen {
-
-
-DisconnectNodeEvent::DisconnectNodeEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path)
-: QueuedEvent(engine, responder, timestamp),
- _node_path(node_path),
- _patch(NULL),
- _node(NULL),
- _succeeded(true),
- _lookup(true)
-{
-}
-
-
-/** Internal version, disconnects parent port as well (in the case of InputNode, etc).
- */
-DisconnectNodeEvent::DisconnectNodeEvent(Engine& engine, NodeImpl* node)
-: QueuedEvent(engine),
- _node_path(node->path()),
- _patch(node->parent_patch()),
- _node(node),
- _succeeded(true),
- _lookup(false)
-{
-}
-
-
-DisconnectNodeEvent::~DisconnectNodeEvent()
-{
- for (Raul::List<DisconnectionEvent*>::iterator i = _disconnection_events.begin(); i != _disconnection_events.end(); ++i)
- delete (*i);
-}
-
-
-void
-DisconnectNodeEvent::pre_process()
-{
- if (_lookup) {
- _patch = _engine.object_store()->find_patch(_node_path.parent());
-
- if (_patch == NULL) {
- _succeeded = false;
- QueuedEvent::pre_process();
- return;
- }
-
- _node = _engine.object_store()->find_node(_node_path);
-
- if (_node == NULL) {
- _succeeded = false;
- QueuedEvent::pre_process();
- return;
- }
- }
-
- for (PatchImpl::Connections::const_iterator i = _patch->connections().begin(); i != _patch->connections().end(); ++i) {
- ConnectionImpl* c = (ConnectionImpl*)i->get();
- if ((c->src_port()->parent_node() == _node || c->dst_port()->parent_node() == _node) && !c->pending_disconnection()) {
- DisconnectionEvent* ev = new DisconnectionEvent(_engine, SharedPtr<Responder>(new Responder()), _time,
- c->src_port(), c->dst_port());
- ev->pre_process();
- _disconnection_events.push_back(new Raul::List<DisconnectionEvent*>::Node(ev));
- c->pending_disconnection(true);
- }
- }
-
- _succeeded = true;
- QueuedEvent::pre_process();
-}
-
-
-void
-DisconnectNodeEvent::execute(ProcessContext& context)
-{
- QueuedEvent::execute(context);
-
- if (_succeeded) {
- for (Raul::List<DisconnectionEvent*>::iterator i = _disconnection_events.begin(); i != _disconnection_events.end(); ++i)
- (*i)->execute(context);
- }
-}
-
-
-void
-DisconnectNodeEvent::post_process()
-{
- if (_succeeded) {
- if (_responder)
- _responder->respond_ok();
- for (Raul::List<DisconnectionEvent*>::iterator i = _disconnection_events.begin(); i != _disconnection_events.end(); ++i)
- (*i)->post_process();
- } else {
- if (_responder)
- _responder->respond_error("Unable to disconnect all ports.");
- }
-}
-
-
-} // namespace Ingen
-