summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-16 23:47:08 +0100
committerDavid Robillard <d@drobilla.net>2017-12-16 23:47:08 +0100
commitaf51373cadb57d8b31ccb3c359e7c80d8f697487 (patch)
treedd8f74b5bb14acd8ec100f691d46d3f300445531 /src/server/events
parent68901d7caa0636895de593e0b23cdec4fb53deaa (diff)
downloadingen-af51373cadb57d8b31ccb3c359e7c80d8f697487.tar.gz
ingen-af51373cadb57d8b31ccb3c359e7c80d8f697487.tar.bz2
ingen-af51373cadb57d8b31ccb3c359e7c80d8f697487.zip
Make events take the corresponding message directly
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp41
-rw-r--r--src/server/events/Connect.hpp13
-rw-r--r--src/server/events/Copy.cpp47
-rw-r--r--src/server/events/Copy.hpp13
-rw-r--r--src/server/events/Delete.cpp23
-rw-r--r--src/server/events/Delete.hpp11
-rw-r--r--src/server/events/Delta.cpp85
-rw-r--r--src/server/events/Delta.hpp31
-rw-r--r--src/server/events/Disconnect.cpp41
-rw-r--r--src/server/events/Disconnect.hpp19
-rw-r--r--src/server/events/DisconnectAll.cpp35
-rw-r--r--src/server/events/DisconnectAll.hpp25
-rw-r--r--src/server/events/Get.cpp34
-rw-r--r--src/server/events/Get.hpp11
-rw-r--r--src/server/events/Mark.cpp26
-rw-r--r--src/server/events/Mark.hpp16
-rw-r--r--src/server/events/Move.cpp31
-rw-r--r--src/server/events/Move.hpp13
-rw-r--r--src/server/events/Undo.cpp21
-rw-r--r--src/server/events/Undo.hpp14
20 files changed, 293 insertions, 257 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 85f8d30a..306c7533 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -34,15 +34,12 @@ namespace Ingen {
namespace Server {
namespace Events {
-Connect::Connect(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& tail_path,
- const Raul::Path& head_path)
- : Event(engine, client, id, timestamp)
- , _tail_path(tail_path)
- , _head_path(head_path)
+Connect::Connect(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Connect& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _graph(NULL)
, _head(NULL)
{}
@@ -52,36 +49,36 @@ Connect::pre_process(PreProcessContext& ctx)
{
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
- Node* tail = _engine.store()->get(_tail_path);
+ Node* tail = _engine.store()->get(_msg.tail);
if (!tail) {
- return Event::pre_process_done(Status::NOT_FOUND, _tail_path);
+ return Event::pre_process_done(Status::NOT_FOUND, _msg.tail);
}
- Node* head = _engine.store()->get(_head_path);
+ Node* head = _engine.store()->get(_msg.head);
if (!head) {
- return Event::pre_process_done(Status::NOT_FOUND, _head_path);
+ return Event::pre_process_done(Status::NOT_FOUND, _msg.head);
}
PortImpl* tail_output = dynamic_cast<PortImpl*>(tail);
_head = dynamic_cast<InputPort*>(head);
if (!tail_output || !_head) {
- return Event::pre_process_done(Status::BAD_REQUEST, _head_path);
+ return Event::pre_process_done(Status::BAD_REQUEST, _msg.head);
}
BlockImpl* const tail_block = tail_output->parent_block();
BlockImpl* const head_block = _head->parent_block();
if (!tail_block || !head_block) {
- return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path);
+ return Event::pre_process_done(Status::PARENT_NOT_FOUND, _msg.head);
}
if (tail_block->parent() != head_block->parent()
&& tail_block != head_block->parent()
&& tail_block->parent() != head_block) {
- return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path);
+ return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.head);
}
if (!ArcImpl::can_connect(tail_output, _head)) {
- return Event::pre_process_done(Status::TYPE_MISMATCH, _head_path);
+ return Event::pre_process_done(Status::TYPE_MISMATCH, _msg.head);
}
if (tail_block->parent_graph() != head_block->parent_graph()) {
@@ -101,7 +98,7 @@ Connect::pre_process(PreProcessContext& ctx)
}
if (_graph->has_arc(tail_output, _head)) {
- return Event::pre_process_done(Status::EXISTS, _head_path);
+ return Event::pre_process_done(Status::EXISTS, _msg.head);
}
_arc = SPtr<ArcImpl>(new ArcImpl(tail_output, _head));
@@ -168,14 +165,14 @@ Connect::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- _engine.broadcaster()->connect(_tail_path, _head_path);
+ _engine.broadcaster()->message(_msg);
if (!_tail_remove.empty() || !_tail_add.empty()) {
_engine.broadcaster()->delta(
- path_to_uri(_tail_path), _tail_remove, _tail_add);
+ path_to_uri(_msg.tail), _tail_remove, _tail_add);
}
if (!_tail_remove.empty() || !_tail_add.empty()) {
_engine.broadcaster()->delta(
- path_to_uri(_tail_path), _tail_remove, _tail_add);
+ path_to_uri(_msg.tail), _tail_remove, _tail_add);
}
}
}
@@ -183,7 +180,7 @@ Connect::post_process()
void
Connect::undo(Interface& target)
{
- target.disconnect(_tail_path, _head_path);
+ target.disconnect(_msg.tail, _msg.head);
}
} // namespace Events
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index 2493e899..8a42b984 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -44,12 +44,10 @@ namespace Events {
class Connect : public Event
{
public:
- Connect(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& tail,
- const Raul::Path& head);
+ Connect(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Connect& msg);
bool pre_process(PreProcessContext& ctx);
void execute(RunContext& context);
@@ -57,8 +55,7 @@ public:
void undo(Interface& target);
private:
- const Raul::Path _tail_path;
- const Raul::Path _head_path;
+ const Ingen::Connect _msg;
GraphImpl* _graph;
InputPort* _head;
MPtr<CompiledGraph> _compiled_graph;
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index b0801075..c83acb6e 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -31,15 +31,12 @@ namespace Ingen {
namespace Server {
namespace Events {
-Copy::Copy(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& old_uri,
- const Raul::URI& new_uri)
- : Event(engine, client, id, timestamp)
- , _old_uri(old_uri)
- , _new_uri(new_uri)
+Copy::Copy(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Copy& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _old_block(NULL)
, _parent(NULL)
, _block(NULL)
@@ -50,9 +47,9 @@ Copy::pre_process(PreProcessContext& ctx)
{
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
- if (uri_is_path(_old_uri)) {
+ if (uri_is_path(_msg.old_uri)) {
// Old URI is a path within the engine
- const Raul::Path old_path = uri_to_path(_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);
@@ -65,17 +62,17 @@ Copy::pre_process(PreProcessContext& ctx)
return Event::pre_process_done(Status::BAD_OBJECT_TYPE, old_path);
}
- if (uri_is_path(_new_uri)) {
+ if (uri_is_path(_msg.new_uri)) {
// Copy to path within the engine
return engine_to_engine(ctx);
- } else if (_new_uri.scheme() == "file") {
+ } else 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 (_old_uri.scheme() == "file") {
- if (uri_is_path(_new_uri)) {
+ } else 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
@@ -90,7 +87,7 @@ bool
Copy::engine_to_engine(PreProcessContext& ctx)
{
// Only support a single source for now
- const Raul::Path new_path = uri_to_path(_new_uri);
+ 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);
}
@@ -143,7 +140,7 @@ Copy::engine_to_filesystem(PreProcessContext& ctx)
// Ensure source is a graph
SPtr<GraphImpl> graph = dynamic_ptr_cast<GraphImpl>(_old_block);
if (!graph) {
- return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _old_uri);
+ return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _msg.old_uri);
}
if (!_engine.world()->serialiser()) {
@@ -152,10 +149,10 @@ Copy::engine_to_filesystem(PreProcessContext& ctx)
std::lock_guard<std::mutex> lock(_engine.world()->rdf_mutex());
- if (ends_with(_new_uri, ".ingen") || ends_with(_new_uri, ".ingen/")) {
- _engine.world()->serialiser()->write_bundle(graph, _new_uri);
+ if (ends_with(_msg.new_uri, ".ingen") || ends_with(_msg.new_uri, ".ingen/")) {
+ _engine.world()->serialiser()->write_bundle(graph, _msg.new_uri);
} else {
- _engine.world()->serialiser()->start_to_file(graph->path(), _new_uri);
+ _engine.world()->serialiser()->start_to_file(graph->path(), _msg.new_uri);
_engine.world()->serialiser()->serialise(graph);
_engine.world()->serialiser()->finish();
}
@@ -173,8 +170,8 @@ Copy::filesystem_to_engine(PreProcessContext& ctx)
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 = _old_uri.substr(strlen("file://"));
- const Raul::Path dst_path = uri_to_path(_new_uri);
+ const std::string src_path = _msg.old_uri.substr(strlen("file://"));
+ const Raul::Path dst_path = uri_to_path(_msg.new_uri);
boost::optional<Raul::Path> dst_parent;
boost::optional<Raul::Symbol> dst_symbol;
if (!dst_path.is_root()) {
@@ -202,15 +199,15 @@ Copy::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- _engine.broadcaster()->copy(_old_uri, _new_uri);
+ _engine.broadcaster()->message(_msg);
}
}
void
Copy::undo(Interface& target)
{
- if (uri_is_path(_new_uri)) {
- target.del(_new_uri);
+ if (uri_is_path(_msg.new_uri)) {
+ target.del(_msg.new_uri);
}
}
diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp
index 52a82b67..5216b56e 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -39,12 +39,10 @@ namespace Events {
class Copy : public Event
{
public:
- Copy(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& old_uri,
- const Raul::URI& new_uri);
+ Copy(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Copy& msg);
bool pre_process(PreProcessContext& ctx);
void execute(RunContext& context);
@@ -56,8 +54,7 @@ private:
bool engine_to_filesystem(PreProcessContext& ctx);
bool filesystem_to_engine(PreProcessContext& ctx);
- const Raul::URI _old_uri;
- const Raul::URI _new_uri;
+ const Ingen::Copy _msg;
SPtr<BlockImpl> _old_block;
GraphImpl* _parent;
BlockImpl* _block;
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 0a065a8a..b83dcef9 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -35,18 +35,17 @@ namespace Ingen {
namespace Server {
namespace Events {
-Delete::Delete(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- FrameTime time,
- const Raul::URI& uri)
- : Event(engine, client, id, time)
- , _uri(uri)
+Delete::Delete(Engine& engine,
+ SPtr<Interface> client,
+ FrameTime timestamp,
+ const Ingen::Del& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _engine_port(NULL)
, _disconnect_event(NULL)
{
- if (uri_is_path(uri)) {
- _path = uri_to_path(uri);
+ if (uri_is_path(msg.uri)) {
+ _path = uri_to_path(msg.uri);
}
}
@@ -176,7 +175,7 @@ Delete::post_process()
_block->deactivate();
}
- _engine.broadcaster()->del(_uri);
+ _engine.broadcaster()->message(_msg);
}
if (_engine_port) {
@@ -199,11 +198,11 @@ Delete::undo(Interface& target)
}
// Put deleted item back
- target.put(_uri, i->second->properties());
+ target.put(_msg.uri, i->second->properties());
// Adjust port indices
for (const auto& c : _port_index_changes) {
- if (c.first != _uri) {
+ if (c.first != _msg.uri) {
target.set_property(path_to_uri(c.first),
uris.lv2_index,
forge.make(int32_t(c.second.first)));
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 03c994fe..8b2a0a91 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -49,11 +49,10 @@ class DisconnectAll;
class Delete : public Event
{
public:
- Delete(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- FrameTime timestamp,
- const Raul::URI& uri);
+ Delete(Engine& engine,
+ SPtr<Interface> client,
+ FrameTime timestamp,
+ const Ingen::Del& msg);
~Delete();
@@ -66,7 +65,7 @@ private:
using IndexChange = std::pair<uint32_t, uint32_t>;
using IndexChanges = std::map<Raul::Path, IndexChange>;
- Raul::URI _uri;
+ const Ingen::Del _msg;
Raul::Path _path;
SPtr<BlockImpl> _block; ///< Non-NULL iff a block
SPtr<DuplexPort> _port; ///< Non-NULL iff a port
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index fccb887c..0b26b797 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -44,38 +44,60 @@ namespace Events {
Delta::Delta(Engine& engine,
SPtr<Interface> client,
- int32_t id,
SampleCount timestamp,
- Type type,
- Resource::Graph context,
- const Raul::URI& subject,
- const Properties& properties,
- const Properties& remove)
- : Event(engine, client, id, timestamp)
+ const Ingen::Put& msg)
+ : Event(engine, client, msg.seq, timestamp)
, _create_event(NULL)
- , _subject(subject)
- , _properties(properties)
- , _remove(remove)
+ , _subject(msg.uri)
+ , _properties(msg.properties)
, _object(NULL)
, _graph(NULL)
, _binding(NULL)
, _state(NULL)
- , _context(context)
- , _type(type)
+ , _context(msg.ctx)
+ , _type(Type::PUT)
, _block(false)
{
- if (context != Resource::Graph::DEFAULT) {
- for (auto& p : _properties) {
- p.second.set_context(context);
- }
- }
+ init();
+}
- // Set atomic execution if polyphony is to be changed
- const Ingen::URIs& uris = _engine.world()->uris();
- if (properties.count(uris.ingen_polyphonic) ||
- properties.count(uris.ingen_polyphony)) {
- _block = true;
- }
+Delta::Delta(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Delta& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _create_event(NULL)
+ , _subject(msg.uri)
+ , _properties(msg.add)
+ , _remove(msg.remove)
+ , _object(NULL)
+ , _graph(NULL)
+ , _binding(NULL)
+ , _state(NULL)
+ , _context(msg.ctx)
+ , _type(Type::PATCH)
+ , _block(false)
+{
+ init();
+}
+
+Delta::Delta(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::SetProperty& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _create_event(NULL)
+ , _subject(msg.subject)
+ , _properties{{msg.predicate, msg.value}}
+ , _object(NULL)
+ , _graph(NULL)
+ , _binding(NULL)
+ , _state(NULL)
+ , _context(msg.ctx)
+ , _type(Type::SET)
+ , _block(false)
+{
+ init();
}
Delta::~Delta()
@@ -87,6 +109,23 @@ Delta::~Delta()
}
void
+Delta::init()
+{
+ if (_context != Resource::Graph::DEFAULT) {
+ for (auto& p : _properties) {
+ p.second.set_context(_context);
+ }
+ }
+
+ // Set atomic execution if polyphony is to be changed
+ const Ingen::URIs& uris = _engine.world()->uris();
+ if (_properties.count(uris.ingen_polyphonic) ||
+ _properties.count(uris.ingen_polyphony)) {
+ _block = true;
+ }
+}
+
+void
Delta::add_set_event(const char* port_symbol,
const void* value,
uint32_t size,
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index 24d58b99..47c4ab22 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -50,21 +50,20 @@ class SetPortValue;
class Delta : public Event
{
public:
- enum class Type {
- SET,
- PUT,
- PATCH
- };
-
Delta(Engine& engine,
SPtr<Interface> client,
- int32_t id,
SampleCount timestamp,
- Type type,
- Resource::Graph context,
- const Raul::URI& subject,
- const Properties& properties,
- const Properties& remove = Properties());
+ const Ingen::Put& msg);
+
+ Delta(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Delta& msg);
+
+ Delta(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::SetProperty& msg);
~Delta();
@@ -81,6 +80,12 @@ public:
Execution get_execution() const;
private:
+ enum class Type {
+ SET,
+ PUT,
+ PATCH
+ };
+
enum class SpecialType {
NONE,
ENABLE,
@@ -95,6 +100,8 @@ private:
typedef std::vector<SetPortValue*> SetEvents;
+ void init();
+
Event* _create_event;
SetEvents _set_events;
std::vector<SpecialType> _types;
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 1411e666..f043d7dc 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -37,15 +37,12 @@ namespace Ingen {
namespace Server {
namespace Events {
-Disconnect::Disconnect(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& tail_path,
- const Raul::Path& head_path)
- : Event(engine, client, id, timestamp)
- , _tail_path(tail_path)
- , _head_path(head_path)
+Disconnect::Disconnect(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Disconnect& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _graph(NULL)
, _impl(NULL)
{
@@ -112,20 +109,20 @@ Disconnect::pre_process(PreProcessContext& ctx)
{
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
- if (_tail_path.parent().parent() != _head_path.parent().parent()
- && _tail_path.parent() != _head_path.parent().parent()
- && _tail_path.parent().parent() != _head_path.parent()) {
- return Event::pre_process_done(Status::PARENT_DIFFERS, _head_path);
+ if (_msg.tail.parent().parent() != _msg.head.parent().parent()
+ && _msg.tail.parent() != _msg.head.parent().parent()
+ && _msg.tail.parent().parent() != _msg.head.parent()) {
+ return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.head);
}
- PortImpl* tail = dynamic_cast<PortImpl*>(_engine.store()->get(_tail_path));
+ PortImpl* tail = dynamic_cast<PortImpl*>(_engine.store()->get(_msg.tail));
if (!tail) {
- return Event::pre_process_done(Status::PORT_NOT_FOUND, _tail_path);
+ return Event::pre_process_done(Status::PORT_NOT_FOUND, _msg.tail);
}
- PortImpl* head = dynamic_cast<PortImpl*>(_engine.store()->get(_head_path));
+ PortImpl* head = dynamic_cast<PortImpl*>(_engine.store()->get(_msg.head));
if (!head) {
- return Event::pre_process_done(Status::PORT_NOT_FOUND, _head_path);
+ return Event::pre_process_done(Status::PORT_NOT_FOUND, _msg.head);
}
BlockImpl* const tail_block = tail->parent_block();
@@ -148,13 +145,13 @@ Disconnect::pre_process(PreProcessContext& ctx)
}
if (!_graph) {
- return Event::pre_process_done(Status::INTERNAL_ERROR, _head_path);
+ return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.head);
} else if (!_graph->has_arc(tail, head)) {
- return Event::pre_process_done(Status::NOT_FOUND, _head_path);
+ return Event::pre_process_done(Status::NOT_FOUND, _msg.head);
}
if (tail_block == NULL || head_block == NULL) {
- return Event::pre_process_done(Status::PARENT_NOT_FOUND, _head_path);
+ return Event::pre_process_done(Status::PARENT_NOT_FOUND, _msg.head);
}
_impl = new Impl(_engine,
@@ -212,14 +209,14 @@ Disconnect::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- _engine.broadcaster()->disconnect(_tail_path, _head_path);
+ _engine.broadcaster()->message(_msg);
}
}
void
Disconnect::undo(Interface& target)
{
- target.connect(_tail_path, _head_path);
+ target.connect(_msg.tail, _msg.head);
}
} // namespace Events
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index 984a1dd4..44290d7c 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -44,12 +44,10 @@ namespace Events {
class Disconnect : public Event
{
public:
- Disconnect(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& tail_path,
- const Raul::Path& head_path);
+ Disconnect(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Disconnect& msg);
~Disconnect();
@@ -76,11 +74,10 @@ public:
};
private:
- const Raul::Path _tail_path;
- const Raul::Path _head_path;
- GraphImpl* _graph;
- Impl* _impl;
- MPtr<CompiledGraph> _compiled_graph;
+ const Ingen::Disconnect _msg;
+ GraphImpl* _graph;
+ Impl* _impl;
+ MPtr<CompiledGraph> _compiled_graph;
};
} // namespace Events
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 23f5118f..afb9c8cb 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -37,15 +37,12 @@ namespace Ingen {
namespace Server {
namespace Events {
-DisconnectAll::DisconnectAll(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& parent_path,
- const Raul::Path& path)
- : Event(engine, client, id, timestamp)
- , _parent_path(parent_path)
- , _path(path)
+DisconnectAll::DisconnectAll(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::DisconnectAll& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _parent(NULL)
, _block(NULL)
, _port(NULL)
@@ -59,8 +56,7 @@ DisconnectAll::DisconnectAll(Engine& engine,
GraphImpl* parent,
Node* object)
: Event(engine)
- , _parent_path(parent->path())
- , _path(object->path())
+ , _msg{0, parent->path(), object->path()}
, _parent(parent)
, _block(dynamic_cast<BlockImpl*>(object))
, _port(dynamic_cast<PortImpl*>(object))
@@ -77,26 +73,27 @@ DisconnectAll::~DisconnectAll()
bool
DisconnectAll::pre_process(PreProcessContext& ctx)
{
- std::unique_lock<Store::Mutex> lock(_engine.store()->mutex(), std::defer_lock);
+ std::unique_lock<Store::Mutex> lock(_engine.store()->mutex(),
+ std::defer_lock);
if (!_deleting) {
lock.lock();
- _parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_parent_path));
+ _parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_msg.graph));
if (!_parent) {
return Event::pre_process_done(Status::PARENT_NOT_FOUND,
- _parent_path);
+ _msg.graph);
}
NodeImpl* const object = dynamic_cast<NodeImpl*>(
- _engine.store()->get(_path));
+ _engine.store()->get(_msg.path));
if (!object) {
- return Event::pre_process_done(Status::NOT_FOUND, _path);
+ return Event::pre_process_done(Status::NOT_FOUND, _msg.path);
}
if (object->parent_graph() != _parent
&& object->parent()->parent_graph() != _parent) {
- return Event::pre_process_done(Status::INVALID_PARENT, _parent_path);
+ return Event::pre_process_done(Status::INVALID_PARENT, _msg.graph);
}
// Only one of these will succeed
@@ -104,7 +101,7 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
_port = dynamic_cast<PortImpl*>(object);
if (!_block && !_port) {
- return Event::pre_process_done(Status::INTERNAL_ERROR, _path);
+ return Event::pre_process_done(Status::INTERNAL_ERROR, _msg.path);
}
}
@@ -161,7 +158,7 @@ DisconnectAll::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- _engine.broadcaster()->disconnect_all(_parent_path, _path);
+ _engine.broadcaster()->message(_msg);
}
}
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index a8de6baf..947e538f 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -43,12 +43,10 @@ class Disconnect;
class DisconnectAll : public Event
{
public:
- DisconnectAll(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& parent,
- const Raul::Path& object);
+ DisconnectAll(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::DisconnectAll& msg);
DisconnectAll(Engine& engine,
GraphImpl* parent,
@@ -64,14 +62,13 @@ public:
private:
typedef std::list<Disconnect::Impl*> Impls;
- Raul::Path _parent_path;
- Raul::Path _path;
- GraphImpl* _parent;
- BlockImpl* _block;
- PortImpl* _port;
- Impls _impls;
- MPtr<CompiledGraph> _compiled_graph;
- bool _deleting;
+ const Ingen::DisconnectAll _msg;
+ GraphImpl* _parent;
+ BlockImpl* _block;
+ PortImpl* _port;
+ Impls _impls;
+ MPtr<CompiledGraph> _compiled_graph;
+ bool _deleting;
};
} // namespace Events
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 7bc2cb6f..64af9363 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -33,13 +33,12 @@ namespace Ingen {
namespace Server {
namespace Events {
-Get::Get(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& uri)
- : Event(engine, client, id, timestamp)
- , _uri(uri)
+Get::Get(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Get& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
, _object(NULL)
, _plugin(NULL)
{}
@@ -49,13 +48,14 @@ Get::pre_process(PreProcessContext& ctx)
{
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
- if (_uri == "ingen:/plugins") {
+ 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") {
+ } else if (uri == "ingen:/engine") {
return Event::pre_process_done(Status::SUCCESS);
- } else if (uri_is_path(_uri)) {
- if ((_object = _engine.store()->get(uri_to_path(_uri)))) {
+ } else if (uri_is_path(uri)) {
+ if ((_object = _engine.store()->get(uri_to_path(uri)))) {
const BlockImpl* block = NULL;
const GraphImpl* graph = NULL;
const PortImpl* port = NULL;
@@ -66,16 +66,16 @@ Get::pre_process(PreProcessContext& ctx)
} else if ((port = dynamic_cast<const PortImpl*>(_object))) {
_response.put_port(port);
} else {
- return Event::pre_process_done(Status::BAD_OBJECT_TYPE, _uri);
+ return Event::pre_process_done(Status::BAD_OBJECT_TYPE, uri);
}
return Event::pre_process_done(Status::SUCCESS);
}
- return Event::pre_process_done(Status::NOT_FOUND, _uri);
- } else if ((_plugin = _engine.block_factory()->plugin(_uri))) {
+ return Event::pre_process_done(Status::NOT_FOUND, uri);
+ } else 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);
}
}
@@ -84,9 +84,9 @@ Get::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS && _request_client) {
- if (_uri == "ingen:/plugins") {
+ if (_msg.subject == "ingen:/plugins") {
_engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins);
- } else if (_uri == "ingen:/engine") {
+ } else if (_msg.subject == "ingen:/engine") {
// TODO: Keep a proper RDF model of the engine
URIs& uris = _engine.world()->uris();
Properties props = {
diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp
index 35955d9a..7392550f 100644
--- a/src/server/events/Get.hpp
+++ b/src/server/events/Get.hpp
@@ -41,18 +41,17 @@ namespace Events {
class Get : public Event
{
public:
- Get(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& uri);
+ Get(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Get& msg);
bool pre_process(PreProcessContext& ctx);
void execute(RunContext& context) {}
void post_process();
private:
- const Raul::URI _uri;
+ const Ingen::Get _msg;
const Node* _object;
PluginImpl* _plugin;
BlockFactory::Plugins _plugins;
diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp
index abba85e8..93ab3071 100644
--- a/src/server/events/Mark.cpp
+++ b/src/server/events/Mark.cpp
@@ -23,13 +23,21 @@ namespace Ingen {
namespace Server {
namespace Events {
-Mark::Mark(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- Type type)
- : Event(engine, client, id, timestamp)
- , _type(type)
+Mark::Mark(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::BundleBegin& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _type(Type::BUNDLE_BEGIN)
+ , _depth(0)
+{}
+
+Mark::Mark(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::BundleEnd& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _type(Type::BUNDLE_END)
, _depth(0)
{}
@@ -45,7 +53,7 @@ Mark::pre_process(PreProcessContext& ctx)
: _engine.undo_stack());
switch (_type) {
- case Type::BUNDLE_START:
+ case Type::BUNDLE_BEGIN:
ctx.set_in_bundle(true);
_depth = stack->start_entry();
break;
@@ -89,7 +97,7 @@ Mark::get_execution() const
}
switch (_type) {
- case Type::BUNDLE_START:
+ case Type::BUNDLE_BEGIN:
if (_depth == 1) {
return Execution::BLOCK;
}
diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp
index 4a5e83bf..b037b56d 100644
--- a/src/server/events/Mark.hpp
+++ b/src/server/events/Mark.hpp
@@ -36,13 +36,15 @@ namespace Events {
class Mark : public Event
{
public:
- enum class Type { BUNDLE_START, BUNDLE_END };
+ Mark(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::BundleBegin& msg);
- Mark(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- Type type);
+ Mark(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::BundleEnd& msg);
~Mark();
@@ -53,6 +55,8 @@ public:
Execution get_execution() const;
private:
+ enum class Type { BUNDLE_BEGIN, BUNDLE_END };
+
typedef std::map<GraphImpl*, MPtr<CompiledGraph>> CompiledGraphs;
CompiledGraphs _compiled_graphs;
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index 1563de13..681c99da 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -31,13 +31,10 @@ namespace Events {
Move::Move(Engine& engine,
SPtr<Interface> client,
- int32_t id,
SampleCount timestamp,
- const Raul::Path& path,
- const Raul::Path& new_path)
- : Event(engine, client, id, timestamp)
- , _old_path(path)
- , _new_path(new_path)
+ const Ingen::Move& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _msg(msg)
{
}
@@ -50,25 +47,25 @@ Move::pre_process(PreProcessContext& ctx)
{
std::lock_guard<Store::Mutex> lock(_engine.store()->mutex());
- if (!_old_path.parent().is_parent_of(_new_path)) {
- return Event::pre_process_done(Status::PARENT_DIFFERS, _new_path);
+ 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(_old_path);
+ const Store::iterator i = _engine.store()->find(_msg.old_path);
if (i == _engine.store()->end()) {
- return Event::pre_process_done(Status::NOT_FOUND, _old_path);
+ return Event::pre_process_done(Status::NOT_FOUND, _msg.old_path);
}
- if (_engine.store()->find(_new_path) != _engine.store()->end()) {
- return Event::pre_process_done(Status::EXISTS, _new_path);
+ if (_engine.store()->find(_msg.new_path) != _engine.store()->end()) {
+ return Event::pre_process_done(Status::EXISTS, _msg.new_path);
}
- EnginePort* eport = _engine.driver()->get_port(_old_path);
+ EnginePort* eport = _engine.driver()->get_port(_msg.old_path);
if (eport) {
- _engine.driver()->rename_port(_old_path, _new_path);
+ _engine.driver()->rename_port(_msg.old_path, _msg.new_path);
}
- _engine.store()->rename(i, _new_path);
+ _engine.store()->rename(i, _msg.new_path);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -83,14 +80,14 @@ Move::post_process()
{
Broadcaster::Transfer t(*_engine.broadcaster());
if (respond() == Status::SUCCESS) {
- _engine.broadcaster()->move(_old_path, _new_path);
+ _engine.broadcaster()->message(_msg);
}
}
void
Move::undo(Interface& target)
{
- target.move(_new_path, _old_path);
+ target.move(_msg.new_path, _msg.old_path);
}
} // namespace Events
diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp
index c45c73aa..4e17033a 100644
--- a/src/server/events/Move.hpp
+++ b/src/server/events/Move.hpp
@@ -36,12 +36,10 @@ namespace Events {
class Move : public Event
{
public:
- Move(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- const Raul::Path& old_path,
- const Raul::Path& new_path);
+ Move(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Move& msg);
~Move();
@@ -51,8 +49,7 @@ public:
void undo(Interface& target);
private:
- const Raul::Path _old_path;
- const Raul::Path _new_path;
+ const Ingen::Move _msg;
};
} // namespace Events
diff --git a/src/server/events/Undo.cpp b/src/server/events/Undo.cpp
index 83279744..a6c80217 100644
--- a/src/server/events/Undo.cpp
+++ b/src/server/events/Undo.cpp
@@ -24,13 +24,20 @@ namespace Ingen {
namespace Server {
namespace Events {
-Undo::Undo(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- bool is_redo)
- : Event(engine, client, id, timestamp)
- , _is_redo(is_redo)
+Undo::Undo(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Undo& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _is_redo(false)
+{}
+
+Undo::Undo(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Redo& msg)
+ : Event(engine, client, msg.seq, timestamp)
+ , _is_redo(true)
{}
bool
diff --git a/src/server/events/Undo.hpp b/src/server/events/Undo.hpp
index 300c74f2..af4b0d65 100644
--- a/src/server/events/Undo.hpp
+++ b/src/server/events/Undo.hpp
@@ -32,11 +32,15 @@ namespace Events {
class Undo : public Event
{
public:
- Undo(Engine& engine,
- SPtr<Interface> client,
- int32_t id,
- SampleCount timestamp,
- bool is_redo);
+ Undo(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Undo& msg);
+
+ Undo(Engine& engine,
+ SPtr<Interface> client,
+ SampleCount timestamp,
+ const Ingen::Redo& msg);
bool pre_process(PreProcessContext& ctx);
void execute(RunContext& context);