summaryrefslogtreecommitdiffstats
path: root/src/engine/DestroyEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-10 01:02:08 +0000
committerDavid Robillard <d@drobilla.net>2006-06-10 01:02:08 +0000
commit6f78a755b0f8c59f85cdc02e9eeca8db860a2ed2 (patch)
treedbb7c668101a811e8b5e10f42f19991edb129674 /src/engine/DestroyEvent.cpp
parentc2fbab4c27df8b9346bb68e30fddd7f94540dee1 (diff)
downloadingen-6f78a755b0f8c59f85cdc02e9eeca8db860a2ed2.tar.gz
ingen-6f78a755b0f8c59f85cdc02e9eeca8db860a2ed2.tar.bz2
ingen-6f78a755b0f8c59f85cdc02e9eeca8db860a2ed2.zip
Juggling things around...
git-svn-id: http://svn.drobilla.net/lad/grauph@13 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/DestroyEvent.cpp')
-rw-r--r--src/engine/DestroyEvent.cpp168
1 files changed, 0 insertions, 168 deletions
diff --git a/src/engine/DestroyEvent.cpp b/src/engine/DestroyEvent.cpp
deleted file mode 100644
index 3988195a..00000000
--- a/src/engine/DestroyEvent.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* This file is part of Om. Copyright (C) 2006 Dave Robillard.
- *
- * Om 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.
- *
- * Om 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.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "DestroyEvent.h"
-#include "Responder.h"
-#include "Om.h"
-#include "OmApp.h"
-#include "Patch.h"
-#include "Tree.h"
-#include "Node.h"
-#include "Plugin.h"
-#include "InternalNode.h"
-#include "DisconnectNodeEvent.h"
-#include "DisconnectPortEvent.h"
-#include "ClientBroadcaster.h"
-#include "Maid.h"
-#include "ObjectStore.h"
-#include "util/Path.h"
-#include "QueuedEventSource.h"
-#include "Port.h"
-
-namespace Om {
-
-
-DestroyEvent::DestroyEvent(CountedPtr<Responder> responder, const string& path, bool lock_mutex)
-: QueuedEvent(responder, true),
- m_path(path),
- m_node(NULL),
- m_patch_listnode(NULL),
- m_store_treenode(NULL),
- m_process_order(NULL),
- m_disconnect_event(NULL),
- m_parent_disconnect_event(NULL)
-{
-}
-
-
-DestroyEvent::DestroyEvent(CountedPtr<Responder> responder, Node* node, bool lock_mutex)
-: QueuedEvent(responder, true),
- m_path(node->path()),
- m_node(node),
- m_patch_listnode(NULL),
- m_store_treenode(NULL),
- m_process_order(NULL),
- m_disconnect_event(NULL),
- m_parent_disconnect_event(NULL)
-{
-}
-
-
-DestroyEvent::~DestroyEvent()
-{
- delete m_disconnect_event;
- delete m_parent_disconnect_event;
-}
-
-
-void
-DestroyEvent::pre_process()
-{
- if (m_node == NULL) {
- OmObject* const obj = om->object_store()->find_node(m_path);
-
- if (obj != NULL && obj->as_node() != NULL)
- m_node = obj->as_node();
- }
-
- if (m_node != NULL && m_path != "/") {
- assert(m_node->parent_patch() != NULL);
- m_patch_listnode = m_node->parent_patch()->remove_node(m_path.name());
- if (m_patch_listnode != NULL) {
- assert(m_patch_listnode->elem() == m_node);
-
- m_node->remove_from_store();
-
- if (m_node->providers()->size() != 0 || m_node->dependants()->size() != 0) {
- m_disconnect_event = new DisconnectNodeEvent(m_node);
- m_disconnect_event->pre_process();
- }
-
- // Create a recursive disconnect event for the parent port, if a bridge node
- Port* parent_port = m_patch_listnode->elem()->as_port();
- if (parent_port != NULL) { // Bridge node
- m_parent_disconnect_event = new DisconnectPortEvent(parent_port);
- m_parent_disconnect_event->pre_process();
- }
-
- if (m_node->parent_patch()->process()) {
- m_process_order = m_node->parent_patch()->build_process_order();
- // Remove node to be removed from the process order so it isn't executed by
- // Patch::run and can safely be destroyed
- //for (size_t i=0; i < m_process_order->size(); ++i)
- // if (m_process_order->at(i) == m_node)
- // m_process_order->at(i) = NULL; // ew, gap
-
-#ifdef DEBUG
- // Be sure node is removed from process order, so it can be destroyed
- for (size_t i=0; i < m_process_order->size(); ++i)
- assert(m_process_order->at(i) != m_node);
-#endif
- }
- }
- }
-
- QueuedEvent::pre_process();
-}
-
-
-void
-DestroyEvent::execute(samplecount offset)
-{
- QueuedEvent::execute(offset);
-
- if (m_patch_listnode != NULL) {
- m_node->remove_from_patch();
-
- if (m_disconnect_event != NULL)
- m_disconnect_event->execute(offset);
- if (m_parent_disconnect_event != NULL)
- m_parent_disconnect_event->execute(offset);
-
- if (m_node->parent_patch()->process_order() != NULL)
- om->maid()->push(m_node->parent_patch()->process_order());
- m_node->parent_patch()->process_order(m_process_order);
- }
-}
-
-
-void
-DestroyEvent::post_process()
-{
- m_source->unblock();
-
- if (m_node == NULL) {
- if (m_path == "/")
- m_responder->respond_error("You can not destroy the root patch (/)");
- else
- m_responder->respond_error("Could not find node to destroy");
- } else if (m_patch_listnode != NULL) {
- m_node->deactivate();
- m_responder->respond_ok();
- if (m_disconnect_event != NULL)
- m_disconnect_event->post_process();
- if (m_parent_disconnect_event != NULL)
- m_parent_disconnect_event->post_process();
- om->client_broadcaster()->send_destroyed(m_path);
- om->maid()->push(m_patch_listnode);
- om->maid()->push(m_node);
- } else {
- m_responder->respond_error("Unable to destroy object");
- }
-}
-
-
-} // namespace Om