summaryrefslogtreecommitdiffstats
path: root/src/server/events/CreateNode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events/CreateNode.cpp')
-rw-r--r--src/server/events/CreateNode.cpp144
1 files changed, 0 insertions, 144 deletions
diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp
deleted file mode 100644
index ca2be305..00000000
--- a/src/server/events/CreateNode.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- Ingen is free software: you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
- Software Foundation, either version 3 of the License, or 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 Affero General Public License for details.
-
- You should have received a copy of the GNU Affero General Public License
- along with Ingen. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
-#include "Broadcaster.hpp"
-#include "CreateNode.hpp"
-#include "Engine.hpp"
-#include "NodeFactory.hpp"
-#include "NodeImpl.hpp"
-#include "PatchImpl.hpp"
-#include "PluginImpl.hpp"
-#include "PortImpl.hpp"
-
-namespace Ingen {
-namespace Server {
-namespace Events {
-
-CreateNode::CreateNode(Engine& engine,
- SharedPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Resource::Properties& properties)
- : Event(engine, client, id, timestamp)
- , _path(path)
- , _properties(properties)
- , _patch(NULL)
- , _node(NULL)
- , _compiled_patch(NULL)
-{}
-
-bool
-CreateNode::pre_process()
-{
- Ingen::URIs& uris = _engine.world()->uris();
-
- typedef Resource::Properties::const_iterator iterator;
-
- if (_path.is_root()) {
- return Event::pre_process_done(BAD_URI, _path);
- }
-
- std::string plugin_uri_str;
- const iterator t = _properties.find(uris.ingen_prototype);
- if (t != _properties.end() && t->second.type() == uris.forge.URI) {
- plugin_uri_str = t->second.get_uri();
- } else {
- return Event::pre_process_done(BAD_REQUEST);
- }
-
- if (_engine.store()->get(_path)) {
- return Event::pre_process_done(EXISTS, _path);
- }
-
- _patch = dynamic_cast<PatchImpl*>(_engine.store()->get(_path.parent()));
- if (!_patch) {
- return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent());
- }
-
- const Raul::URI plugin_uri(plugin_uri_str);
- PluginImpl* plugin = _engine.node_factory()->plugin(plugin_uri);
- if (!plugin) {
- return Event::pre_process_done(PLUGIN_NOT_FOUND, Raul::URI(plugin_uri));
- }
-
- const iterator p = _properties.find(uris.ingen_polyphonic);
- const bool polyphonic = (
- p != _properties.end() &&
- p->second.type() == _engine.world()->forge().Bool &&
- p->second.get_bool());
-
- if (!(_node = plugin->instantiate(*_engine.buffer_factory(),
- Raul::Symbol(_path.symbol()),
- polyphonic,
- _patch,
- _engine))) {
- return Event::pre_process_done(CREATION_FAILED, _path);
- }
-
- _node->properties().insert(_properties.begin(), _properties.end());
- _node->activate(*_engine.buffer_factory());
-
- // Add node to the store and the patch's pre-processor only node list
- _patch->add_node(*_node);
- _engine.store()->add(_node);
-
- /* Compile patch with new node added for insertion in audio thread
- TODO: Since the node is not connected at this point, a full compilation
- could be avoided and the node simply appended. */
- if (_patch->enabled()) {
- _compiled_patch = _patch->compile();
- }
-
- _update.push_back(make_pair(_node->uri(), _node->properties()));
- for (uint32_t i = 0; i < _node->num_ports(); ++i) {
- const PortImpl* port = _node->port_impl(i);
- Resource::Properties pprops = port->properties();
- pprops.erase(uris.ingen_value);
- pprops.insert(std::make_pair(uris.ingen_value, port->value()));
- _update.push_back(std::make_pair(port->uri(), pprops));
- }
-
- return Event::pre_process_done(SUCCESS);
-}
-
-void
-CreateNode::execute(ProcessContext& context)
-{
- if (_node) {
- _engine.maid()->dispose(_patch->compiled_patch());
- _patch->compiled_patch(_compiled_patch);
- }
-}
-
-void
-CreateNode::post_process()
-{
- if (!respond()) {
- for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) {
- _engine.broadcaster()->put(i->first, i->second);
- }
- }
-}
-
-} // namespace Events
-} // namespace Server
-} // namespace Ingen