diff options
Diffstat (limited to 'src/server/events/Delta.cpp')
-rw-r--r-- | src/server/events/Delta.cpp | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 034b2194..11a0b0ff 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -43,23 +43,20 @@ #include "ingen/Store.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" -#include "ingen/memory.hpp" #include "ingen/paths.hpp" #include "lilv/lilv.h" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include <algorithm> -#include <map> #include <memory> #include <mutex> #include <set> #include <string> +#include <string_view> #include <utility> #include <vector> -namespace ingen { -namespace server { +namespace ingen::server { class PreProcessContext; @@ -70,16 +67,10 @@ Delta::Delta(Engine& engine, SampleCount timestamp, const ingen::Put& msg) : Event(engine, client, msg.seq, timestamp) - , _create_event(nullptr) , _subject(msg.uri) , _properties(msg.properties) - , _object(nullptr) - , _graph(nullptr) - , _binding(nullptr) - , _state() , _context(msg.ctx) , _type(Type::PUT) - , _block(false) { init(); } @@ -93,13 +84,8 @@ Delta::Delta(Engine& engine, , _subject(msg.uri) , _properties(msg.add) , _remove(msg.remove) - , _object(nullptr) - , _graph(nullptr) - , _binding(nullptr) - , _state(nullptr) , _context(msg.ctx) , _type(Type::PATCH) - , _block(false) { init(); } @@ -111,13 +97,8 @@ Delta::Delta(Engine& engine, : Event(engine, client, msg.seq, timestamp) , _subject(msg.subject) , _properties{{msg.predicate, msg.value}} - , _object(nullptr) - , _graph(nullptr) - , _binding(nullptr) - , _state(nullptr) , _context(msg.ctx) , _type(Type::SET) - , _block(false) { init(); } @@ -153,7 +134,7 @@ Delta::add_set_event(const char* port_symbol, } _set_events.emplace_back( - make_unique<SetPortValue>( + std::make_unique<SetPortValue>( _engine, _request_client, _request_id, _time, port, Atom(size, type, value), false, true)); } @@ -173,12 +154,15 @@ get_file_node(LilvWorld* lworld, const URIs& uris, const Atom& value) { if (value.type() == uris.atom_Path) { return lilv_new_file_uri(lworld, nullptr, value.ptr<char>()); - } else if (uris.forge.is_uri(value)) { + } + + if (uris.forge.is_uri(value)) { const std::string str = uris.forge.str(value, false); if (str.substr(0, 5) == "file:") { return lilv_new_uri(lworld, value.ptr<char>()); } } + return nullptr; } @@ -223,12 +207,12 @@ Delta::pre_process(PreProcessContext& ctx) if ((_preset = block->save_preset(_subject, _properties))) { return Event::pre_process_done(Status::SUCCESS); - } else { - return Event::pre_process_done(Status::FAILURE); } + + return Event::pre_process_done(Status::FAILURE); } - std::lock_guard<Store::Mutex> lock(_engine.store()->mutex()); + const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()}; _object = is_graph_object ? static_cast<ingen::Resource*>(_engine.store()->get(uri_to_path(_subject))) @@ -240,7 +224,7 @@ Delta::pre_process(PreProcessContext& ctx) } if (is_graph_object && !_object) { - raul::Path path(uri_to_path(_subject)); + const raul::Path path{uri_to_path(_subject)}; bool is_graph = false; bool is_block = false; @@ -249,19 +233,19 @@ Delta::pre_process(PreProcessContext& ctx) ingen::Resource::type(uris, _properties, is_graph, is_block, is_port, is_output); if (is_graph) { - _create_event = make_unique<CreateGraph>( + _create_event = std::make_unique<CreateGraph>( _engine, _request_client, _request_id, _time, path, _properties); } else if (is_block) { - _create_event = make_unique<CreateBlock>( + _create_event = std::make_unique<CreateBlock>( _engine, _request_client, _request_id, _time, path, _properties); } else if (is_port) { - _create_event = make_unique<CreatePort>( + _create_event = std::make_unique<CreatePort>( _engine, _request_client, _request_id, _time, path, _properties); } if (_create_event) { if (_create_event->pre_process(ctx)) { - _object = _engine.store()->get(path); // Get object for setting + _object = _engine.store()->get(path); // Get object for setting } else { return Event::pre_process_done(Status::CREATION_FAILED, _subject); } @@ -351,7 +335,7 @@ Delta::pre_process(PreProcessContext& ctx) } } else if (key == uris.ingen_value || key == uris.ingen_activity) { _set_events.emplace_back( - make_unique<SetPortValue>( + std::make_unique<SetPortValue>( _engine, _request_client, _request_id, _time, port, value, key == uris.ingen_activity)); } else if (key == uris.midi_binding) { @@ -373,7 +357,7 @@ Delta::pre_process(PreProcessContext& ctx) } } else if ((block = dynamic_cast<BlockImpl*>(_object))) { if (key == uris.midi_binding && value == uris.patch_wildcard) { - op = SpecialType::CONTROL_BINDING; // Internal block learn + op = SpecialType::CONTROL_BINDING; // Internal block learn } else if (key == uris.ingen_enabled) { if (value.type() == uris.forge.Bool) { op = SpecialType::ENABLE; @@ -410,9 +394,9 @@ Delta::pre_process(PreProcessContext& ctx) if (key == uris.ingen_enabled) { if (value.type() == uris.forge.Bool) { op = SpecialType::ENABLE; - // FIXME: defer this until all other metadata has been processed + // FIXME: defer until all other data has been processed if (value.get<int32_t>() && !_graph->enabled()) { - if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) { + if (!(_compiled_graph = compile(*_graph))) { _status = Status::COMPILATION_FAILED; } } @@ -517,7 +501,7 @@ Delta::execute(RunContext& ctx) auto* const block = dynamic_cast<BlockImpl*>(_object); auto* const port = dynamic_cast<PortImpl*>(_object); - std::vector<SpecialType>::const_iterator t = _types.begin(); + auto t = _types.begin(); for (const auto& p : _properties) { const URI& key = p.first; const Atom& value = p.second; @@ -531,7 +515,7 @@ Delta::execute(RunContext& ctx) if (_graph) { if (value.get<int32_t>()) { if (_compiled_graph) { - _graph->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph)); } _graph->enable(); } else { @@ -609,18 +593,18 @@ Delta::post_process() _state.reset(); } - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (_create_event) { _create_event->post_process(); if (_create_event->status() != Status::SUCCESS) { - return; // Creation failed, nothing else to do + return; // Creation failed, nothing else to do } } for (auto& s : _set_events) { if (s->synthetic() || s->status() != Status::SUCCESS) { - s->post_process(); // Set failed, report error + s->post_process(); // Set failed, report error } } @@ -689,5 +673,4 @@ Delta::get_execution() const } } // namespace events -} // namespace server -} // namespace ingen +} // namespace ingen::server |