diff options
Diffstat (limited to 'src/server/events/CreateGraph.cpp')
-rw-r--r-- | src/server/events/CreateGraph.cpp | 71 |
1 files changed, 33 insertions, 38 deletions
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 2a74ddf0..5df28afa 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -14,54 +14,50 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "events/CreateGraph.hpp" +#include "CreateGraph.hpp" #include "BlockImpl.hpp" #include "Broadcaster.hpp" #include "CompiledGraph.hpp" +#include "CreatePort.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "PreProcessContext.hpp" -#include "events/CreatePort.hpp" #include "types.hpp" -#include "ingen/Forge.hpp" -#include "ingen/Interface.hpp" -#include "ingen/Node.hpp" -#include "ingen/Resource.hpp" -#include "ingen/Status.hpp" -#include "ingen/Store.hpp" -#include "ingen/URI.hpp" -#include "ingen/URIs.hpp" -#include "ingen/World.hpp" -#include "ingen/paths.hpp" -#include "raul/Maid.hpp" -#include "raul/Path.hpp" -#include "raul/Symbol.hpp" +#include <ingen/Forge.hpp> +#include <ingen/Interface.hpp> +#include <ingen/Node.hpp> +#include <ingen/Properties.hpp> +#include <ingen/Resource.hpp> +#include <ingen/Status.hpp> +#include <ingen/Store.hpp> +#include <ingen/URI.hpp> +#include <ingen/URIs.hpp> +#include <ingen/World.hpp> +#include <ingen/paths.hpp> +#include <raul/Path.hpp> +#include <raul/Symbol.hpp> #include <boost/intrusive/slist.hpp> #include <map> #include <memory> +#include <string> #include <utility> -namespace ingen { -namespace server { -namespace events { +namespace ingen::server::events { CreateGraph::CreateGraph(Engine& engine, const std::shared_ptr<Interface>& client, int32_t id, SampleCount timestamp, raul::Path path, - const Properties& properties) + Properties properties) : Event(engine, client, id, timestamp) , _path(std::move(path)) - , _properties(properties) - , _graph(nullptr) - , _parent(nullptr) -{ -} + , _properties(std::move(properties)) +{} CreateGraph::~CreateGraph() = default; @@ -136,11 +132,9 @@ CreateGraph::pre_process(PreProcessContext& ctx) const ingen::URIs& uris = _engine.world().uris(); - using iterator = Properties::const_iterator; - - uint32_t ext_poly = 1; - uint32_t int_poly = 1; - iterator p = _properties.find(uris.ingen_polyphony); + uint32_t ext_poly = 1; + uint32_t int_poly = 1; + const auto p = _properties.find(uris.ingen_polyphony); if (p != _properties.end() && p->second.type() == uris.forge.Int) { int_poly = p->second.get<int32_t>(); } @@ -156,7 +150,7 @@ CreateGraph::pre_process(PreProcessContext& ctx) const raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol()); // Get graph prototype - iterator t = _properties.find(uris.lv2_prototype); + auto t = _properties.find(uris.lv2_prototype); if (t == _properties.end()) { t = _properties.find(uris.lv2_prototype); } @@ -171,8 +165,10 @@ CreateGraph::pre_process(PreProcessContext& ctx) if (!ancestor) { return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype); - } else if (!(_graph = dynamic_cast<GraphImpl*>( - ancestor->duplicate(_engine, symbol, _parent)))) { + } + + if (!(_graph = dynamic_cast<GraphImpl*>( + ancestor->duplicate(_engine, symbol, _parent)))) { return Event::pre_process_done(Status::CREATION_FAILED, _path); } } else { @@ -197,7 +193,7 @@ CreateGraph::pre_process(PreProcessContext& ctx) if (_parent->enabled()) { _graph->enable(); } - _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent); + _compiled_graph = ctx.maybe_compile(*_parent); } _graph->activate(*_engine.buffer_factory()); @@ -224,7 +220,8 @@ CreateGraph::execute(RunContext& ctx) if (_graph) { if (_parent) { if (_compiled_graph) { - _parent->set_compiled_graph(std::move(_compiled_graph)); + _compiled_graph = + _parent->swap_compiled_graph(std::move(_compiled_graph)); } } else { _engine.set_root_graph(_graph); @@ -240,7 +237,7 @@ CreateGraph::execute(RunContext& ctx) void CreateGraph::post_process() { - Broadcaster::Transfer t(*_engine.broadcaster()); + const Broadcaster::Transfer t{*_engine.broadcaster()}; if (respond() == Status::SUCCESS) { _update.send(*_engine.broadcaster()); } @@ -258,6 +255,4 @@ CreateGraph::undo(Interface& target) target.del(_graph->uri()); } -} // namespace events -} // namespace server -} // namespace ingen +} // namespace ingen::server::events |