From a7d83f19b08eb4c6f79a82fe60c2b86db13f4420 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 24 Nov 2018 13:44:03 +0100 Subject: Squashed 'waflib/' changes from 6e726eb1..5ea8f99f 5ea8f99f Improve test output spacing 0e23b29f Raise exception when test suite fails to ensure non-zero exit status d6de073b Show run time of unit tests 5b655541 Add short configure option for ultra-strict flags 4687ba6d Use gtest-like test output 258903d9 Fix failure count in test group summaries da07e738 Fix verbose tests with Python 3 git-subtree-dir: waflib git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d --- src/server/events/Delete.cpp | 216 ------------------------------------------- 1 file changed, 216 deletions(-) delete mode 100644 src/server/events/Delete.cpp (limited to 'src/server/events/Delete.cpp') diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp deleted file mode 100644 index e8f9582c..00000000 --- a/src/server/events/Delete.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2016 David Robillard - - 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 . -*/ - -#include "ingen/Store.hpp" -#include "raul/Maid.hpp" -#include "raul/Path.hpp" - -#include "BlockImpl.hpp" -#include "Broadcaster.hpp" -#include "ControlBindings.hpp" -#include "Delete.hpp" -#include "DisconnectAll.hpp" -#include "Driver.hpp" -#include "Engine.hpp" -#include "EnginePort.hpp" -#include "GraphImpl.hpp" -#include "PluginImpl.hpp" -#include "PortImpl.hpp" -#include "PreProcessContext.hpp" - -namespace Ingen { -namespace Server { -namespace Events { - -Delete::Delete(Engine& engine, - SPtr client, - FrameTime timestamp, - const Ingen::Del& msg) - : Event(engine, client, msg.seq, timestamp) - , _msg(msg) - , _engine_port(nullptr) - , _disconnect_event(nullptr) -{ - if (uri_is_path(msg.uri)) { - _path = uri_to_path(msg.uri); - } -} - -Delete::~Delete() -{ - delete _disconnect_event; - for (ControlBindings::Binding* b : _removed_bindings) { - delete b; - } -} - -bool -Delete::pre_process(PreProcessContext& ctx) -{ - const Ingen::URIs& uris = _engine.world()->uris(); - if (_path.is_root() || _path == "/control" || _path == "/notify") { - return Event::pre_process_done(Status::NOT_DELETABLE, _path); - } - - _engine.control_bindings()->get_all(_path, _removed_bindings); - - auto iter = _engine.store()->find(_path); - if (iter == _engine.store()->end()) { - return Event::pre_process_done(Status::NOT_FOUND, _path); - } - - if (!(_block = dynamic_ptr_cast(iter->second))) { - _port = dynamic_ptr_cast(iter->second); - } - - if ((!_block && !_port) || (_port && !_engine.driver()->dynamic_ports())) { - return Event::pre_process_done(Status::NOT_DELETABLE, _path); - } - - GraphImpl* parent = _block ? _block->parent_graph() : _port->parent_graph(); - if (!parent) { - return Event::pre_process_done(Status::INTERNAL_ERROR, _path); - } - - // Take a writer lock while we modify the store - std::lock_guard lock(_engine.store()->mutex()); - - _engine.store()->remove(iter, _removed_objects); - - if (_block) { - parent->remove_block(*_block); - _disconnect_event = new DisconnectAll(_engine, parent, _block.get()); - _disconnect_event->pre_process(ctx); - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent); - } else if (_port) { - parent->remove_port(*_port); - _disconnect_event = new DisconnectAll(_engine, parent, _port.get()); - _disconnect_event->pre_process(ctx); - - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent); - if (parent->enabled()) { - _ports_array = parent->build_ports_array(*_engine.maid()); - assert(_ports_array->size() == parent->num_ports_non_rt()); - - // Adjust port indices if necessary and record changes for later - for (size_t i = 0; i < _ports_array->size(); ++i) { - PortImpl* const port = _ports_array->at(i); - if (port->index() != i) { - _port_index_changes.emplace( - port->path(), std::make_pair(port->index(), i)); - port->remove_property(uris.lv2_index, uris.patch_wildcard); - port->set_property( - uris.lv2_index, - _engine.buffer_factory()->forge().make((int32_t)i)); - } - } - } - - if (!parent->parent()) { - _engine_port = _engine.driver()->get_port(_port->path()); - } - } - - return Event::pre_process_done(Status::SUCCESS); -} - -void -Delete::execute(RunContext& context) -{ - if (_status != Status::SUCCESS) { - return; - } - - if (_disconnect_event) { - _disconnect_event->execute(context); - } - - if (!_removed_bindings.empty()) { - _engine.control_bindings()->remove(context, _removed_bindings); - } - - GraphImpl* parent = _block ? _block->parent_graph() : nullptr; - if (_port) { - // Adjust port indices if necessary - for (size_t i = 0; i < _ports_array->size(); ++i) { - PortImpl* const port = _ports_array->at(i); - if (port->index() != i) { - port->set_index(context, i); - } - } - - // Replace ports array in graph - parent = _port->parent_graph(); - parent->set_external_ports(std::move(_ports_array)); - - if (_engine_port) { - _engine.driver()->remove_port(context, _engine_port); - } - } - - if (parent && _compiled_graph) { - parent->set_compiled_graph(std::move(_compiled_graph)); - } -} - -void -Delete::post_process() -{ - Broadcaster::Transfer t(*_engine.broadcaster()); - if (respond() == Status::SUCCESS && (_block || _port)) { - if (_block) { - _block->deactivate(); - } - - _engine.broadcaster()->message(_msg); - } - - if (_engine_port) { - _engine.driver()->unregister_port(*_engine_port); - delete _engine_port; - } -} - -void -Delete::undo(Interface& target) -{ - const Ingen::URIs& uris = _engine.world()->uris(); - Ingen::Forge& forge = _engine.buffer_factory()->forge(); - - auto i = _removed_objects.find(_path); - if (i != _removed_objects.end()) { - // Undo disconnect - if (_disconnect_event) { - _disconnect_event->undo(target); - } - - // Put deleted item back - target.put(_msg.uri, i->second->properties()); - - // Adjust port indices - for (const auto& c : _port_index_changes) { - if (c.first != _msg.uri.path()) { - target.set_property(path_to_uri(c.first), - uris.lv2_index, - forge.make(int32_t(c.second.first))); - } - } - } -} - -} // namespace Events -} // namespace Server -} // namespace Ingen -- cgit v1.2.1