summaryrefslogtreecommitdiffstats
path: root/src/engine/events/DeleteEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-06-03 00:56:34 +0000
committerDavid Robillard <d@drobilla.net>2009-06-03 00:56:34 +0000
commit952d0c985dd511050ba17f4e293faf01d7885dad (patch)
tree482c0bbd38f3afb058a2a4c4d984c13a842b9073 /src/engine/events/DeleteEvent.cpp
parent6fa626aa20ca44e17713d947d60ec661ba44f0f5 (diff)
downloadingen-952d0c985dd511050ba17f4e293faf01d7885dad.tar.gz
ingen-952d0c985dd511050ba17f4e293faf01d7885dad.tar.bz2
ingen-952d0c985dd511050ba17f4e293faf01d7885dad.zip
Chop "Event" from event source file names.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2066 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events/DeleteEvent.cpp')
-rw-r--r--src/engine/events/DeleteEvent.cpp213
1 files changed, 0 insertions, 213 deletions
diff --git a/src/engine/events/DeleteEvent.cpp b/src/engine/events/DeleteEvent.cpp
deleted file mode 100644
index 958a8d42..00000000
--- a/src/engine/events/DeleteEvent.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007-2009 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/Maid.hpp"
-#include "raul/Path.hpp"
-#include "DeleteEvent.hpp"
-#include "Responder.hpp"
-#include "Engine.hpp"
-#include "PatchImpl.hpp"
-#include "NodeBase.hpp"
-#include "PluginImpl.hpp"
-#include "AudioDriver.hpp"
-#include "MidiDriver.hpp"
-#include "DisconnectAllEvent.hpp"
-#include "ClientBroadcaster.hpp"
-#include "EngineStore.hpp"
-#include "QueuedEventSource.hpp"
-#include "PortImpl.hpp"
-
-using namespace std;
-
-namespace Ingen {
-
-using namespace Shared;
-
-
-DeleteEvent::DeleteEvent(Engine& engine, SharedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const Raul::Path& path)
- : QueuedEvent(engine, responder, time, true, source)
- , _path(path)
- , _store_iterator(engine.engine_store()->end())
- , _driver_port(NULL)
- , _patch_node_listnode(NULL)
- , _patch_port_listnode(NULL)
- , _ports_array(NULL)
- , _compiled_patch(NULL)
- , _disconnect_event(NULL)
-{
- assert(_source);
-}
-
-
-DeleteEvent::~DeleteEvent()
-{
- delete _disconnect_event;
-}
-
-
-void
-DeleteEvent::pre_process()
-{
- _store_iterator = _engine.engine_store()->find(_path);
-
- if (_store_iterator != _engine.engine_store()->end()) {
- _node = PtrCast<NodeImpl>(_store_iterator->second);
-
- if (!_node)
- _port = PtrCast<PortImpl>(_store_iterator->second);
- }
-
- if (_store_iterator != _engine.engine_store()->end()) {
- _removed_table = _engine.engine_store()->remove(_store_iterator);
- }
-
- if (_node != NULL && !_path.is_root()) {
- assert(_node->parent_patch());
- _patch_node_listnode = _node->parent_patch()->remove_node(_path.name());
- if (_patch_node_listnode) {
- assert(_patch_node_listnode->elem() == _node.get());
-
- _disconnect_event = new DisconnectAllEvent(_engine, _node->parent_patch(), _node.get());
- _disconnect_event->pre_process();
-
- if (_node->parent_patch()->enabled()) {
- // FIXME: is this called multiple times?
- _compiled_patch = _node->parent_patch()->compile();
-#ifndef NDEBUG
- // Be sure node is removed from process order, so it can be deleted
- for (size_t i=0; i < _compiled_patch->size(); ++i) {
- assert(_compiled_patch->at(i).node() != _node.get());
- // FIXME: check providers/dependants too
- }
-#endif
- }
- }
- } else if (_port) {
- assert(_port->parent_patch());
- _patch_port_listnode = _port->parent_patch()->remove_port(_path.name());
- if (_patch_port_listnode) {
- assert(_patch_port_listnode->elem() == _port.get());
-
- _disconnect_event = new DisconnectAllEvent(_engine, _port->parent_patch(), _port.get());
- _disconnect_event->pre_process();
-
- if (_port->parent_patch()->enabled()) {
- // FIXME: is this called multiple times?
- _compiled_patch = _port->parent_patch()->compile();
- _ports_array = _port->parent_patch()->build_ports_array();
- assert(_ports_array->size() == _port->parent_patch()->num_ports());
- }
- }
-
- }
-
- QueuedEvent::pre_process();
-}
-
-
-void
-DeleteEvent::execute(ProcessContext& context)
-{
- QueuedEvent::execute(context);
-
- if (_patch_node_listnode) {
- assert(_node);
-
- if (_disconnect_event)
- _disconnect_event->execute(context);
-
- if (_node->parent_patch()->compiled_patch())
- _engine.maid()->push(_node->parent_patch()->compiled_patch());
-
- _node->parent_patch()->compiled_patch(_compiled_patch);
-
- } else if (_patch_port_listnode) {
- assert(_port);
-
- if (_disconnect_event)
- _disconnect_event->execute(context);
-
- if (_port->parent_patch()->compiled_patch())
- _engine.maid()->push(_port->parent_patch()->compiled_patch());
-
- _port->parent_patch()->compiled_patch(_compiled_patch);
-
- if (_port->parent_patch()->external_ports())
- _engine.maid()->push(_port->parent_patch()->external_ports());
-
- _port->parent_patch()->external_ports(_ports_array);
-
- if ( ! _port->parent_patch()->parent()) {
- if (_port->type() == DataType::AUDIO)
- _driver_port = _engine.audio_driver()->remove_port(_port->path());
- else if (_port->type() == DataType::EVENT)
- _driver_port = _engine.midi_driver()->remove_port(_port->path());
-
- // Apparently this needs to be called in post_process??
- //if (_driver_port)
- // _driver_port->elem()->unregister();
- }
- }
-
- if (_source)
- _source->unblock();
-}
-
-
-void
-DeleteEvent::post_process()
-{
- if (!_node && !_port) {
- if (_path.is_root()) {
- _responder->respond_error("You can not destroy the root patch (/)");
- } else {
- string msg = string("Could not find object ") + _path.str() + " to destroy";
- _responder->respond_error(msg);
- }
- }
-
- if (_patch_node_listnode) {
- assert(_node);
- _node->deactivate();
- _responder->respond_ok();
- _engine.broadcaster()->bundle_begin();
- if (_disconnect_event)
- _disconnect_event->post_process();
- _engine.broadcaster()->send_deleted(_path);
- _engine.broadcaster()->bundle_end();
- _engine.maid()->push(_patch_node_listnode);
- } else if (_patch_port_listnode) {
- assert(_port);
- _responder->respond_ok();
- _engine.broadcaster()->bundle_begin();
- if (_disconnect_event)
- _disconnect_event->post_process();
- _engine.broadcaster()->send_deleted(_path);
- _engine.broadcaster()->bundle_end();
- _engine.maid()->push(_patch_port_listnode);
- } else {
- _responder->respond_error("Unable to destroy object");
- }
-
- if (_driver_port) {
- _driver_port->elem()->destroy();
- _engine.maid()->push(_driver_port);
- }
-}
-
-
-} // namespace Ingen