summaryrefslogtreecommitdiffstats
path: root/src/engine/CreatePatchEvent.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/CreatePatchEvent.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/CreatePatchEvent.cpp')
-rw-r--r--src/engine/CreatePatchEvent.cpp150
1 files changed, 0 insertions, 150 deletions
diff --git a/src/engine/CreatePatchEvent.cpp b/src/engine/CreatePatchEvent.cpp
deleted file mode 100644
index 9f0ae7f2..00000000
--- a/src/engine/CreatePatchEvent.cpp
+++ /dev/null
@@ -1,150 +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 "CreatePatchEvent.h"
-#include "Responder.h"
-#include "Patch.h"
-#include "Node.h"
-#include "Tree.h"
-#include "Plugin.h"
-#include "Om.h"
-#include "OmApp.h"
-#include "Maid.h"
-#include "ClientBroadcaster.h"
-#include "AudioDriver.h"
-#include "util/Path.h"
-#include "ObjectStore.h"
-
-namespace Om {
-
-
-CreatePatchEvent::CreatePatchEvent(CountedPtr<Responder> responder, const string& path, int poly)
-: QueuedEvent(responder),
- m_path(path),
- m_patch(NULL),
- m_parent(NULL),
- m_process_order(NULL),
- m_poly(poly),
- m_error(NO_ERROR)
-{
-}
-
-
-void
-CreatePatchEvent::pre_process()
-{
- if (om->object_store()->find(m_path) != NULL) {
- m_error = OBJECT_EXISTS;
- QueuedEvent::pre_process();
- return;
- }
-
- if (m_poly < 1) {
- m_error = INVALID_POLY;
- QueuedEvent::pre_process();
- return;
- }
-
- if (m_path != "/") {
- m_parent = om->object_store()->find_patch(m_path.parent());
- if (m_parent == NULL) {
- m_error = PARENT_NOT_FOUND;
- QueuedEvent::pre_process();
- return;
- }
- }
-
- size_t poly = 1;
- if (m_parent != NULL && m_poly > 1 && m_poly == static_cast<int>(m_parent->internal_poly()))
- poly = m_poly;
-
- m_patch = new Patch(m_path.name(), poly, m_parent, om->audio_driver()->sample_rate(), om->audio_driver()->buffer_size(), m_poly);
-
- if (m_parent != NULL) {
- m_parent->add_node(new ListNode<Node*>(m_patch->as_node()));
-
- if (m_parent->process())
- m_process_order = m_parent->build_process_order();
- }
-
- m_patch->activate();
-
- // Insert into ObjectStore
- m_patch->add_to_store();
-
- QueuedEvent::pre_process();
-}
-
-
-void
-CreatePatchEvent::execute(samplecount offset)
-{
- QueuedEvent::execute(offset);
-
- if (m_patch != NULL) {
- if (m_parent == NULL) {
- assert(m_path == "/");
- assert(m_patch->parent_patch() == NULL);
- om->audio_driver()->set_root_patch(m_patch);
- } else {
- assert(m_parent != NULL);
- assert(m_path != "/");
-
- m_patch->add_to_patch();
-
- if (m_parent->process_order() != NULL)
- om->maid()->push(m_parent->process_order());
- m_parent->process_order(m_process_order);
- }
- }
-}
-
-
-void
-CreatePatchEvent::post_process()
-{
- if (m_responder.get()) {
- if (m_error == NO_ERROR) {
-
- m_responder->respond_ok();
-
- // Don't want to send nodes that have been added since prepare()
- //om->client_broadcaster()->send_node_creation_messages(m_patch);
-
- // Patches are always empty on creation, so this is fine
- om->client_broadcaster()->send_patch(m_patch);
-
- } else if (m_error == OBJECT_EXISTS) {
- string msg = "Unable to create patch: ";
- msg += m_path += " already exists.";
- m_responder->respond_error(msg);
- } else if (m_error == PARENT_NOT_FOUND) {
- string msg = "Unable to create patch: Parent ";
- msg += m_path.parent() += " not found.";
- m_responder->respond_error(msg);
- } else if (m_error == INVALID_POLY) {
- string msg = "Unable to create patch ";
- msg.append(m_path).append(": ").append("Invalid polyphony respondered.");
- m_responder->respond_error(msg);
- } else {
- m_responder->respond_error("Unable to load patch.");
- }
- }
-}
-
-
-} // namespace Om
-