summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp21
-rw-r--r--src/server/events/Connect.hpp6
-rw-r--r--src/server/events/Copy.cpp61
-rw-r--r--src/server/events/Copy.hpp9
-rw-r--r--src/server/events/CreateBlock.cpp45
-rw-r--r--src/server/events/CreateBlock.hpp7
-rw-r--r--src/server/events/CreateGraph.cpp87
-rw-r--r--src/server/events/CreateGraph.hpp9
-rw-r--r--src/server/events/CreatePort.cpp51
-rw-r--r--src/server/events/CreatePort.hpp13
-rw-r--r--src/server/events/Delete.cpp28
-rw-r--r--src/server/events/Delete.hpp7
-rw-r--r--src/server/events/Delta.cpp67
-rw-r--r--src/server/events/Delta.hpp24
-rw-r--r--src/server/events/Disconnect.cpp33
-rw-r--r--src/server/events/Disconnect.hpp11
-rw-r--r--src/server/events/DisconnectAll.cpp80
-rw-r--r--src/server/events/DisconnectAll.hpp7
-rw-r--r--src/server/events/Get.cpp33
-rw-r--r--src/server/events/Get.hpp4
-rw-r--r--src/server/events/Mark.cpp12
-rw-r--r--src/server/events/Mark.hpp9
-rw-r--r--src/server/events/Move.cpp21
-rw-r--r--src/server/events/SetPortValue.cpp19
-rw-r--r--src/server/events/Undo.cpp11
25 files changed, 320 insertions, 355 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 234bc550..e1854ef2 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -42,9 +42,7 @@
#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Connect::Connect(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -52,17 +50,14 @@ Connect::Connect(Engine& engine,
const ingen::Connect& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _graph(nullptr)
- , _head(nullptr)
-{
-}
+{}
Connect::~Connect() = default;
bool
Connect::pre_process(PreProcessContext& ctx)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
Node* tail = _engine.store()->get(_msg.tail);
if (!tail) {
@@ -137,7 +132,7 @@ Connect::pre_process(PreProcessContext& ctx)
head_block->providers().insert(tail_block);
if (ctx.must_compile(*_graph)) {
- if (!(_compiled_graph = compile(*_engine.maid(), *_graph))) {
+ if (!(_compiled_graph = compile(*_graph))) {
head_block->providers().erase(tail_block);
tail_block->dependants().erase(head_block);
return Event::pre_process_done(Status::COMPILATION_FAILED);
@@ -170,7 +165,7 @@ Connect::execute(RunContext& ctx)
}
_head->connect_buffers();
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph));
}
}
}
@@ -178,7 +173,7 @@ Connect::execute(RunContext& ctx)
void
Connect::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
if (!_tail_remove.empty() || !_tail_add.empty()) {
@@ -198,6 +193,4 @@ Connect::undo(Interface& target)
target.disconnect(_msg.tail, _msg.head);
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index 941c0a25..4224f109 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -64,9 +64,9 @@ public:
private:
const ingen::Connect _msg;
- GraphImpl* _graph;
- InputPort* _head;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ GraphImpl* _graph{nullptr};
+ InputPort* _head{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
std::shared_ptr<ArcImpl> _arc;
raul::managed_ptr<PortImpl::Voices> _voices;
Properties _tail_remove;
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 9ce7ead6..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,
@@ -52,9 +51,6 @@ Copy::Copy(Engine& engine,
const ingen::Copy& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _old_block(nullptr)
- , _parent(nullptr)
- , _block(nullptr)
{}
Copy::~Copy() = default;
@@ -62,14 +58,14 @@ 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
const raul::Path old_path = uri_to_path(_msg.old_uri);
// Find the old node
- const Store::iterator i = _engine.store()->find(old_path);
+ const auto i = _engine.store()->find(old_path);
if (i == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, old_path);
}
@@ -82,19 +78,23 @@ Copy::pre_process(PreProcessContext& ctx)
if (uri_is_path(_msg.new_uri)) {
// Copy to path within the engine
return engine_to_engine(ctx);
- } else if (_msg.new_uri.scheme() == "file") {
+ }
+
+ if (_msg.new_uri.scheme() == "file") {
// Copy to filesystem path (i.e. save)
return engine_to_filesystem(ctx);
- } else {
- return Event::pre_process_done(Status::BAD_REQUEST);
}
- } else if (_msg.old_uri.scheme() == "file") {
+
+ return Event::pre_process_done(Status::BAD_REQUEST);
+ }
+
+ if (_msg.old_uri.scheme() == "file") {
if (uri_is_path(_msg.new_uri)) {
return filesystem_to_engine(ctx);
- } else {
- // Ingen is not your file manager
- return Event::pre_process_done(Status::BAD_REQUEST);
}
+
+ // Ingen is not your file manager
+ return Event::pre_process_done(Status::BAD_REQUEST);
}
return Event::pre_process_done(Status::BAD_URI);
@@ -115,8 +115,8 @@ Copy::engine_to_engine(PreProcessContext& ctx)
}
// Find new parent graph
- const raul::Path parent_path = new_path.parent();
- const Store::iterator p = _engine.store()->find(parent_path);
+ const raul::Path parent_path = new_path.parent();
+ const auto p = _engine.store()->find(parent_path);
if (p == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, parent_path);
}
@@ -137,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);
}
@@ -164,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));
@@ -185,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());
@@ -208,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);
}
@@ -229,6 +230,4 @@ Copy::undo(Interface& target)
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp
index f9c507f0..744a61c2 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -21,7 +21,6 @@
#include "types.hpp"
#include "ingen/Message.hpp"
-#include "raul/Maid.hpp"
#include <memory>
@@ -64,10 +63,10 @@ private:
bool filesystem_to_engine(PreProcessContext& ctx);
const ingen::Copy _msg;
- std::shared_ptr<BlockImpl> _old_block;
- GraphImpl* _parent;
- BlockImpl* _block;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::shared_ptr<BlockImpl> _old_block{nullptr};
+ GraphImpl* _parent{nullptr};
+ BlockImpl* _block{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
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
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index 97a54b3f..e8a49ea0 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -21,7 +21,6 @@
#include "Event.hpp"
#include "types.hpp"
-#include "raul/Maid.hpp"
#include "raul/Path.hpp"
#include <cstdint>
@@ -68,9 +67,9 @@ private:
raul::Path _path;
Properties& _properties;
ClientUpdate _update;
- GraphImpl* _graph;
- BlockImpl* _block;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ GraphImpl* _graph{nullptr};
+ BlockImpl* _block{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index 6b85281d..7a8a973d 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -34,9 +34,7 @@
#include "ingen/URI.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
-#include "ingen/memory.hpp"
#include "ingen/paths.hpp"
-#include "raul/Maid.hpp"
#include "raul/Path.hpp"
#include "raul/Symbol.hpp"
@@ -46,21 +44,17 @@
#include <memory>
#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;
@@ -84,30 +78,40 @@ CreateGraph::build_child_events()
in_properties.put(uris.lv2_index, uris.forge.make(0));
in_properties.put(uris.lv2_name, uris.forge.alloc("Control"));
in_properties.put(uris.rdf_type, uris.lv2_InputPort);
- in_properties.put(uris.ingen_canvasX, uris.forge.make(32.0f),
+ in_properties.put(uris.ingen_canvasX,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
- in_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ in_properties.put(uris.ingen_canvasY,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
- _child_events.push_back(
- make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
- _path.child(raul::Symbol("control")),
- in_properties));
+ _child_events.push_back(std::make_unique<events::CreatePort>(
+ _engine,
+ _request_client,
+ -1,
+ _time,
+ _path.child(raul::Symbol("control")),
+ in_properties));
// Add notify port (message respond)
Properties out_properties(control_properties);
out_properties.put(uris.lv2_index, uris.forge.make(1));
out_properties.put(uris.lv2_name, uris.forge.alloc("Notify"));
out_properties.put(uris.rdf_type, uris.lv2_OutputPort);
- out_properties.put(uris.ingen_canvasX, uris.forge.make(128.0f),
+ out_properties.put(uris.ingen_canvasX,
+ uris.forge.make(128.0f),
Resource::Graph::EXTERNAL);
- out_properties.put(uris.ingen_canvasY, uris.forge.make(32.0f),
+ out_properties.put(uris.ingen_canvasY,
+ uris.forge.make(32.0f),
Resource::Graph::EXTERNAL);
_child_events.push_back(
- make_unique<events::CreatePort>(_engine, _request_client, -1, _time,
- _path.child(raul::Symbol("notify")),
- out_properties));
+ std::make_unique<events::CreatePort>(_engine,
+ _request_client,
+ -1,
+ _time,
+ _path.child(raul::Symbol("notify")),
+ out_properties));
}
bool
@@ -126,11 +130,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>();
}
@@ -146,29 +148,35 @@ 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);
}
- if (t != _properties.end() &&
- uris.forge.is_uri(t->second) &&
+ if (t != _properties.end() && uris.forge.is_uri(t->second) &&
URI::is_valid(uris.forge.str(t->second, false)) &&
uri_is_path(URI(uris.forge.str(t->second, false)))) {
// Create a duplicate of an existing graph
const URI prototype(uris.forge.str(t->second, false));
GraphImpl* ancestor = dynamic_cast<GraphImpl*>(
- _engine.store()->get(uri_to_path(prototype)));
+ _engine.store()->get(uri_to_path(prototype)));
if (!ancestor) {
- return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(
- ancestor->duplicate(_engine, symbol, _parent)))) {
+ return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND,
+ prototype);
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(
+ ancestor->duplicate(_engine, symbol, _parent)))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
} else {
// Create a new graph
- _graph = new GraphImpl(_engine, symbol, ext_poly, _parent,
- _engine.sample_rate(), int_poly);
+ _graph = new GraphImpl(_engine,
+ symbol,
+ ext_poly,
+ _parent,
+ _engine.sample_rate(),
+ int_poly);
_graph->add_property(uris.rdf_type, uris.ingen_Graph.urid_atom());
_graph->add_property(uris.rdf_type,
Property(uris.ingen_Block,
@@ -183,7 +191,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());
@@ -210,7 +218,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);
@@ -226,7 +235,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());
}
@@ -244,6 +253,4 @@ CreateGraph::undo(Interface& target)
target.del(_graph->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index d9e994c0..b083ae8c 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -22,7 +22,6 @@
#include "types.hpp"
#include "ingen/Properties.hpp"
-#include "raul/Maid.hpp"
#include "raul/Path.hpp"
#include <cstdint>
@@ -55,7 +54,7 @@ public:
int32_t id,
SampleCount timestamp,
raul::Path path,
- const Properties& properties);
+ Properties properties);
~CreateGraph() override;
@@ -72,9 +71,9 @@ private:
const raul::Path _path;
Properties _properties;
ClientUpdate _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ GraphImpl* _graph{nullptr};
+ GraphImpl* _parent{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
std::list<std::unique_ptr<Event>> _child_events;
};
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index 1fa2a528..937842a7 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -45,9 +45,7 @@
#include <memory>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
CreatePort::CreatePort(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -58,19 +56,12 @@ CreatePort::CreatePort(Engine& engine,
: Event(engine, client, id, timestamp)
, _path(std::move(path))
, _port_type(PortType::UNKNOWN)
- , _buf_type(0)
- , _graph(nullptr)
- , _graph_port(nullptr)
- , _engine_port(nullptr)
, _properties(properties)
{
const ingen::URIs& uris = _engine.world().uris();
- using Iterator = Properties::const_iterator;
- using Range = std::pair<Iterator, Iterator>;
-
- const Range types = properties.equal_range(uris.rdf_type);
- for (Iterator i = types.first; i != types.second; ++i) {
+ const auto types = properties.equal_range(uris.rdf_type);
+ for (auto i = types.first; i != types.second; ++i) {
const Atom& type = i->second;
if (type == uris.lv2_AudioPort) {
_port_type = PortType::AUDIO;
@@ -87,8 +78,8 @@ CreatePort::CreatePort(Engine& engine,
}
}
- const Range buffer_types = properties.equal_range(uris.atom_bufferType);
- for (Iterator i = buffer_types.first; i != buffer_types.second; ++i) {
+ const auto buffer_types = properties.equal_range(uris.atom_bufferType);
+ for (auto i = buffer_types.first; i != buffer_types.second; ++i) {
if (uris.forge.is_uri(i->second)) {
_buf_type = _engine.world().uri_map().map_uri(
uris.forge.str(i->second, false));
@@ -101,9 +92,13 @@ CreatePort::pre_process(PreProcessContext&)
{
if (_port_type == PortType::UNKNOWN || !_flow) {
return Event::pre_process_done(Status::UNKNOWN_TYPE, _path);
- } else if (_path.is_root()) {
+ }
+
+ if (_path.is_root()) {
return Event::pre_process_done(Status::BAD_URI, _path);
- } else if (_engine.store()->get(_path)) {
+ }
+
+ if (_engine.store()->get(_path)) {
return Event::pre_process_done(Status::EXISTS, _path);
}
@@ -111,10 +106,14 @@ CreatePort::pre_process(PreProcessContext&)
Node* const parent = _engine.store()->get(parent_path);
if (!parent) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, parent_path);
- } else if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
+ }
+
+ if (!(_graph = dynamic_cast<GraphImpl*>(parent))) {
return Event::pre_process_done(Status::INVALID_PARENT, parent_path);
- } else if (!_graph->parent() && _engine.activated() &&
- !_engine.driver()->dynamic_ports()) {
+ }
+
+ if (!_graph->parent() && _engine.activated() &&
+ !_engine.driver()->dynamic_ports()) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
@@ -123,10 +122,8 @@ CreatePort::pre_process(PreProcessContext&)
const uint32_t buf_size = bufs.default_size(_buf_type);
const int32_t old_n_ports = _graph->num_ports_non_rt();
- using PropIter = Properties::const_iterator;
-
- PropIter index_i = _properties.find(uris.lv2_index);
- int32_t index = 0;
+ auto index_i = _properties.find(uris.lv2_index);
+ int32_t index = 0;
if (index_i != _properties.end()) {
// Ensure given index is sane and not taken
if (index_i->second.type() != uris.forge.Int) {
@@ -144,7 +141,7 @@ CreatePort::pre_process(PreProcessContext&)
_engine.world().forge().make(index));
}
- const PropIter poly_i = _properties.find(uris.ingen_polyphonic);
+ const auto poly_i = _properties.find(uris.ingen_polyphonic);
const bool polyphonic = (poly_i != _properties.end() &&
poly_i->second.type() == uris.forge.Bool &&
poly_i->second.get<int32_t>());
@@ -213,7 +210,7 @@ CreatePort::execute(RunContext& ctx)
void
CreatePort::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->put(path_to_uri(_path), _update);
}
@@ -225,6 +222,4 @@ CreatePort::undo(Interface& target)
target.del(_graph_port->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index 73746434..6d3e9ca2 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -27,10 +27,9 @@
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
-#include <boost/optional/optional.hpp>
-
#include <cstdint>
#include <memory>
+#include <optional>
namespace ingen {
@@ -74,14 +73,14 @@ private:
raul::Path _path;
PortType _port_type;
- LV2_URID _buf_type;
- GraphImpl* _graph;
- DuplexPort* _graph_port;
+ LV2_URID _buf_type{0};
+ GraphImpl* _graph{nullptr};
+ DuplexPort* _graph_port{nullptr};
raul::managed_ptr<BlockImpl::Ports> _ports_array; ///< New external port array for Graph
- EnginePort* _engine_port; ///< Driver port if on the root
+ EnginePort* _engine_port{nullptr}; ///< Driver port if on the root
Properties _properties;
Properties _update;
- boost::optional<Flow> _flow;
+ std::optional<Flow> _flow;
};
} // namespace events
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index cd045820..62653752 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -38,7 +38,6 @@
#include "ingen/URI.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
-#include "ingen/memory.hpp"
#include "ingen/paths.hpp"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
@@ -49,9 +48,9 @@
#include <memory>
#include <mutex>
#include <string>
+#include <string_view>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class RunContext;
@@ -63,8 +62,6 @@ Delete::Delete(Engine& engine,
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);
@@ -73,7 +70,7 @@ Delete::Delete(Engine& engine,
Delete::~Delete()
{
- for (ControlBindings::Binding* b : _removed_bindings) {
+ for (auto* b : _removed_bindings) {
delete b;
}
}
@@ -107,23 +104,23 @@ Delete::pre_process(PreProcessContext& ctx)
}
// Take a writer lock while we modify the store
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
_engine.store()->remove(iter, _removed_objects);
if (_block) {
parent->remove_block(*_block);
_disconnect_event =
- make_unique<DisconnectAll>(_engine, parent, _block.get());
+ std::make_unique<DisconnectAll>(_engine, parent, _block.get());
_disconnect_event->pre_process(ctx);
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
+ _compiled_graph = ctx.maybe_compile(*parent);
} else if (_port) {
parent->remove_port(*_port);
_disconnect_event =
- make_unique<DisconnectAll>(_engine, parent, _port.get());
+ std::make_unique<DisconnectAll>(_engine, parent, _port.get());
_disconnect_event->pre_process(ctx);
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
+ _compiled_graph = ctx.maybe_compile(*parent);
if (parent->enabled()) {
_ports_array = parent->build_ports_array(*_engine.maid());
assert(_ports_array->size() == parent->num_ports_non_rt());
@@ -166,7 +163,7 @@ Delete::execute(RunContext& ctx)
}
GraphImpl* parent = _block ? _block->parent_graph() : nullptr;
- if (_port) {
+ if (_ports_array && _port) {
// Adjust port indices if necessary
for (size_t i = 0; i < _ports_array->size(); ++i) {
PortImpl* const port = _ports_array->at(i);
@@ -185,14 +182,14 @@ Delete::execute(RunContext& ctx)
}
if (parent && _compiled_graph) {
- parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = parent->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
Delete::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && (_block || _port)) {
if (_block) {
_block->deactivate();
@@ -235,5 +232,4 @@ Delete::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 50a925b5..87cde2c7 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -17,7 +17,6 @@
#ifndef INGEN_EVENTS_DELETE_HPP
#define INGEN_EVENTS_DELETE_HPP
-#include "BlockImpl.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
#include "GraphImpl.hpp"
@@ -31,6 +30,7 @@
#include <cstdint>
#include <map>
#include <memory>
+#include <string>
#include <utility>
#include <vector>
@@ -40,6 +40,7 @@ class Interface;
namespace server {
+class BlockImpl;
class CompiledGraph;
class DuplexPort;
class Engine;
@@ -77,9 +78,9 @@ private:
raul::Path _path;
std::shared_ptr<BlockImpl> _block; ///< Non-null iff a block
std::shared_ptr<DuplexPort> _port; ///< Non-null iff a port
- EnginePort* _engine_port;
+ EnginePort* _engine_port{nullptr};
raul::managed_ptr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
- raul::managed_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order
+ std::unique_ptr<CompiledGraph> _compiled_graph; ///< Graph's new process order
std::unique_ptr<DisconnectAll> _disconnect_event;
Store::Objects _removed_objects;
IndexChanges _port_index_changes;
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
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 726d8b48..ed04f8c9 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -20,20 +20,22 @@
#include "ClientUpdate.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
+#include "SetPortValue.hpp"
#include "State.hpp"
#include "types.hpp"
#include "ingen/Properties.hpp"
#include "ingen/Resource.hpp"
#include "ingen/URI.hpp"
-#include "raul/Maid.hpp"
-
-#include <boost/optional/optional.hpp>
#include <cstdint>
#include <memory>
+#include <optional>
#include <vector>
+// IWYU pragma: no_include "CompiledGraph.hpp"
+// IWYU pragma: no_include <algorithm>
+
namespace ingen {
class Interface;
@@ -43,7 +45,7 @@ struct SetProperty;
namespace server {
-class CompiledGraph;
+class CompiledGraph; // IWYU pragma: keep
class Engine;
class GraphImpl;
class PreProcessContext;
@@ -51,8 +53,6 @@ class RunContext;
namespace events {
-class SetPortValue;
-
/** Set properties of a graph object.
* \ingroup engine
*/
@@ -115,10 +115,10 @@ private:
Properties _properties;
Properties _remove;
ClientUpdate _update;
- ingen::Resource* _object;
- GraphImpl* _graph;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
- ControlBindings::Binding* _binding;
+ ingen::Resource* _object{nullptr};
+ GraphImpl* _graph{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
+ ControlBindings::Binding* _binding{nullptr};
StatePtr _state;
Resource::Graph _context;
Type _type;
@@ -128,9 +128,9 @@ private:
std::vector<ControlBindings::Binding*> _removed_bindings;
- boost::optional<Resource> _preset;
+ std::optional<Resource> _preset;
- bool _block;
+ bool _block{false};
};
} // namespace events
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 93e271af..e0db262a 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -35,20 +35,19 @@
#include "ingen/Node.hpp"
#include "ingen/Status.hpp"
#include "ingen/Store.hpp"
-#include "ingen/memory.hpp"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
#include <cassert>
#include <cstdint>
+#include <memory>
#include <mutex>
#include <set>
#include <string>
#include <utility>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class RunContext;
@@ -60,9 +59,7 @@ Disconnect::Disconnect(Engine& engine,
const ingen::Disconnect& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _graph(nullptr)
-{
-}
+{}
Disconnect::~Disconnect() = default;
@@ -120,7 +117,7 @@ Disconnect::Impl::Impl(Engine& e,
bool
Disconnect::pre_process(PreProcessContext& ctx)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
if (_msg.tail.parent().parent() != _msg.head.parent().parent()
&& _msg.tail.parent() != _msg.head.parent().parent()
@@ -159,7 +156,9 @@ Disconnect::pre_process(PreProcessContext& ctx)
if (!_graph) {
return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.head);
- } else if (!_graph->has_arc(tail, head)) {
+ }
+
+ if (!_graph->has_arc(tail, head)) {
return Event::pre_process_done(Status::NOT_FOUND, _msg.head);
}
@@ -167,12 +166,12 @@ Disconnect::pre_process(PreProcessContext& ctx)
return Event::pre_process_done(Status::PARENT_NOT_FOUND, _msg.head);
}
- _impl = make_unique<Impl>(_engine,
- _graph,
- dynamic_cast<PortImpl*>(tail),
- dynamic_cast<InputPort*>(head));
+ _impl = std::make_unique<Impl>(_engine,
+ _graph,
+ dynamic_cast<PortImpl*>(tail),
+ dynamic_cast<InputPort*>(head));
- _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
+ _compiled_graph = ctx.maybe_compile(*_graph);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -209,7 +208,8 @@ Disconnect::execute(RunContext& ctx)
if (_status == Status::SUCCESS) {
if (_impl->execute(ctx, true)) {
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph =
+ _graph->swap_compiled_graph(std::move(_compiled_graph));
}
} else {
_status = Status::NOT_FOUND;
@@ -220,7 +220,7 @@ Disconnect::execute(RunContext& ctx)
void
Disconnect::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -233,5 +233,4 @@ Disconnect::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index a835ed27..ad3d07b0 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -61,14 +61,15 @@ public:
void post_process() override;
void undo(Interface& target) override;
- class Impl {
+ class Impl
+ {
public:
Impl(Engine& e, GraphImpl* graph, PortImpl* t, InputPort* h);
bool execute(RunContext& ctx, bool set_head_buffers);
- inline PortImpl* tail() { return _tail; }
- inline InputPort* head() { return _head; }
+ PortImpl* tail() { return _tail; }
+ InputPort* head() { return _head; }
private:
Engine& _engine;
@@ -80,9 +81,9 @@ public:
private:
const ingen::Disconnect _msg;
- GraphImpl* _graph;
+ GraphImpl* _graph{nullptr};
std::unique_ptr<Impl> _impl;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 86a38d7b..5f0e9a5e 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -32,17 +32,13 @@
#include "ingen/Node.hpp"
#include "ingen/Status.hpp"
#include "ingen/Store.hpp"
-#include "raul/Maid.hpp"
-#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
DisconnectAll::DisconnectAll(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -54,8 +50,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _block(nullptr)
, _port(nullptr)
, _deleting(false)
-{
-}
+{}
/** Internal version for use by other events.
*/
@@ -68,8 +63,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _block(dynamic_cast<BlockImpl*>(object))
, _port(dynamic_cast<PortImpl*>(object))
, _deleting(true)
-{
-}
+{}
DisconnectAll::~DisconnectAll()
{
@@ -113,32 +107,29 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
}
}
- // Find set of arcs to remove
- std::set<ArcImpl*> to_remove;
- for (const auto& a : _parent->arcs()) {
- auto* const arc = static_cast<ArcImpl*>(a.second.get());
- if (_block) {
- if (arc->tail()->parent_block() == _block
- || arc->head()->parent_block() == _block) {
- to_remove.insert(arc);
- }
- } else if (_port) {
- if (arc->tail() == _port || arc->head() == _port) {
- to_remove.insert(arc);
- }
- }
+ // Create disconnect events to erase adjacent arcs in parent
+ for (const auto& a : adjacent_arcs(_parent)) {
+ _impls.push_back(
+ new Disconnect::Impl(_engine,
+ _parent,
+ dynamic_cast<PortImpl*>(a->tail()),
+ dynamic_cast<InputPort*>(a->head())));
}
- // Create disconnect events (which erases from _parent->arcs())
- for (const auto& a : to_remove) {
- _impls.push_back(new Disconnect::Impl(
- _engine, _parent,
- dynamic_cast<PortImpl*>(a->tail()),
- dynamic_cast<InputPort*>(a->head())));
+ // Create disconnect events to erase adjacent arcs in parent's parent
+ if (_port && _parent->parent()) {
+ auto* const parent_parent = dynamic_cast<GraphImpl*>(_parent->parent());
+ for (const auto& a : adjacent_arcs(parent_parent)) {
+ _impls.push_back(
+ new Disconnect::Impl(_engine,
+ parent_parent,
+ dynamic_cast<PortImpl*>(a->tail()),
+ dynamic_cast<InputPort*>(a->head())));
+ }
}
if (!_deleting && ctx.must_compile(*_parent)) {
- if (!(_compiled_graph = compile(*_engine.maid(), *_parent))) {
+ if (!(_compiled_graph = compile(*_parent))) {
return Event::pre_process_done(Status::COMPILATION_FAILED);
}
}
@@ -157,14 +148,14 @@ DisconnectAll::execute(RunContext& ctx)
}
if (_compiled_graph) {
- _parent->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _parent->swap_compiled_graph(std::move(_compiled_graph));
}
}
void
DisconnectAll::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -178,6 +169,25 @@ DisconnectAll::undo(Interface& target)
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+std::set<ArcImpl*>
+DisconnectAll::adjacent_arcs(GraphImpl* const graph)
+{
+ std::set<ArcImpl*> arcs;
+ for (const auto& a : graph->arcs()) {
+ auto* const arc = static_cast<ArcImpl*>(a.second.get());
+ if (_block) {
+ if (arc->tail()->parent_block() == _block
+ || arc->head()->parent_block() == _block) {
+ arcs.insert(arc);
+ }
+ } else if (_port) {
+ if (arc->tail() == _port || arc->head() == _port) {
+ arcs.insert(arc);
+ }
+ }
+ }
+
+ return arcs;
+}
+
+} // namespace ingen::server::events
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index a527dc34..aeb180de 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -22,10 +22,10 @@
#include "types.hpp"
#include "ingen/Message.hpp"
-#include "raul/Maid.hpp"
#include <list>
#include <memory>
+#include <set>
namespace ingen {
@@ -34,6 +34,7 @@ class Node;
namespace server {
+class ArcImpl;
class BlockImpl;
class CompiledGraph;
class Engine;
@@ -70,12 +71,14 @@ public:
private:
using Impls = std::list<Disconnect::Impl*>;
+ std::set<ArcImpl*> adjacent_arcs(GraphImpl* graph);
+
const ingen::DisconnectAll _msg;
GraphImpl* _parent;
BlockImpl* _block;
PortImpl* _port;
Impls _impls;
- raul::managed_ptr<CompiledGraph> _compiled_graph;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
bool _deleting;
};
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 219af6fe..9efef123 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -37,9 +37,7 @@
#include <memory>
#include <mutex>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Get::Get(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -47,22 +45,24 @@ Get::Get(Engine& engine,
const ingen::Get& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _object(nullptr)
- , _plugin(nullptr)
{}
bool
Get::pre_process(PreProcessContext&)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
const auto& uri = _msg.subject;
if (uri == "ingen:/plugins") {
_plugins = _engine.block_factory()->plugins();
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri == "ingen:/engine") {
+ }
+
+ if (uri == "ingen:/engine") {
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri_is_path(uri)) {
+ }
+
+ if (uri_is_path(uri)) {
if ((_object = _engine.store()->get(uri_to_path(uri)))) {
const BlockImpl* block = nullptr;
const GraphImpl* graph = nullptr;
@@ -79,23 +79,24 @@ Get::pre_process(PreProcessContext&)
return Event::pre_process_done(Status::SUCCESS);
}
return Event::pre_process_done(Status::NOT_FOUND, uri);
- } else if ((_plugin = _engine.block_factory()->plugin(uri))) {
+ }
+
+ if ((_plugin = _engine.block_factory()->plugin(uri))) {
_response.put_plugin(_plugin);
return Event::pre_process_done(Status::SUCCESS);
- } else {
- return Event::pre_process_done(Status::NOT_FOUND, uri);
}
+
+ return Event::pre_process_done(Status::NOT_FOUND, uri);
}
void
Get::execute(RunContext&)
-{
-}
+{}
void
Get::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && _request_client) {
if (_msg.subject == "ingen:/plugins") {
_engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins);
@@ -119,6 +120,4 @@ Get::post_process()
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index fd3f8569..1ec49bfa 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -58,8 +58,8 @@ public:
private:
const ingen::Get _msg;
- const Node* _object;
- PluginImpl* _plugin;
+ const Node* _object{nullptr};
+ PluginImpl* _plugin{nullptr};
BlockFactory::Plugins _plugins;
ClientUpdate _response;
};
diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp
index 27ca6630..87bc1035 100644
--- a/src/server/events/Mark.cpp
+++ b/src/server/events/Mark.cpp
@@ -30,9 +30,7 @@
#include <unordered_set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Mark::Mark(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -86,7 +84,7 @@ Mark::pre_process(PreProcessContext& ctx)
ctx.set_in_bundle(false);
if (!ctx.dirty_graphs().empty()) {
for (GraphImpl* g : ctx.dirty_graphs()) {
- auto cg = compile(*_engine.maid(), *g);
+ auto cg = compile(*g);
if (cg) {
_compiled_graphs.emplace(g, std::move(cg));
}
@@ -103,7 +101,7 @@ void
Mark::execute(RunContext&)
{
for (auto& g : _compiled_graphs) {
- g.first->set_compiled_graph(std::move(g.second));
+ g.second = g.first->swap_compiled_graph(std::move(g.second));
}
}
@@ -136,6 +134,4 @@ Mark::get_execution() const
return Execution::NORMAL;
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp
index 7ebab080..eb99c5a9 100644
--- a/src/server/events/Mark.hpp
+++ b/src/server/events/Mark.hpp
@@ -20,11 +20,11 @@
#include "Event.hpp"
#include "types.hpp"
-#include "raul/Maid.hpp"
-
#include <map>
#include <memory>
+// IWYU pragma: no_include "CompiledGraph.hpp"
+
namespace ingen {
class Interface;
@@ -33,7 +33,7 @@ struct BundleEnd;
namespace server {
-class CompiledGraph;
+class CompiledGraph; // IWYU pragma: keep
class Engine;
class GraphImpl;
class PreProcessContext;
@@ -73,8 +73,7 @@ public:
private:
enum class Type { BUNDLE_BEGIN, BUNDLE_END };
- using CompiledGraphs =
- std::map<GraphImpl*, raul::managed_ptr<CompiledGraph>>;
+ using CompiledGraphs = std::map<GraphImpl*, std::unique_ptr<CompiledGraph>>;
CompiledGraphs _compiled_graphs;
Type _type;
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index d85451c8..3af0ce6c 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -14,10 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "events/Move.hpp"
+
#include "Broadcaster.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
-#include "events/Move.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Status.hpp"
@@ -28,8 +29,7 @@
#include <memory>
#include <mutex>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class EnginePort;
@@ -41,19 +41,18 @@ Move::Move(Engine& engine,
const ingen::Move& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
-{
-}
+{}
bool
Move::pre_process(PreProcessContext&)
{
- std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
+ const std::lock_guard<Store::Mutex> lock{_engine.store()->mutex()};
if (!_msg.old_path.parent().is_parent_of(_msg.new_path)) {
return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path);
}
- const Store::iterator i = _engine.store()->find(_msg.old_path);
+ const auto i = _engine.store()->find(_msg.old_path);
if (i == _engine.store()->end()) {
return Event::pre_process_done(Status::NOT_FOUND, _msg.old_path);
}
@@ -74,13 +73,12 @@ Move::pre_process(PreProcessContext&)
void
Move::execute(RunContext&)
-{
-}
+{}
void
Move::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -93,5 +91,4 @@ Move::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index a1b5bafa..04da7338 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -33,9 +33,7 @@
#include <cassert>
#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
/** Internal */
SetPortValue::SetPortValue(Engine& engine,
@@ -51,13 +49,12 @@ SetPortValue::SetPortValue(Engine& engine,
, _value(value)
, _activity(activity)
, _synthetic(synthetic)
-{
-}
+{}
bool
SetPortValue::pre_process(PreProcessContext&)
{
- ingen::URIs& uris = _engine.world().uris();
+ const ingen::URIs& uris = _engine.world().uris();
if (_port->is_output()) {
return Event::pre_process_done(Status::DIRECTION_MISMATCH, _port->path());
}
@@ -95,8 +92,8 @@ SetPortValue::apply(RunContext& ctx)
return;
}
- ingen::URIs& uris = _engine.world().uris();
- Buffer* buf = _port->buffer(0).get();
+ const ingen::URIs& uris = _engine.world().uris();
+ Buffer* buf = _port->buffer(0).get();
if (_buffer) {
if (_port->user_buffer(ctx)) {
@@ -130,7 +127,7 @@ SetPortValue::apply(RunContext& ctx)
void
SetPortValue::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS && !_activity) {
_engine.broadcaster()->set_property(
_port->uri(),
@@ -139,6 +136,4 @@ SetPortValue::post_process()
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp
index 3c91235d..ea8c7d69 100644
--- a/src/server/events/Undo.cpp
+++ b/src/server/events/Undo.cpp
@@ -28,9 +28,7 @@
#include <deque>
#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
Undo::Undo(Engine& engine,
const std::shared_ptr<Interface>& client,
@@ -81,8 +79,7 @@ Undo::pre_process(PreProcessContext&)
void
Undo::execute(RunContext&)
-{
-}
+{}
void
Undo::post_process()
@@ -90,6 +87,4 @@ Undo::post_process()
respond();
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events