diff options
Diffstat (limited to 'src/server/events/Copy.cpp')
-rw-r--r-- | src/server/events/Copy.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index beb5224c..f6529da3 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -24,6 +24,7 @@ #include "PreProcessContext.hpp" #include "ingen/Interface.hpp" +#include "ingen/Node.hpp" #include "ingen/Parser.hpp" #include "ingen/Serialiser.hpp" #include "ingen/Status.hpp" @@ -34,17 +35,15 @@ #include "raul/Path.hpp" #include "raul/Symbol.hpp" -#include <boost/optional/optional.hpp> - #include <map> #include <memory> #include <mutex> +#include <optional> #include <string> +#include <string_view> #include <utility> -namespace ingen { -namespace server { -namespace events { +namespace ingen::server::events { Copy::Copy(Engine& engine, const std::shared_ptr<Interface>& client, @@ -59,7 +58,7 @@ Copy::~Copy() = default; bool Copy::pre_process(PreProcessContext& ctx) { - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; if (uri_is_path(_msg.old_uri)) { // Old URI is a path within the engine @@ -138,7 +137,7 @@ Copy::engine_to_engine(PreProcessContext& ctx) _engine.store()->add(_block); // Compile graph with new block added for insertion in audio thread - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent); + _compiled_graph = ctx.maybe_compile(*_parent); return Event::pre_process_done(Status::SUCCESS); } @@ -165,7 +164,7 @@ Copy::engine_to_filesystem(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()}; if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) { _engine.world().serialiser()->write_bundle(graph, URI(_msg.new_uri)); @@ -186,13 +185,13 @@ Copy::filesystem_to_engine(PreProcessContext&) return Event::pre_process_done(Status::INTERNAL_ERROR); } - std::lock_guard<std::mutex> lock(_engine.world().rdf_mutex()); + const std::lock_guard<std::mutex> lock{_engine.world().rdf_mutex()}; // Old URI is a filesystem path and new URI is a path within the engine - const std::string src_path(_msg.old_uri.path()); - const raul::Path dst_path = uri_to_path(_msg.new_uri); - boost::optional<raul::Path> dst_parent; - boost::optional<raul::Symbol> dst_symbol; + const std::string src_path(_msg.old_uri.path()); + const raul::Path dst_path = uri_to_path(_msg.new_uri); + std::optional<raul::Path> dst_parent; + std::optional<raul::Symbol> dst_symbol; if (!dst_path.is_root()) { dst_parent = dst_path.parent(); dst_symbol = raul::Symbol(dst_path.symbol()); @@ -209,14 +208,15 @@ void Copy::execute(RunContext&) { if (_block && _compiled_graph) { - _parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _parent->swap_compiled_graph(std::move(_compiled_graph)); } } void Copy::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _engine.broadcaster()->message(_msg); } @@ -230,6 +230,4 @@ Copy::undo(Interface& target) } } -} // namespace events -} // namespace server -} // namespace ingen +} // namespace ingen::server::events |