summaryrefslogtreecommitdiffstats
path: root/src/server/events/CreateBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events/CreateBlock.cpp')
-rw-r--r--src/server/events/CreateBlock.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 0898a6a0..7f50411c 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -40,7 +40,6 @@
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
#include "ingen/paths.hpp"
-#include "raul/Maid.hpp"
#include "raul/Path.hpp"
#include "raul/Symbol.hpp"
@@ -48,8 +47,7 @@
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class RunContext;
@@ -64,8 +62,6 @@ CreateBlock::CreateBlock(Engine& engine,
: Event(engine, client, id, timestamp)
, _path(std::move(path))
, _properties(properties)
- , _graph(nullptr)
- , _block(nullptr)
{}
CreateBlock::~CreateBlock() = default;
@@ -73,22 +69,24 @@ CreateBlock::~CreateBlock() = default;
bool
CreateBlock::pre_process(PreProcessContext& ctx)
{
- using iterator = Properties::const_iterator;
-
const ingen::URIs& uris = _engine.world().uris();
const std::shared_ptr<Store> store = _engine.store();
// Check sanity of target path
if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (store->get(_path)) {
+ }
+
+ if (store->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(store->get(_path.parent())))) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _path.parent());
}
// Map old ingen:prototype to new lv2:prototype
- auto range = _properties.equal_range(uris.ingen_prototype);
+ const auto range = _properties.equal_range(uris.ingen_prototype);
for (auto i = range.first; i != range.second;) {
const auto value = i->second;
auto next = i;
@@ -98,7 +96,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
}
// Get prototype
- iterator t = _properties.find(uris.lv2_prototype);
+ const auto t = _properties.find(uris.lv2_prototype);
if (t == _properties.end() || !uris.forge.is_uri(t->second)) {
// Missing/invalid prototype
return Event::pre_process_done(Status::BAD_REQUEST);
@@ -107,10 +105,10 @@ CreateBlock::pre_process(PreProcessContext& ctx)
const URI prototype(uris.forge.str(t->second, false));
// Find polyphony
- const iterator p = _properties.find(uris.ingen_polyphonic);
- const bool polyphonic = (p != _properties.end() &&
- p->second.type() == uris.forge.Bool &&
- p->second.get<int32_t>());
+ const auto p = _properties.find(uris.ingen_polyphonic);
+ const bool polyphonic = (p != _properties.end() &&
+ p->second.type() == uris.forge.Bool &&
+ p->second.get<int32_t>());
// Find and instantiate/duplicate prototype (plugin/existing node)
if (uri_is_path(prototype)) {
@@ -119,8 +117,11 @@ CreateBlock::pre_process(PreProcessContext& ctx)
store->get(uri_to_path(prototype)));
if (!ancestor) {
return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype);
- } else if (!(_block = ancestor->duplicate(
- _engine, raul::Symbol(_path.symbol()), _graph))) {
+ }
+
+ if (!(_block = ancestor->duplicate(_engine,
+ raul::Symbol(_path.symbol()),
+ _graph))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
@@ -167,7 +168,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
/* Compile graph with new block added for insertion in audio thread
TODO: Since the block is not connected at this point, a full compilation
could be avoided and the block simply appended. */
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
+ _compiled_graph = ctx.maybe_compile(*_graph);
_update.put_block(_block);
@@ -178,14 +179,15 @@ void
CreateBlock::execute(RunContext&)
{
if (_status == Status::SUCCESS && _compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _graph->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
CreateBlock::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_update.send(*_engine.broadcaster());
}
@@ -198,5 +200,4 @@ CreateBlock::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server