summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp56
-rw-r--r--src/server/events/Connect.hpp44
-rw-r--r--src/server/events/Copy.cpp113
-rw-r--r--src/server/events/Copy.hpp33
-rw-r--r--src/server/events/CreateBlock.cpp108
-rw-r--r--src/server/events/CreateBlock.hpp39
-rw-r--r--src/server/events/CreateGraph.cpp148
-rw-r--r--src/server/events/CreateGraph.hpp41
-rw-r--r--src/server/events/CreatePort.cpp116
-rw-r--r--src/server/events/CreatePort.hpp49
-rw-r--r--src/server/events/Delete.cpp79
-rw-r--r--src/server/events/Delete.hpp51
-rw-r--r--src/server/events/Delta.cpp167
-rw-r--r--src/server/events/Delta.hpp93
-rw-r--r--src/server/events/Disconnect.cpp79
-rw-r--r--src/server/events/Disconnect.hpp52
-rw-r--r--src/server/events/DisconnectAll.cpp137
-rw-r--r--src/server/events/DisconnectAll.hpp43
-rw-r--r--src/server/events/Get.cpp68
-rw-r--r--src/server/events/Get.hpp26
-rw-r--r--src/server/events/Mark.cpp48
-rw-r--r--src/server/events/Mark.hpp31
-rw-r--r--src/server/events/Move.cpp46
-rw-r--r--src/server/events/Move.hpp22
-rw-r--r--src/server/events/SetPortValue.cpp71
-rw-r--r--src/server/events/SetPortValue.hpp28
-rw-r--r--src/server/events/Undo.cpp42
-rw-r--r--src/server/events/Undo.hpp28
28 files changed, 1053 insertions, 805 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index dd5b32a9..6e20be8f 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -16,42 +16,50 @@
#include "Connect.hpp"
+#include "../internals/BlockDelay.hpp"
#include "ArcImpl.hpp"
+#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "BufferFactory.hpp"
+#include "CompiledGraph.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "InputPort.hpp"
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "internals/BlockDelay.hpp"
#include "types.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Maid.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Maid.hpp>
#include <cassert>
+#include <memory>
#include <mutex>
+#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-Connect::Connect(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Connect& msg)
- : Event(engine, client, msg.seq, timestamp)
- , _msg(msg)
- , _graph(nullptr)
- , _head(nullptr)
+namespace ingen::server::events {
+
+Connect::Connect(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Connect& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
{}
+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) {
@@ -126,7 +134,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);
@@ -150,16 +158,16 @@ Connect::pre_process(PreProcessContext& ctx)
}
void
-Connect::execute(RunContext& context)
+Connect::execute(RunContext& ctx)
{
if (_status == Status::SUCCESS) {
- _head->add_arc(context, *_arc.get());
+ _head->add_arc(ctx, *_arc);
if (!_head->is_driver_port()) {
- _head->set_voices(context, std::move(_voices));
+ _head->set_voices(ctx, std::move(_voices));
}
_head->connect_buffers();
if (_compiled_graph) {
- _graph->set_compiled_graph(std::move(_compiled_graph));
+ _compiled_graph = _graph->swap_compiled_graph(std::move(_compiled_graph));
}
}
}
@@ -167,7 +175,7 @@ Connect::execute(RunContext& context)
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()) {
@@ -187,6 +195,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 adc80afc..458df0ef 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -17,15 +17,25 @@
#ifndef INGEN_EVENTS_CONNECT_HPP
#define INGEN_EVENTS_CONNECT_HPP
-#include "CompiledGraph.hpp"
#include "Event.hpp"
#include "PortImpl.hpp"
#include "types.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Properties.hpp>
+#include <raul/Maid.hpp>
+
+#include <memory>
+
namespace ingen {
+
+class Interface;
+
namespace server {
class ArcImpl;
+class CompiledGraph;
+class Engine;
class GraphImpl;
class InputPort;
@@ -38,27 +48,29 @@ namespace events {
class Connect : public Event
{
public:
- Connect(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Connect& msg);
+ Connect(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Connect& msg);
+
+ ~Connect() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
private:
- const ingen::Connect _msg;
- GraphImpl* _graph;
- InputPort* _head;
- MPtr<CompiledGraph> _compiled_graph;
- SPtr<ArcImpl> _arc;
- MPtr<PortImpl::Voices> _voices;
- Properties _tail_remove;
- Properties _tail_add;
- Properties _head_remove;
- Properties _head_add;
+ const ingen::Connect _msg;
+ 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;
+ Properties _tail_add;
+ Properties _head_remove;
+ Properties _head_add;
};
} // namespace events
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 5418af4b..e75bf1c5 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -14,75 +14,88 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Copy.hpp"
+#include "Copy.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
+#include "CompiledGraph.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "PreProcessContext.hpp"
-#include "ingen/Parser.hpp"
-#include "ingen/Serialiser.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/World.hpp"
-#include "raul/Path.hpp"
-
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Parser.hpp>
+#include <ingen/Serialiser.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/World.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
+
+#include <map>
+#include <memory>
#include <mutex>
+#include <optional>
#include <string>
+#include <string_view>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-Copy::Copy(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Copy& msg)
- : Event(engine, client, msg.seq, timestamp)
- , _msg(msg)
- , _old_block(nullptr)
- , _parent(nullptr)
- , _block(nullptr)
+namespace ingen::server::events {
+
+Copy::Copy(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Copy& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
{}
+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);
+ 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);
}
// Ensure it is a block (ports are not supported for now)
- if (!(_old_block = dynamic_ptr_cast<BlockImpl>(i->second))) {
+ if (!(_old_block = std::dynamic_pointer_cast<BlockImpl>(i->second))) {
return Event::pre_process_done(Status::BAD_OBJECT_TYPE, old_path);
}
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);
@@ -92,8 +105,8 @@ bool
Copy::engine_to_engine(PreProcessContext& ctx)
{
// Only support a single source for now
- const Raul::Path new_path = uri_to_path(_msg.new_uri);
- if (!Raul::Symbol::is_valid(new_path.symbol())) {
+ const raul::Path new_path = uri_to_path(_msg.new_uri);
+ if (!raul::Symbol::is_valid(new_path.symbol())) {
return Event::pre_process_done(Status::BAD_REQUEST);
}
@@ -103,8 +116,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);
}
@@ -113,8 +126,7 @@ Copy::engine_to_engine(PreProcessContext& ctx)
}
// Create new block
- if (!(_block = dynamic_cast<BlockImpl*>(
- _old_block->duplicate(_engine, Raul::Symbol(new_path.symbol()), _parent)))) {
+ if (!(_block = _old_block->duplicate(_engine, raul::Symbol(new_path.symbol()), _parent))) {
return Event::pre_process_done(Status::INTERNAL_ERROR);
}
@@ -125,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);
}
@@ -143,7 +155,7 @@ bool
Copy::engine_to_filesystem(PreProcessContext&)
{
// Ensure source is a graph
- SPtr<GraphImpl> graph = dynamic_ptr_cast<GraphImpl>(_old_block);
+ auto graph = std::dynamic_pointer_cast<GraphImpl>(_old_block);
if (!graph) {
return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _msg.old_uri);
}
@@ -152,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));
@@ -173,16 +185,16 @@ 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());
+ dst_symbol = raul::Symbol(dst_path.symbol());
}
_engine.world().parser()->parse_file(
@@ -196,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);
}
@@ -217,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 26673a55..8031bb42 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -17,15 +17,24 @@
#ifndef INGEN_EVENTS_COPY_HPP
#define INGEN_EVENTS_COPY_HPP
-#include "CompiledGraph.hpp"
#include "Event.hpp"
+#include "types.hpp"
+
+#include <ingen/Message.hpp>
+
+#include <memory>
namespace ingen {
+
+class Interface;
+
namespace server {
class BlockImpl;
+class CompiledGraph;
class Engine;
class GraphImpl;
+class PreProcessContext;
namespace events {
@@ -35,13 +44,15 @@ namespace events {
class Copy : public Event
{
public:
- Copy(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Copy& msg);
+ Copy(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Copy& msg);
+
+ ~Copy() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
@@ -50,11 +61,11 @@ private:
bool engine_to_filesystem(PreProcessContext& ctx);
bool filesystem_to_engine(PreProcessContext& ctx);
- const ingen::Copy _msg;
- SPtr<BlockImpl> _old_block;
- GraphImpl* _parent;
- BlockImpl* _block;
- MPtr<CompiledGraph> _compiled_graph;
+ const ingen::Copy _msg;
+ 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 4b48cfde..55c9b782 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -19,57 +19,71 @@
#include "BlockFactory.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
+#include "CompiledGraph.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "LV2Block.hpp"
#include "PluginImpl.hpp"
#include "PreProcessContext.hpp"
-
-#include "ingen/Forge.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
+#include "State.hpp"
+#include "types.hpp"
+
+#include <ingen/FilePath.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 <map>
+#include <memory>
+#include <string>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-CreateBlock::CreateBlock(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- Properties& properties)
- : Event(engine, client, id, timestamp)
- , _path(path)
- , _properties(properties)
- , _graph(nullptr)
- , _block(nullptr)
+namespace ingen::server::events {
+
+CreateBlock::CreateBlock(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ Properties& properties)
+ : Event(engine, client, id, timestamp)
+ , _path(std::move(path))
+ , _properties(properties)
{}
+CreateBlock::~CreateBlock() = default;
+
bool
CreateBlock::pre_process(PreProcessContext& ctx)
{
- using iterator = Properties::const_iterator;
-
- const ingen::URIs& uris = _engine.world().uris();
- const SPtr<Store> store = _engine.store();
+ 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;
@@ -79,7 +93,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);
@@ -88,10 +102,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)) {
@@ -100,8 +114,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);
}
@@ -119,7 +136,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
}
// Load state from directory if given in properties
- LilvState* state = nullptr;
+ StatePtr state{};
auto s = _properties.find(uris.state_state);
if (s != _properties.end() && s->second.type() == uris.forge.Path) {
state = LV2Block::load_state(
@@ -128,11 +145,11 @@ CreateBlock::pre_process(PreProcessContext& ctx)
// Instantiate plugin
if (!(_block = plugin->instantiate(*_engine.buffer_factory(),
- Raul::Symbol(_path.symbol()),
+ raul::Symbol(_path.symbol()),
polyphonic,
_graph,
_engine,
- state))) {
+ state.get()))) {
return Event::pre_process_done(Status::CREATION_FAILED, _path);
}
}
@@ -148,7 +165,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);
@@ -159,14 +176,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());
}
@@ -178,6 +196,4 @@ CreateBlock::undo(Interface& target)
target.del(_block->uri());
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index 00f58008..0ee6e36f 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -18,15 +18,24 @@
#define INGEN_EVENTS_CREATEBLOCK_HPP
#include "ClientUpdate.hpp"
-#include "CompiledGraph.hpp"
#include "Event.hpp"
+#include "types.hpp"
+
+#include <raul/Path.hpp>
#include <cstdint>
+#include <memory>
namespace ingen {
+
+class Interface;
+class Properties;
+
namespace server {
class BlockImpl;
+class CompiledGraph;
+class Engine;
class GraphImpl;
namespace events {
@@ -38,25 +47,27 @@ namespace events {
class CreateBlock : public Event
{
public:
- CreateBlock(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- Properties& properties);
+ CreateBlock(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ Properties& properties);
+
+ ~CreateBlock() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
private:
- Raul::Path _path;
- Properties& _properties;
- ClientUpdate _update;
- GraphImpl* _graph;
- BlockImpl* _block;
- MPtr<CompiledGraph> _compiled_graph;
+ raul::Path _path;
+ Properties& _properties;
+ ClientUpdate _update;
+ 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 3e847bdd..5df28afa 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -14,40 +14,53 @@
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 "ingen/Forge.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
-
+#include "types.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 {
-
-CreateGraph::CreateGraph(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Properties& properties)
- : Event(engine, client, id, timestamp)
- , _path(path)
- , _properties(properties)
- , _graph(nullptr)
- , _parent(nullptr)
+namespace ingen::server::events {
+
+CreateGraph::CreateGraph(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ Properties properties)
+ : Event(engine, client, id, timestamp)
+ , _path(std::move(path))
+ , _properties(std::move(properties))
{}
+CreateGraph::~CreateGraph() = default;
+
void
CreateGraph::build_child_events()
{
@@ -67,30 +80,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
@@ -101,7 +124,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
}
if (!_path.is_root()) {
- const Raul::Path up(_path.parent());
+ const raul::Path up(_path.parent());
if (!(_parent = dynamic_cast<GraphImpl*>(_engine.store()->get(up)))) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND, up);
}
@@ -109,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>();
}
@@ -126,33 +147,39 @@ CreateGraph::pre_process(PreProcessContext& ctx)
ext_poly = int_poly;
}
- const Raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol());
+ 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->add_property(uris.rdf_type, uris.ingen_Graph.urid);
+ _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,
Resource::Graph::EXTERNAL));
@@ -166,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());
@@ -188,12 +215,13 @@ CreateGraph::pre_process(PreProcessContext& ctx)
}
void
-CreateGraph::execute(RunContext& context)
+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);
@@ -201,7 +229,7 @@ CreateGraph::execute(RunContext& context)
}
for (const auto& ev : _child_events) {
- ev->execute(context);
+ ev->execute(ctx);
}
}
}
@@ -209,7 +237,7 @@ CreateGraph::execute(RunContext& context)
void
CreateGraph::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_update.send(*_engine.broadcaster());
}
@@ -227,6 +255,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 dadb644e..1d7f04a5 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -18,17 +18,24 @@
#define INGEN_EVENTS_CREATEGRAPH_HPP
#include "ClientUpdate.hpp"
-#include "CompiledGraph.hpp"
#include "Event.hpp"
+#include "types.hpp"
-#include "ingen/types.hpp"
+#include <ingen/Properties.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
#include <list>
+#include <memory>
namespace ingen {
+
+class Interface;
+
namespace server {
+class CompiledGraph;
+class Engine;
class GraphImpl;
namespace events {
@@ -40,15 +47,17 @@ namespace events {
class CreateGraph : public Event
{
public:
- CreateGraph(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Properties& properties);
+ CreateGraph(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ Properties properties);
+
+ ~CreateGraph() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
@@ -57,13 +66,13 @@ public:
private:
void build_child_events();
- const Raul::Path _path;
- Properties _properties;
- ClientUpdate _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
- MPtr<CompiledGraph> _compiled_graph;
- std::list<UPtr<Event>> _child_events;
+ const raul::Path _path;
+ Properties _properties;
+ ClientUpdate _update;
+ GraphImpl* _graph{nullptr};
+ GraphImpl* _parent{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
+ std::list<std::unique_ptr<Event>> _child_events;
};
} // namespace events
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index d0dcbaf3..b42542f8 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -23,45 +23,47 @@
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "PortImpl.hpp"
-
-#include "ingen/Atom.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIMap.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Array.hpp"
-#include "raul/Path.hpp"
+#include "PortType.hpp"
+
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIMap.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/paths.hpp>
+#include <raul/Array.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
+#include <raul/Symbol.hpp>
#include <cassert>
+#include <map>
+#include <memory>
+#include <string>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-CreatePort::CreatePort(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Properties& properties)
- : Event(engine, client, id, timestamp)
- , _path(path)
- , _port_type(PortType::UNKNOWN)
- , _buf_type(0)
- , _graph(nullptr)
- , _graph_port(nullptr)
- , _engine_port(nullptr)
- , _properties(properties)
+namespace ingen::server::events {
+
+CreatePort::CreatePort(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ const Properties& properties)
+ : Event(engine, client, id, timestamp)
+ , _path(std::move(path))
+ , _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;
@@ -78,8 +80,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));
@@ -92,20 +94,28 @@ 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);
}
- const Raul::Path parent_path = _path.parent();
+ const raul::Path parent_path = _path.parent();
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);
}
@@ -114,10 +124,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) {
@@ -135,7 +143,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>());
@@ -147,7 +155,7 @@ CreatePort::pre_process(PreProcessContext&)
}
// Create port
- _graph_port = new DuplexPort(bufs, _graph, Raul::Symbol(_path.symbol()),
+ _graph_port = new DuplexPort(bufs, _graph, raul::Symbol(_path.symbol()),
index,
polyphonic,
_port_type, _buf_type, buf_size,
@@ -172,18 +180,18 @@ CreatePort::pre_process(PreProcessContext&)
_update = _graph_port->properties();
- assert(_graph_port->index() == (uint32_t)index_i->second.get<int32_t>());
- assert(_graph->num_ports_non_rt() == (uint32_t)old_n_ports + 1);
+ assert(_graph_port->index() == static_cast<uint32_t>(index_i->second.get<int32_t>()));
+ assert(_graph->num_ports_non_rt() == static_cast<uint32_t>(old_n_ports) + 1U);
assert(_ports_array->size() == _graph->num_ports_non_rt());
assert(_graph_port->index() < _ports_array->size());
return Event::pre_process_done(Status::SUCCESS);
}
void
-CreatePort::execute(RunContext& context)
+CreatePort::execute(RunContext& ctx)
{
if (_status == Status::SUCCESS) {
- const MPtr<GraphImpl::Ports>& old_ports = _graph->external_ports();
+ const auto& old_ports = _graph->external_ports();
if (old_ports) {
for (uint32_t i = 0; i < old_ports->size(); ++i) {
const auto* const old_port = (*old_ports)[i];
@@ -196,7 +204,7 @@ CreatePort::execute(RunContext& context)
_graph->set_external_ports(std::move(_ports_array));
if (_engine_port) {
- _engine.driver()->add_port(context, _engine_port);
+ _engine.driver()->add_port(ctx, _engine_port);
}
}
}
@@ -204,7 +212,7 @@ CreatePort::execute(RunContext& context)
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);
}
@@ -216,6 +224,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 8137328d..151bf82f 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -20,18 +20,25 @@
#include "BlockImpl.hpp"
#include "Event.hpp"
#include "PortType.hpp"
+#include "types.hpp"
-#include "lv2/urid/urid.h"
-#include "raul/Path.hpp"
-
-#include <boost/optional/optional.hpp>
+#include <ingen/Properties.hpp>
+#include <lv2/urid/urid.h>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
+#include <memory>
+#include <optional>
namespace ingen {
+
+class Interface;
+
namespace server {
class DuplexPort;
+class Engine;
class EnginePort;
class GraphImpl;
@@ -44,15 +51,15 @@ namespace events {
class CreatePort : public Event
{
public:
- CreatePort(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& path,
- const Properties& properties);
+ CreatePort(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ raul::Path path,
+ const Properties& properties);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
@@ -62,16 +69,16 @@ private:
OUTPUT
};
- Raul::Path _path;
- PortType _port_type;
- LV2_URID _buf_type;
- GraphImpl* _graph;
- DuplexPort* _graph_port;
- MPtr<BlockImpl::Ports> _ports_array; ///< New external port array for Graph
- EnginePort* _engine_port; ///< Driver port if on the root
- Properties _properties;
- Properties _update;
- boost::optional<Flow> _flow;
+ raul::Path _path;
+ PortType _port_type{PortType::UNKNOWN};
+ 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{nullptr}; ///< Driver port if on the root
+ Properties _properties;
+ Properties _update;
+ std::optional<Flow> _flow;
};
} // namespace events
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 5d605bca..9e940ea7 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -19,38 +19,45 @@
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "BufferFactory.hpp"
+#include "CompiledGraph.hpp"
#include "ControlBindings.hpp"
#include "DisconnectAll.hpp"
#include "Driver.hpp"
+#include "DuplexPort.hpp"
#include "Engine.hpp"
#include "EnginePort.hpp"
#include "GraphImpl.hpp"
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.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/Array.hpp>
+#include <raul/Path.hpp>
#include <cassert>
#include <cstddef>
+#include <memory>
#include <mutex>
#include <string>
+#include <string_view>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
-Delete::Delete(Engine& engine,
- const SPtr<Interface>& client,
- FrameTime timestamp,
- const ingen::Del& msg)
+Delete::Delete(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ FrameTime timestamp,
+ 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);
@@ -59,7 +66,7 @@ Delete::Delete(Engine& engine,
Delete::~Delete()
{
- for (ControlBindings::Binding* b : _removed_bindings) {
+ for (auto* b : _removed_bindings) {
delete b;
}
}
@@ -79,8 +86,8 @@ Delete::pre_process(PreProcessContext& ctx)
return Event::pre_process_done(Status::NOT_FOUND, _path);
}
- if (!(_block = dynamic_ptr_cast<BlockImpl>(iter->second))) {
- _port = dynamic_ptr_cast<DuplexPort>(iter->second);
+ if (!(_block = std::dynamic_pointer_cast<BlockImpl>(iter->second))) {
+ _port = std::dynamic_pointer_cast<DuplexPort>(iter->second);
}
if ((!_block && !_port) || (_port && !_engine.driver()->dynamic_ports())) {
@@ -93,23 +100,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());
@@ -121,9 +128,9 @@ Delete::pre_process(PreProcessContext& ctx)
_port_index_changes.emplace(
port->path(), std::make_pair(port->index(), i));
port->remove_property(uris.lv2_index, uris.patch_wildcard);
- port->set_property(
- uris.lv2_index,
- _engine.buffer_factory()->forge().make((int32_t)i));
+ port->set_property(uris.lv2_index,
+ _engine.buffer_factory()->forge().make(
+ static_cast<int32_t>(i)));
}
}
}
@@ -137,27 +144,27 @@ Delete::pre_process(PreProcessContext& ctx)
}
void
-Delete::execute(RunContext& context)
+Delete::execute(RunContext& ctx)
{
if (_status != Status::SUCCESS) {
return;
}
if (_disconnect_event) {
- _disconnect_event->execute(context);
+ _disconnect_event->execute(ctx);
}
if (!_removed_bindings.empty()) {
- _engine.control_bindings()->remove(context, _removed_bindings);
+ _engine.control_bindings()->remove(ctx, _removed_bindings);
}
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);
if (port->index() != i) {
- port->set_index(context, i);
+ port->set_index(ctx, i);
}
}
@@ -166,19 +173,19 @@ Delete::execute(RunContext& context)
parent->set_external_ports(std::move(_ports_array));
if (_engine_port) {
- _engine.driver()->remove_port(context, _engine_port);
+ _engine.driver()->remove_port(ctx, _engine_port);
}
}
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();
@@ -214,12 +221,10 @@ Delete::undo(Interface& target)
if (c.first != _msg.uri.path()) {
target.set_property(path_to_uri(c.first),
uris.lv2_index,
- forge.make(int32_t(c.second.first)));
+ forge.make(static_cast<int32_t>(c.second.first)));
}
}
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 6b3149e9..7e901f4b 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -20,19 +20,32 @@
#include "ControlBindings.hpp"
#include "Event.hpp"
#include "GraphImpl.hpp"
+#include "types.hpp"
-#include "ingen/Store.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Maid.hpp>
+#include <raul/Path.hpp>
#include <cstdint>
#include <map>
+#include <memory>
+#include <string>
#include <utility>
#include <vector>
+// IWYU pragma: no_include <iterator>
+
namespace ingen {
+
+class Interface;
+
namespace server {
+class BlockImpl;
class CompiledGraph;
class DuplexPort;
+class Engine;
class EnginePort;
namespace events {
@@ -45,32 +58,32 @@ class DisconnectAll;
class Delete : public Event
{
public:
- Delete(Engine& engine,
- const SPtr<Interface>& client,
- FrameTime timestamp,
- const ingen::Del& msg);
+ Delete(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ FrameTime timestamp,
+ const ingen::Del& msg);
- ~Delete();
+ ~Delete() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
private:
using IndexChange = std::pair<uint32_t, uint32_t>;
- using IndexChanges = std::map<Raul::Path, IndexChange>;
-
- const ingen::Del _msg;
- Raul::Path _path;
- SPtr<BlockImpl> _block; ///< Non-null iff a block
- SPtr<DuplexPort> _port; ///< Non-null iff a port
- EnginePort* _engine_port;
- MPtr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
- MPtr<CompiledGraph> _compiled_graph; ///< Graph's new process order
- UPtr<DisconnectAll> _disconnect_event;
- Store::Objects _removed_objects;
- IndexChanges _port_index_changes;
+ using IndexChanges = std::map<raul::Path, IndexChange>;
+
+ const ingen::Del _msg;
+ 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{nullptr};
+ raul::managed_ptr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
+ 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;
std::vector<ControlBindings::Binding*> _removed_bindings;
};
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 0a7b05ea..cba21214 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -16,91 +16,87 @@
#include "Delta.hpp"
+#include "BlockFactory.hpp"
+#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
+#include "CompiledGraph.hpp"
#include "ControlBindings.hpp"
#include "CreateBlock.hpp"
#include "CreateGraph.hpp"
#include "CreatePort.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
+#include "NodeImpl.hpp"
#include "PluginImpl.hpp"
#include "PortImpl.hpp"
#include "PortType.hpp"
#include "SetPortValue.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "raul/Maid.hpp"
-
+#include <ingen/Atom.hpp>
+#include <ingen/FilePath.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Message.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 <lilv/lilv.h>
+#include <raul/Path.hpp>
+
+#include <memory>
#include <mutex>
#include <set>
#include <string>
+#include <string_view>
#include <utility>
#include <vector>
-namespace ingen {
-namespace server {
-
-class PreProcessContext;
-
-namespace events {
+namespace ingen::server::events {
-Delta::Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Put& msg)
+Delta::Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ 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(nullptr)
, _context(msg.ctx)
, _type(Type::PUT)
- , _block(false)
{
init();
}
-Delta::Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Delta& msg)
+Delta::Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Delta& msg)
: Event(engine, client, msg.seq, timestamp)
, _create_event(nullptr)
, _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();
}
-Delta::Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::SetProperty& msg)
+Delta::Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::SetProperty& msg)
: 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();
}
@@ -136,7 +132,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));
}
@@ -148,7 +144,7 @@ s_add_set_event(const char* port_symbol,
uint32_t size,
uint32_t type)
{
- ((Delta*)user_data)->add_set_event(port_symbol, value, size, type);
+ static_cast<Delta*>(user_data)->add_set_event(port_symbol, value, size, type);
}
static LilvNode*
@@ -156,12 +152,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;
}
@@ -206,12 +205,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)))
@@ -223,7 +222,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;
@@ -232,19 +231,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);
}
@@ -316,8 +315,8 @@ Delta::pre_process(PreProcessContext& ctx)
const Property& value = p.second;
SpecialType op = SpecialType::NONE;
if (obj) {
- Resource& resource = *obj;
if (value != uris.patch_wildcard) {
+ Resource& resource = *obj;
if (resource.add_property(key, value, value.context())) {
_added.emplace(key, value);
}
@@ -334,7 +333,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) {
@@ -356,7 +355,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;
@@ -377,8 +376,9 @@ Delta::pre_process(PreProcessContext& ctx)
if (!uri.empty()) {
op = SpecialType::PRESET;
if ((_state = block->load_preset(uri))) {
- lilv_state_emit_port_values(
- _state, s_add_set_event, this);
+ lilv_state_emit_port_values(_state.get(),
+ s_add_set_event,
+ this);
} else {
_engine.log().warn("Failed to load preset <%1%>\n", uri);
}
@@ -392,9 +392,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;
}
}
@@ -423,9 +423,8 @@ Delta::pre_process(PreProcessContext& ctx)
} else if (value.type() != uris.forge.Bool) {
_status = Status::BAD_VALUE_TYPE;
} else {
- op = SpecialType::POLYPHONIC;
+ op = SpecialType::POLYPHONIC;
obj->set_property(key, value, value.context());
- auto* block = dynamic_cast<BlockImpl*>(obj);
if (block) {
block->set_polyphonic(value.get<int32_t>());
}
@@ -446,9 +445,9 @@ Delta::pre_process(PreProcessContext& ctx)
lilv_world_load_bundle(lworld, bundle);
const auto new_plugins = _engine.block_factory()->refresh();
- for (const auto& p : new_plugins) {
- if (p->bundle_uri() == lilv_node_as_string(bundle)) {
- _update.put_plugin(p.get());
+ for (const auto& plugin : new_plugins) {
+ if (plugin->bundle_uri() == lilv_node_as_string(bundle)) {
+ _update.put_plugin(plugin.get());
}
}
lilv_node_free(bundle);
@@ -474,7 +473,7 @@ Delta::pre_process(PreProcessContext& ctx)
}
void
-Delta::execute(RunContext& context)
+Delta::execute(RunContext& ctx)
{
if (_status != Status::SUCCESS || _preset) {
return;
@@ -484,23 +483,23 @@ Delta::execute(RunContext& context)
if (_create_event) {
_create_event->set_time(_time);
- _create_event->execute(context);
+ _create_event->execute(ctx);
}
for (auto& s : _set_events) {
s->set_time(_time);
- s->execute(context);
+ s->execute(ctx);
}
if (!_removed_bindings.empty()) {
- _engine.control_bindings()->remove(context, _removed_bindings);
+ _engine.control_bindings()->remove(ctx, _removed_bindings);
}
auto* const object = dynamic_cast<NodeImpl*>(_object);
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;
@@ -514,11 +513,11 @@ Delta::execute(RunContext& context)
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 {
- _graph->disable(context);
+ _graph->disable(ctx);
}
} else if (block) {
block->set_enabled(value.get<int32_t>());
@@ -528,15 +527,15 @@ Delta::execute(RunContext& context)
if (object) {
if (value.get<int32_t>()) {
auto* parent = reinterpret_cast<GraphImpl*>(object->parent());
- object->apply_poly(context, parent->internal_poly_process());
+ object->apply_poly(ctx, parent->internal_poly_process());
} else {
- object->apply_poly(context, 1);
+ object->apply_poly(ctx, 1);
}
}
} break;
case SpecialType::POLYPHONY:
if (_graph &&
- !_graph->apply_internal_poly(context,
+ !_graph->apply_internal_poly(ctx,
*_engine.buffer_factory(),
*_engine.maid(),
value.get<int32_t>())) {
@@ -545,12 +544,12 @@ Delta::execute(RunContext& context)
break;
case SpecialType::PORT_INDEX:
if (port) {
- port->set_index(context, value.get<int32_t>());
+ port->set_index(ctx, value.get<int32_t>());
}
break;
case SpecialType::CONTROL_BINDING:
if (port) {
- if (!_engine.control_bindings()->set_port_binding(context, port, _binding, value)) {
+ if (!_engine.control_bindings()->set_port_binding(ctx, port, _binding, value)) {
_status = Status::BAD_VALUE;
}
} else if (block) {
@@ -572,6 +571,7 @@ Delta::execute(RunContext& context)
port->set_maximum(value);
}
}
+ break;
case SpecialType::LOADED_BUNDLE:
break;
}
@@ -584,24 +584,25 @@ Delta::post_process()
if (_state) {
auto* block = dynamic_cast<BlockImpl*>(_object);
if (block) {
- block->apply_state(_engine.sync_worker(), _state);
+ block->apply_state(_engine.sync_worker(), _state.get());
block->set_enabled(true);
}
- lilv_state_free(_state);
+
+ _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
}
}
@@ -669,6 +670,4 @@ Delta::get_execution() const
return _block ? Execution::ATOMIC : Execution::NORMAL;
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 1dce2663..befbdcc7 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -18,51 +18,58 @@
#define INGEN_EVENTS_DELTA_HPP
#include "ClientUpdate.hpp"
+#include "CompiledGraph.hpp"
#include "ControlBindings.hpp"
#include "Event.hpp"
+#include "SetPortValue.hpp"
+#include "State.hpp"
+#include "types.hpp"
-#include "lilv/lilv.h"
+#include <ingen/Properties.hpp>
+#include <ingen/Resource.hpp>
+#include <ingen/URI.hpp>
-#include <boost/optional/optional.hpp>
-
-#include <algorithm>
#include <cstdint>
+#include <memory>
+#include <optional>
#include <vector>
namespace ingen {
+
+class Interface;
+struct Delta;
+struct Put;
+struct SetProperty;
+
namespace server {
-class CompiledGraph;
class Engine;
class GraphImpl;
-class RunContext;
namespace events {
-class SetPortValue;
-
/** Set properties of a graph object.
* \ingroup engine
*/
class Delta : public Event
{
public:
- Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Put& msg);
+ Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Put& msg);
- Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Delta& msg);
+ Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Delta& msg);
- Delta(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::SetProperty& msg);
+ Delta(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::SetProperty& msg);
- ~Delta() = default;
+ ~Delta() override = default;
void add_set_event(const char* port_symbol,
const void* value,
@@ -70,18 +77,14 @@ public:
uint32_t type);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
Execution get_execution() const override;
private:
- enum class Type {
- SET,
- PUT,
- PATCH
- };
+ enum class Type { SET, PUT, PATCH };
enum class SpecialType {
NONE,
@@ -95,34 +98,34 @@ private:
LOADED_BUNDLE
};
- using SetEvents = std::vector<UPtr<SetPortValue>>;
+ using SetEvents = std::vector<std::unique_ptr<SetPortValue>>;
void init();
- UPtr<Event> _create_event;
- SetEvents _set_events;
- std::vector<SpecialType> _types;
- std::vector<SpecialType> _remove_types;
- URI _subject;
- Properties _properties;
- Properties _remove;
- ClientUpdate _update;
- ingen::Resource* _object;
- GraphImpl* _graph;
- MPtr<CompiledGraph> _compiled_graph;
- ControlBindings::Binding* _binding;
- LilvState* _state;
- Resource::Graph _context;
- Type _type;
+ std::unique_ptr<Event> _create_event;
+ SetEvents _set_events;
+ std::vector<SpecialType> _types;
+ std::vector<SpecialType> _remove_types;
+ URI _subject;
+ Properties _properties;
+ Properties _remove;
+ ClientUpdate _update;
+ ingen::Resource* _object{nullptr};
+ GraphImpl* _graph{nullptr};
+ std::unique_ptr<CompiledGraph> _compiled_graph;
+ ControlBindings::Binding* _binding{nullptr};
+ StatePtr _state;
+ Resource::Graph _context;
+ Type _type;
Properties _added;
Properties _removed;
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 531d70af..7189fdd0 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -14,44 +14,55 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Disconnect.hpp"
+#include "Disconnect.hpp"
-#include "ArcImpl.hpp"
+#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "Buffer.hpp"
-#include "DuplexPort.hpp"
+#include "BufferFactory.hpp"
+#include "BufferRef.hpp"
+#include "CompiledGraph.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "InputPort.hpp"
#include "PortImpl.hpp"
+#include "PortType.hpp"
#include "PreProcessContext.hpp"
-#include "RunContext.hpp"
#include "ThreadManager.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.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;
+
namespace events {
-Disconnect::Disconnect(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Disconnect& msg)
+Disconnect::Disconnect(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Disconnect& msg)
: Event(engine, client, msg.seq, timestamp)
, _msg(msg)
- , _graph(nullptr)
-{
-}
+{}
+
+Disconnect::~Disconnect() = default;
Disconnect::Impl::Impl(Engine& e,
GraphImpl* graph,
@@ -107,7 +118,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()
@@ -146,7 +157,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);
}
@@ -154,33 +167,33 @@ 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,
+ 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);
}
bool
-Disconnect::Impl::execute(RunContext& context, bool set_head_buffers)
+Disconnect::Impl::execute(RunContext& ctx, bool set_head_buffers)
{
if (!_arc) {
return false;
}
- _head->remove_arc(*_arc.get());
+ _head->remove_arc(*_arc);
if (_head->is_driver_port()) {
return true;
}
if (set_head_buffers) {
if (_voices) {
- _head->set_voices(context, std::move(_voices));
+ _head->set_voices(ctx, std::move(_voices));
} else {
- _head->setup_buffers(context, *_engine.buffer_factory(), _head->poly());
+ _head->setup_buffers(ctx, *_engine.buffer_factory(), _head->poly());
}
_head->connect_buffers();
} else {
@@ -191,12 +204,13 @@ Disconnect::Impl::execute(RunContext& context, bool set_head_buffers)
}
void
-Disconnect::execute(RunContext& context)
+Disconnect::execute(RunContext& ctx)
{
if (_status == Status::SUCCESS) {
- if (_impl->execute(context, true)) {
+ 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;
@@ -207,7 +221,7 @@ Disconnect::execute(RunContext& context)
void
Disconnect::post_process()
{
- Broadcaster::Transfer t(*_engine.broadcaster());
+ const Broadcaster::Transfer t{*_engine.broadcaster()};
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->message(_msg);
}
@@ -220,5 +234,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 ec638c73..92dd81d3 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -17,16 +17,27 @@
#ifndef INGEN_EVENTS_DISCONNECT_HPP
#define INGEN_EVENTS_DISCONNECT_HPP
-#include "CompiledGraph.hpp"
#include "Event.hpp"
#include "PortImpl.hpp"
#include "types.hpp"
+#include <ingen/Message.hpp>
+#include <raul/Maid.hpp>
+
+#include <memory>
+
namespace ingen {
+
+class Interface;
+
namespace server {
class ArcImpl;
+class CompiledGraph;
+class Engine;
+class GraphImpl;
class InputPort;
+class RunContext;
namespace events {
@@ -37,38 +48,41 @@ namespace events {
class Disconnect : public Event
{
public:
- Disconnect(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Disconnect& msg);
+ Disconnect(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Disconnect& msg);
+
+ ~Disconnect() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
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& context, bool set_head_buffers);
+ 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;
- PortImpl* _tail;
- InputPort* _head;
- SPtr<ArcImpl> _arc;
- MPtr<PortImpl::Voices> _voices;
+ Engine& _engine;
+ PortImpl* _tail;
+ InputPort* _head;
+ std::shared_ptr<ArcImpl> _arc;
+ raul::managed_ptr<PortImpl::Voices> _voices;
};
private:
- const ingen::Disconnect _msg;
- GraphImpl* _graph;
- UPtr<Impl> _impl;
- MPtr<CompiledGraph> _compiled_graph;
+ const ingen::Disconnect _msg;
+ GraphImpl* _graph{nullptr};
+ std::unique_ptr<Impl> _impl;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
};
} // namespace events
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 4444bb26..8e7bfbbe 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -14,44 +14,47 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/DisconnectAll.hpp"
+#include "DisconnectAll.hpp"
#include "ArcImpl.hpp"
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
+#include "CompiledGraph.hpp"
+#include "Disconnect.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
#include "InputPort.hpp"
+#include "NodeImpl.hpp"
#include "PortImpl.hpp"
#include "PreProcessContext.hpp"
-#include "events/Disconnect.hpp"
-#include "util.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Array.hpp"
-#include "raul/Maid.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Path.hpp>
+#include <algorithm>
+#include <iterator>
+#include <memory>
#include <mutex>
#include <set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
-
-DisconnectAll::DisconnectAll(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::DisconnectAll& msg)
- : Event(engine, client, msg.seq, timestamp)
- , _msg(msg)
- , _parent(nullptr)
- , _block(nullptr)
- , _port(nullptr)
- , _deleting(false)
-{
-}
+namespace ingen::server::events {
+
+DisconnectAll::DisconnectAll(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::DisconnectAll& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
+ , _parent(nullptr)
+ , _block(nullptr)
+ , _port(nullptr)
+ , _deleting(false)
+{}
/** Internal version for use by other events.
*/
@@ -64,12 +67,11 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _block(dynamic_cast<BlockImpl*>(object))
, _port(dynamic_cast<PortImpl*>(object))
, _deleting(true)
-{
-}
+{}
DisconnectAll::~DisconnectAll()
{
- for (auto& i : _impls) {
+ for (auto* i : _impls) {
delete i;
}
}
@@ -109,32 +111,36 @@ 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 (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
+ const auto& arcs = adjacent_arcs(_parent);
+ std::transform(arcs.begin(),
+ arcs.end(),
+ std::back_inserter(_impls),
+ [this](const auto& a) {
+ return new Disconnect::Impl(_engine,
+ _parent,
+ a->tail(),
+ dynamic_cast<InputPort*>(a->head()));
+ });
+
+ // Create disconnect events to erase adjacent arcs in parent's parent
+ if (_port && _parent->parent()) {
+ auto* const grandparent = dynamic_cast<GraphImpl*>(_parent->parent());
+ const auto& parent_arcs = adjacent_arcs(grandparent);
+
+ std::transform(parent_arcs.begin(),
+ parent_arcs.end(),
+ std::back_inserter(_impls),
+ [this, grandparent](const auto& a) {
+ return new Disconnect::Impl(_engine,
+ grandparent,
+ 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);
}
}
@@ -143,24 +149,24 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
}
void
-DisconnectAll::execute(RunContext& context)
+DisconnectAll::execute(RunContext& ctx)
{
if (_status == Status::SUCCESS) {
for (auto& i : _impls) {
- i->execute(context,
+ i->execute(ctx,
!_deleting || (i->head()->parent_block() != _block));
}
}
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);
}
@@ -174,6 +180,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 9ab908c1..0eeda6f8 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -17,25 +17,32 @@
#ifndef INGEN_EVENTS_DISCONNECTALL_HPP
#define INGEN_EVENTS_DISCONNECTALL_HPP
-#include "CompiledGraph.hpp"
#include "Disconnect.hpp"
#include "Event.hpp"
+#include "types.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Message.hpp>
#include <list>
+#include <memory>
+#include <set>
namespace ingen {
+
+class Interface;
+class Node;
+
namespace server {
+class ArcImpl;
class BlockImpl;
+class CompiledGraph;
+class Engine;
class GraphImpl;
class PortImpl;
namespace events {
-class Disconnect;
-
/** An event to disconnect all connections to a Block.
*
* \ingroup engine
@@ -43,32 +50,34 @@ class Disconnect;
class DisconnectAll : public Event
{
public:
- DisconnectAll(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::DisconnectAll& msg);
+ DisconnectAll(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::DisconnectAll& msg);
DisconnectAll(Engine& engine,
GraphImpl* parent,
Node* object);
- ~DisconnectAll();
+ ~DisconnectAll() override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
private:
using Impls = std::list<Disconnect::Impl*>;
- const ingen::DisconnectAll _msg;
- GraphImpl* _parent;
- BlockImpl* _block;
- PortImpl* _port;
- Impls _impls;
- MPtr<CompiledGraph> _compiled_graph;
- bool _deleting;
+ std::set<ArcImpl*> adjacent_arcs(GraphImpl* graph);
+
+ const ingen::DisconnectAll _msg;
+ GraphImpl* _parent;
+ BlockImpl* _block;
+ PortImpl* _port;
+ Impls _impls;
+ std::unique_ptr<CompiledGraph> _compiled_graph;
+ bool _deleting;
};
} // namespace events
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 2335c09f..45e7ea94 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -18,47 +18,53 @@
#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
-#include "BufferFactory.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
-#include "PluginImpl.hpp"
#include "PortImpl.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Node.hpp>
+#include <ingen/Properties.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 <cstdint>
+#include <memory>
#include <mutex>
+#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
-Get::Get(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Get& msg)
+Get::Get(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ 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;
@@ -75,18 +81,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);
@@ -95,11 +107,11 @@ Get::post_process()
URIs& uris = _engine.world().uris();
Properties props = {
{ uris.param_sampleRate,
- uris.forge.make(int32_t(_engine.sample_rate())) },
+ uris.forge.make(static_cast<int32_t>(_engine.sample_rate())) },
{ uris.bufsz_maxBlockLength,
- uris.forge.make(int32_t(_engine.block_length())) },
+ uris.forge.make(static_cast<int32_t>(_engine.block_length())) },
{ uris.ingen_numThreads,
- uris.forge.make(int32_t(_engine.n_threads())) } };
+ uris.forge.make(static_cast<int32_t>(_engine.n_threads())) } };
const Properties load_props = _engine.load_properties();
props.insert(load_props.begin(), load_props.end());
@@ -110,6 +122,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 e24c9998..0f5ed235 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -17,18 +17,24 @@
#ifndef INGEN_EVENTS_GET_HPP
#define INGEN_EVENTS_GET_HPP
+#include <ingen/Message.hpp>
+
#include "BlockFactory.hpp"
#include "ClientUpdate.hpp"
#include "Event.hpp"
#include "types.hpp"
+#include <memory>
+
namespace ingen {
+
+class Interface;
+class Node;
+
namespace server {
-class BlockImpl;
-class GraphImpl;
+class Engine;
class PluginImpl;
-class PortImpl;
namespace events {
@@ -39,19 +45,19 @@ namespace events {
class Get : public Event
{
public:
- Get(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Get& msg);
+ Get(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Get& msg);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override {}
+ void execute(RunContext&) override;
void post_process() override;
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 eb50e4a0..b60b0432 100644
--- a/src/server/events/Mark.cpp
+++ b/src/server/events/Mark.cpp
@@ -14,42 +14,50 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "events/Mark.hpp"
+#include "Mark.hpp"
+#include "CompiledGraph.hpp"
#include "Engine.hpp"
+#include "GraphImpl.hpp"
#include "PreProcessContext.hpp"
#include "UndoStack.hpp"
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+
+#include <cassert>
+#include <memory>
+#include <unordered_set>
#include <utility>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
-Mark::Mark(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::BundleBegin& msg)
+Mark::Mark(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::BundleBegin& msg)
: Event(engine, client, msg.seq, timestamp)
, _type(Type::BUNDLE_BEGIN)
, _depth(-1)
{}
-Mark::Mark(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::BundleEnd& msg)
+Mark::Mark(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::BundleEnd& msg)
: Event(engine, client, msg.seq, timestamp)
, _type(Type::BUNDLE_END)
, _depth(-1)
{}
+Mark::~Mark() = default;
+
void
-Mark::mark(PreProcessContext& ctx)
+Mark::mark(PreProcessContext&)
{
- const UPtr<UndoStack>& stack = ((_mode == Mode::UNDO)
- ? _engine.redo_stack()
- : _engine.undo_stack());
+ const std::unique_ptr<UndoStack>& stack = ((_mode == Mode::UNDO)
+ ? _engine.redo_stack()
+ : _engine.undo_stack());
switch (_type) {
case Type::BUNDLE_BEGIN:
@@ -76,7 +84,7 @@ Mark::pre_process(PreProcessContext& ctx)
ctx.set_in_bundle(false);
if (!ctx.dirty_graphs().empty()) {
for (GraphImpl* g : ctx.dirty_graphs()) {
- MPtr<CompiledGraph> cg = compile(*_engine.maid(), *g);
+ auto cg = compile(*g);
if (cg) {
_compiled_graphs.emplace(g, std::move(cg));
}
@@ -93,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));
}
}
@@ -126,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 bff38f06..e7180764 100644
--- a/src/server/events/Mark.hpp
+++ b/src/server/events/Mark.hpp
@@ -17,14 +17,21 @@
#ifndef INGEN_EVENTS_MARK_HPP
#define INGEN_EVENTS_MARK_HPP
+#include "CompiledGraph.hpp"
#include "Event.hpp"
+#include "types.hpp"
#include <map>
+#include <memory>
namespace ingen {
+
+class Interface;
+struct BundleBegin;
+struct BundleEnd;
+
namespace server {
-class CompiledGraph;
class Engine;
class GraphImpl;
@@ -40,19 +47,21 @@ namespace events {
class Mark : public Event
{
public:
- Mark(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::BundleBegin& msg);
+ Mark(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::BundleBegin& msg);
+
+ Mark(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::BundleEnd& msg);
- Mark(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::BundleEnd& msg);
+ ~Mark() override;
void mark(PreProcessContext& ctx) override;
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
Execution get_execution() const override;
@@ -60,7 +69,7 @@ public:
private:
enum class Type { BUNDLE_BEGIN, BUNDLE_END };
- using CompiledGraphs = std::map<GraphImpl*, MPtr<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 f6a39f1f..80ae5a11 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -14,42 +14,46 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Store.hpp"
-#include "raul/Path.hpp"
+#include "Move.hpp"
-#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
-#include "EnginePort.hpp"
-#include "GraphImpl.hpp"
-#include "events/Move.hpp"
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/Store.hpp>
+#include <raul/Path.hpp>
+
+#include <map>
+#include <memory>
#include <mutex>
-namespace ingen {
-namespace server {
+namespace ingen::server {
+
+class EnginePort;
+
namespace events {
-Move::Move(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Move& msg)
+Move::Move(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ 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);
}
@@ -69,14 +73,13 @@ Move::pre_process(PreProcessContext&)
}
void
-Move::execute(RunContext& context)
-{
-}
+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);
}
@@ -89,5 +92,4 @@ Move::undo(Interface& target)
}
} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp
index b4487b78..cca4d310 100644
--- a/src/server/events/Move.hpp
+++ b/src/server/events/Move.hpp
@@ -18,15 +18,19 @@
#define INGEN_EVENTS_MOVE_HPP
#include "Event.hpp"
+#include "types.hpp"
-#include "ingen/Store.hpp"
-#include "raul/Path.hpp"
+#include <ingen/Message.hpp>
+
+#include <memory>
namespace ingen {
+
+class Interface;
+
namespace server {
-class GraphImpl;
-class PortImpl;
+class Engine;
namespace events {
@@ -36,13 +40,13 @@ namespace events {
class Move : public Event
{
public:
- Move(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Move& msg);
+ Move(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Move& msg);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
void undo(Interface& target) override;
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index 2eecf9ce..ba6859dd 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -16,47 +16,46 @@
#include "SetPortValue.hpp"
-#include "BlockImpl.hpp"
#include "Broadcaster.hpp"
#include "Buffer.hpp"
+#include "BufferFactory.hpp"
#include "ControlBindings.hpp"
#include "Engine.hpp"
#include "PortImpl.hpp"
#include "RunContext.hpp"
-#include "ingen/Forge.hpp"
-#include "ingen/LV2Features.hpp"
-#include "ingen/Store.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
+#include <ingen/Atom.hpp>
+#include <ingen/Forge.hpp>
+#include <ingen/Status.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <lv2/atom/atom.h>
#include <cassert>
+#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
/** Internal */
-SetPortValue::SetPortValue(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- PortImpl* port,
- const Atom& value,
- bool activity,
- bool synthetic)
+SetPortValue::SetPortValue(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ PortImpl* port,
+ const Atom& value,
+ bool activity,
+ bool synthetic)
: Event(engine, client, id, timestamp)
, _port(port)
, _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());
}
@@ -80,43 +79,43 @@ SetPortValue::pre_process(PreProcessContext&)
}
void
-SetPortValue::execute(RunContext& context)
+SetPortValue::execute(RunContext& ctx)
{
- assert(_time >= context.start() && _time <= context.end());
- apply(context);
- _engine.control_bindings()->port_value_changed(context, _port, _binding, _value);
+ assert(_time >= ctx.start() && _time <= ctx.end());
+ apply(ctx);
+ _engine.control_bindings()->port_value_changed(ctx, _port, _binding, _value);
}
void
-SetPortValue::apply(RunContext& context)
+SetPortValue::apply(RunContext& ctx)
{
if (_status != Status::SUCCESS) {
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(context)) {
- buf = _port->user_buffer(context).get();
+ if (_port->user_buffer(ctx)) {
+ buf = _port->user_buffer(ctx).get();
} else {
- _port->set_user_buffer(context, _buffer);
+ _port->set_user_buffer(ctx, _buffer);
buf = _buffer.get();
}
}
if (buf->type() == uris.atom_Sound || buf->type() == uris.atom_Float) {
if (_value.type() == uris.forge.Float) {
- _port->set_control_value(context, _time, _value.get<float>());
+ _port->set_control_value(ctx, _time, _value.get<float>());
} else {
_status = Status::TYPE_MISMATCH;
}
} else if (buf->type() == uris.atom_Sequence) {
- if (!buf->append_event(_time - context.start(),
+ if (!buf->append_event(_time - ctx.start(),
_value.size(),
_value.type(),
- (const uint8_t*)_value.get_body())) {
+ reinterpret_cast<const uint8_t*>(_value.get_body()))) {
_status = Status::NO_SPACE;
}
} else if (buf->type() == uris.atom_URID) {
@@ -129,7 +128,7 @@ SetPortValue::apply(RunContext& context)
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(),
@@ -138,6 +137,4 @@ SetPortValue::post_process()
}
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp
index 99d55af3..32a8b761 100644
--- a/src/server/events/SetPortValue.hpp
+++ b/src/server/events/SetPortValue.hpp
@@ -22,14 +22,20 @@
#include "Event.hpp"
#include "types.hpp"
-#include "ingen/Atom.hpp"
+#include <ingen/Atom.hpp>
#include <cstdint>
+#include <memory>
namespace ingen {
+
+class Interface;
+
namespace server {
+class Engine;
class PortImpl;
+class RunContext;
namespace events {
@@ -40,23 +46,23 @@ namespace events {
class SetPortValue : public Event
{
public:
- SetPortValue(Engine& engine,
- const SPtr<Interface>& client,
- int32_t id,
- SampleCount timestamp,
- PortImpl* port,
- const Atom& value,
- bool activity,
- bool synthetic = false);
+ SetPortValue(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ int32_t id,
+ SampleCount timestamp,
+ PortImpl* port,
+ const Atom& value,
+ bool activity,
+ bool synthetic = false);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
bool synthetic() const { return _synthetic; }
private:
- void apply(RunContext& context);
+ void apply(RunContext& ctx);
PortImpl* _port;
const Atom _value;
diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp
index 0741e60d..db7c1c86 100644
--- a/src/server/events/Undo.cpp
+++ b/src/server/events/Undo.cpp
@@ -19,26 +19,29 @@
#include "Engine.hpp"
#include "EventWriter.hpp"
-#include "ingen/AtomReader.hpp"
+#include <ingen/AtomReader.hpp>
+#include <ingen/Interface.hpp>
+#include <ingen/Message.hpp>
+#include <ingen/Status.hpp>
+#include <lv2/atom/atom.h>
#include <deque>
+#include <memory>
-namespace ingen {
-namespace server {
-namespace events {
+namespace ingen::server::events {
-Undo::Undo(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Undo& msg)
+Undo::Undo(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Undo& msg)
: Event(engine, client, msg.seq, timestamp)
, _is_redo(false)
{}
-Undo::Undo(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Redo& msg)
+Undo::Undo(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Redo& msg)
: Event(engine, client, msg.seq, timestamp)
, _is_redo(true)
{}
@@ -46,8 +49,10 @@ Undo::Undo(Engine& engine,
bool
Undo::pre_process(PreProcessContext&)
{
- const UPtr<UndoStack>& stack = _is_redo ? _engine.redo_stack() : _engine.undo_stack();
- const Event::Mode mode = _is_redo ? Event::Mode::REDO : Event::Mode::UNDO;
+ const std::unique_ptr<UndoStack>& stack =
+ _is_redo ? _engine.redo_stack() : _engine.undo_stack();
+
+ const Event::Mode mode = _is_redo ? Event::Mode::REDO : Event::Mode::UNDO;
if (stack->empty()) {
return Event::pre_process_done(Status::NOT_FOUND);
@@ -73,9 +78,8 @@ Undo::pre_process(PreProcessContext&)
}
void
-Undo::execute(RunContext& context)
-{
-}
+Undo::execute(RunContext&)
+{}
void
Undo::post_process()
@@ -83,6 +87,4 @@ Undo::post_process()
respond();
}
-} // namespace events
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server::events
diff --git a/src/server/events/Undo.hpp b/src/server/events/Undo.hpp
index e36ebaad..818dc754 100644
--- a/src/server/events/Undo.hpp
+++ b/src/server/events/Undo.hpp
@@ -21,8 +21,18 @@
#include "UndoStack.hpp"
#include "types.hpp"
+#include <memory>
+
namespace ingen {
+
+class Interface;
+struct Redo;
+struct Undo;
+
namespace server {
+
+class Engine;
+
namespace events {
/** A request to undo the last change to the engine.
@@ -32,18 +42,18 @@ namespace events {
class Undo : public Event
{
public:
- Undo(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Undo& msg);
+ Undo(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Undo& msg);
- Undo(Engine& engine,
- const SPtr<Interface>& client,
- SampleCount timestamp,
- const ingen::Redo& msg);
+ Undo(Engine& engine,
+ const std::shared_ptr<Interface>& client,
+ SampleCount timestamp,
+ const ingen::Redo& msg);
bool pre_process(PreProcessContext& ctx) override;
- void execute(RunContext& context) override;
+ void execute(RunContext& ctx) override;
void post_process() override;
private: