summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-16 22:31:10 +0100
committerDavid Robillard <d@drobilla.net>2017-12-16 22:31:10 +0100
commit68901d7caa0636895de593e0b23cdec4fb53deaa (patch)
tree79fbfd567f2cc2b29ab225cec674127acb4d54d4 /src
parentf2d3c77c9a470f20506c90098ab5cf4d3e5c9eff (diff)
downloadingen-68901d7caa0636895de593e0b23cdec4fb53deaa.tar.gz
ingen-68901d7caa0636895de593e0b23cdec4fb53deaa.tar.bz2
ingen-68901d7caa0636895de593e0b23cdec4fb53deaa.zip
Move sequence numbers into messages and simplify interfaces
Diffstat (limited to 'src')
-rw-r--r--src/AtomReader.cpp48
-rw-r--r--src/AtomWriter.cpp52
-rw-r--r--src/gui/App.cpp2
-rw-r--r--src/server/Broadcaster.hpp2
-rw-r--r--src/server/EventWriter.cpp43
-rw-r--r--src/server/EventWriter.hpp3
6 files changed, 65 insertions, 85 deletions
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 40be80e2..eb5b957b 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -158,25 +158,24 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
const boost::optional<Raul::URI> subject_uri = atom_to_uri(subject);
- const int32_t seq_id = ((number && number->type == _uris.atom_Int)
- ? ((const LV2_Atom_Int*)number)->body
- : default_id);
- _iface.set_response_id(seq_id);
+ const int32_t seq = ((number && number->type == _uris.atom_Int)
+ ? ((const LV2_Atom_Int*)number)->body
+ : default_id);
if (obj->body.otype == _uris.patch_Get) {
if (subject_uri) {
- _iface.get(*subject_uri);
+ _iface(Get{seq, *subject_uri});
}
} else if (obj->body.otype == _uris.ingen_BundleStart) {
- _iface.bundle_begin();
+ _iface(BundleBegin{seq});
} else if (obj->body.otype == _uris.ingen_BundleEnd) {
- _iface.bundle_end();
+ _iface(BundleEnd{seq});
} else if (obj->body.otype == _uris.patch_Delete) {
const LV2_Atom_Object* body = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
if (subject_uri && !body) {
- _iface.del(*subject_uri);
+ _iface(Del{seq, *subject_uri});
return true;
} else if (body && body->body.otype == _uris.ingen_Arc) {
const LV2_Atom* tail = NULL;
@@ -193,9 +192,9 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
boost::optional<Raul::Path> head_path(atom_to_path(head));
boost::optional<Raul::Path> other_path(atom_to_path(incidentTo));
if (tail_path && head_path) {
- _iface.disconnect(*tail_path, *head_path);
+ _iface(Disconnect{seq, *tail_path, *head_path});
} else if (subject_path && other_path) {
- _iface.disconnect_all(*subject_path, *other_path);
+ _iface(DisconnectAll{seq, *subject_path, *other_path});
} else {
_log.warn("Delete of unknown object\n");
return false;
@@ -231,14 +230,14 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
boost::optional<Raul::Path> tail_path(atom_to_path(tail));
boost::optional<Raul::Path> head_path(atom_to_path(head));
if (tail_path && head_path) {
- _iface.connect(*tail_path, *head_path);
+ _iface(Connect{seq, *tail_path, *head_path});
} else {
_log.warn("Arc has non-path tail or head\n");
}
} else {
Ingen::Properties props;
get_props(body, props);
- _iface.put(*subject_uri, props, atom_to_context(context));
+ _iface(Put{seq, *subject_uri, props, atom_to_context(context)});
}
} else if (obj->body.otype == _uris.patch_Set) {
if (!subject_uri) {
@@ -264,10 +263,11 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
Atom atom;
get_atom(value, atom);
- _iface.set_property(*subject_uri,
- Raul::URI(_map.unmap_uri(prop->body)),
- atom,
- atom_to_context(context));
+ _iface(SetProperty{seq,
+ *subject_uri,
+ Raul::URI(_map.unmap_uri(prop->body)),
+ atom,
+ atom_to_context(context)});
} else if (obj->body.otype == _uris.patch_Patch) {
if (!subject_uri) {
_log.warn("Patch message has no subject\n");
@@ -296,8 +296,8 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
Ingen::Properties remove_props;
get_props(remove, remove_props);
- _iface.delta(*subject_uri, remove_props, add_props,
- atom_to_context(context));
+ _iface(Delta{seq, *subject_uri, remove_props, add_props,
+ atom_to_context(context)});
} else if (obj->body.otype == _uris.patch_Copy) {
if (!subject) {
_log.warn("Copy message has no subject\n");
@@ -323,7 +323,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
return false;
}
- _iface.copy(*subject_uri, *dest_uri);
+ _iface(Copy{seq, *subject_uri, *dest_uri});
} else if (obj->body.otype == _uris.patch_Move) {
if (!subject) {
_log.warn("Move message has no subject\n");
@@ -349,7 +349,7 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
return false;
}
- _iface.move(*subject_path, *dest_path);
+ _iface(Move{seq, *subject_path, *dest_path});
} else if (obj->body.otype == _uris.patch_Response) {
const LV2_Atom* seq = NULL;
const LV2_Atom* body = NULL;
@@ -364,13 +364,13 @@ AtomReader::write(const LV2_Atom* msg, int32_t default_id)
_log.warn("Response message body is not integer\n");
return false;
}
- _iface.response(((const LV2_Atom_Int*)seq)->body,
+ _iface(Response{((const LV2_Atom_Int*)seq)->body,
(Ingen::Status)((const LV2_Atom_Int*)body)->body,
- subject_uri ? subject_uri->c_str() : "");
+ subject_uri ? subject_uri->c_str() : ""});
} else if (obj->body.otype == _uris.ingen_BundleStart) {
- _iface.bundle_begin();
+ _iface(BundleBegin{seq});
} else if (obj->body.otype == _uris.ingen_BundleEnd) {
- _iface.bundle_end();
+ _iface(BundleEnd{seq});
} else {
_log.warn(fmt("Unknown object type <%1%>\n")
% _map.unmap_uri(obj->body.otype));
diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index 1615630f..cf5f40ac 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -66,7 +66,6 @@ AtomWriter::AtomWriter(URIMap& map, URIs& uris, AtomSink& sink)
: _map(map)
, _uris(uris)
, _sink(sink)
- , _id(0)
{
lv2_atom_forge_init(&_forge, &map.urid_map_feature()->urid_map);
_out.set_forge_sink(&_forge);
@@ -109,19 +108,19 @@ AtomWriter::message(const Message& message)
* @endcode
*/
void
-AtomWriter::operator()(const BundleBegin&)
+AtomWriter::operator()(const BundleBegin& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.ingen_BundleStart);
+ forge_request(&msg, _uris.ingen_BundleStart, message.seq);
lv2_atom_forge_pop(&_forge, &msg);
finish_msg();
}
void
-AtomWriter::operator()(const BundleEnd&)
+AtomWriter::operator()(const BundleEnd& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.ingen_BundleEnd);
+ forge_request(&msg, _uris.ingen_BundleEnd, message.seq);
lv2_atom_forge_pop(&_forge, &msg);
finish_msg();
}
@@ -163,13 +162,13 @@ AtomWriter::forge_arc(const Raul::Path& tail, const Raul::Path& head)
}
void
-AtomWriter::forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type)
+AtomWriter::forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type, int32_t id)
{
lv2_atom_forge_object(&_forge, frame, 0, type);
- if (_id) {
+ if (id) {
lv2_atom_forge_key(&_forge, _uris.patch_sequenceNumber);
- lv2_atom_forge_int(&_forge, _id);
+ lv2_atom_forge_int(&_forge, id);
}
}
@@ -217,7 +216,7 @@ void
AtomWriter::operator()(const Put& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Put);
+ forge_request(&msg, _uris.patch_Put, message.seq);
forge_context(message.ctx);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.uri);
@@ -262,7 +261,7 @@ void
AtomWriter::operator()(const Delta& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Patch);
+ forge_request(&msg, _uris.patch_Patch, message.seq);
forge_context(message.ctx);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.uri);
@@ -310,7 +309,7 @@ void
AtomWriter::operator()(const Copy& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Copy);
+ forge_request(&msg, _uris.patch_Copy, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.old_uri);
lv2_atom_forge_key(&_forge, _uris.patch_destination);
@@ -339,7 +338,7 @@ void
AtomWriter::operator()(const Move& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Move);
+ forge_request(&msg, _uris.patch_Move, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(path_to_uri(message.old_path));
lv2_atom_forge_key(&_forge, _uris.patch_destination);
@@ -367,7 +366,7 @@ void
AtomWriter::operator()(const Del& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Delete);
+ forge_request(&msg, _uris.patch_Delete, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.uri);
lv2_atom_forge_pop(&_forge, &msg);
@@ -392,7 +391,7 @@ void
AtomWriter::operator()(const SetProperty& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Set);
+ forge_request(&msg, _uris.patch_Set, message.seq);
forge_context(message.ctx);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.subject);
@@ -419,10 +418,10 @@ AtomWriter::operator()(const SetProperty& message)
* @endcode
*/
void
-AtomWriter::operator()(const Undo&)
+AtomWriter::operator()(const Undo& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.ingen_Undo);
+ forge_request(&msg, _uris.ingen_Undo, message.seq);
lv2_atom_forge_pop(&_forge, &msg);
finish_msg();
}
@@ -437,10 +436,10 @@ AtomWriter::operator()(const Undo&)
* @endcode
*/
void
-AtomWriter::operator()(const Redo&)
+AtomWriter::operator()(const Redo& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.ingen_Redo);
+ forge_request(&msg, _uris.ingen_Redo, message.seq);
lv2_atom_forge_pop(&_forge, &msg);
finish_msg();
}
@@ -461,7 +460,7 @@ void
AtomWriter::operator()(const Get& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Get);
+ forge_request(&msg, _uris.patch_Get, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(message.subject);
lv2_atom_forge_pop(&_forge, &msg);
@@ -495,7 +494,7 @@ void
AtomWriter::operator()(const Connect& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Put);
+ forge_request(&msg, _uris.patch_Put, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(path_to_uri(Raul::Path::lca(message.tail, message.head)));
lv2_atom_forge_key(&_forge, _uris.patch_body);
@@ -524,7 +523,7 @@ void
AtomWriter::operator()(const Disconnect& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Delete);
+ forge_request(&msg, _uris.patch_Delete, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_body);
forge_arc(message.tail, message.head);
lv2_atom_forge_pop(&_forge, &msg);
@@ -553,7 +552,7 @@ void
AtomWriter::operator()(const DisconnectAll& message)
{
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Delete);
+ forge_request(&msg, _uris.patch_Delete, message.seq);
lv2_atom_forge_key(&_forge, _uris.patch_subject);
forge_uri(path_to_uri(message.graph));
@@ -569,13 +568,6 @@ AtomWriter::operator()(const DisconnectAll& message)
finish_msg();
}
-void
-AtomWriter::set_response_id(int32_t id)
-{
- _id = id;
-}
-
-
/** @page protocol
* @section Responses
*
@@ -615,7 +607,7 @@ AtomWriter::operator()(const Response& response)
}
LV2_Atom_Forge_Frame msg;
- forge_request(&msg, _uris.patch_Response);
+ forge_request(&msg, _uris.patch_Response, 0);
lv2_atom_forge_key(&_forge, _uris.patch_sequenceNumber);
lv2_atom_forge_int(&_forge, response.id);
if (!subject.empty() && Raul::URI::is_valid(subject)) {
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 789ead6d..c0f3f9bd 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -263,7 +263,7 @@ App::set_property(const Raul::URI& subject,
went as planned here and fire the signal ourselves as if the server
feedback came back immediately. */
if (key != uris().ingen_activity) {
- _client->signal_message().emit(SetProperty{subject, key, value, ctx});
+ _client->signal_message().emit(SetProperty{0, subject, key, value, ctx});
}
}
diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp
index 6fcb3e4d..93b6ec8f 100644
--- a/src/server/Broadcaster.hpp
+++ b/src/server/Broadcaster.hpp
@@ -99,8 +99,6 @@ public:
Raul::URI uri() const { return Raul::URI("ingen:/broadcaster"); }
- void set_response_id(int32_t id) {} ///< N/A
-
private:
friend class Transfer;
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index 2fc15802..7cec07bc 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -29,7 +29,6 @@ namespace Server {
EventWriter::EventWriter(Engine& engine)
: _engine(engine)
- , _request_id(0)
, _event_mode(Event::Mode::NORMAL)
{
}
@@ -41,31 +40,25 @@ EventWriter::now() const
}
void
-EventWriter::set_response_id(int32_t id)
-{
- _request_id = id;
-}
-
-void
EventWriter::message(const Message& msg)
{
boost::apply_visitor(*this, msg);
}
void
-EventWriter::operator()(const BundleBegin&)
+EventWriter::operator()(const BundleBegin& msg)
{
_engine.enqueue_event(
- new Events::Mark(_engine, _respondee, _request_id, now(),
+ new Events::Mark(_engine, _respondee, msg.seq, now(),
Events::Mark::Type::BUNDLE_START),
_event_mode);
}
void
-EventWriter::operator()(const BundleEnd&)
+EventWriter::operator()(const BundleEnd& msg)
{
_engine.enqueue_event(
- new Events::Mark(_engine, _respondee, _request_id, now(),
+ new Events::Mark(_engine, _respondee, msg.seq, now(),
Events::Mark::Type::BUNDLE_END),
_event_mode);
}
@@ -74,7 +67,7 @@ void
EventWriter::operator()(const Put& msg)
{
_engine.enqueue_event(
- new Events::Delta(_engine, _respondee, _request_id, now(),
+ new Events::Delta(_engine, _respondee, msg.seq, now(),
Events::Delta::Type::PUT, msg.ctx, msg.uri, msg.properties),
_event_mode);
}
@@ -83,7 +76,7 @@ void
EventWriter::operator()(const Delta& msg)
{
_engine.enqueue_event(
- new Events::Delta(_engine, _respondee, _request_id, now(),
+ new Events::Delta(_engine, _respondee, msg.seq, now(),
Events::Delta::Type::PATCH, msg.ctx, msg.uri, msg.add, msg.remove),
_event_mode);
}
@@ -92,7 +85,7 @@ void
EventWriter::operator()(const Copy& msg)
{
_engine.enqueue_event(
- new Events::Copy(_engine, _respondee, _request_id, now(),
+ new Events::Copy(_engine, _respondee, msg.seq, now(),
msg.old_uri, msg.new_uri),
_event_mode);
}
@@ -101,7 +94,7 @@ void
EventWriter::operator()(const Move& msg)
{
_engine.enqueue_event(
- new Events::Move(_engine, _respondee, _request_id, now(),
+ new Events::Move(_engine, _respondee, msg.seq, now(),
msg.old_path, msg.new_path),
_event_mode);
}
@@ -110,7 +103,7 @@ void
EventWriter::operator()(const Del& msg)
{
_engine.enqueue_event(
- new Events::Delete(_engine, _respondee, _request_id, now(), msg.uri),
+ new Events::Delete(_engine, _respondee, msg.seq, now(), msg.uri),
_event_mode);
}
@@ -118,7 +111,7 @@ void
EventWriter::operator()(const Connect& msg)
{
_engine.enqueue_event(
- new Events::Connect(_engine, _respondee, _request_id, now(),
+ new Events::Connect(_engine, _respondee, msg.seq, now(),
msg.tail, msg.head),
_event_mode);
@@ -128,7 +121,7 @@ void
EventWriter::operator()(const Disconnect& msg)
{
_engine.enqueue_event(
- new Events::Disconnect(_engine, _respondee, _request_id, now(),
+ new Events::Disconnect(_engine, _respondee, msg.seq, now(),
msg.tail, msg.head),
_event_mode);
}
@@ -137,7 +130,7 @@ void
EventWriter::operator()(const DisconnectAll& msg)
{
_engine.enqueue_event(
- new Events::DisconnectAll(_engine, _respondee, _request_id, now(),
+ new Events::DisconnectAll(_engine, _respondee, msg.seq, now(),
msg.graph, msg.path),
_event_mode);
}
@@ -146,25 +139,25 @@ void
EventWriter::operator()(const SetProperty& msg)
{
_engine.enqueue_event(
- new Events::Delta(_engine, _respondee, _request_id, now(),
+ new Events::Delta(_engine, _respondee, msg.seq, now(),
Events::Delta::Type::SET, msg.ctx,
msg.subject, {{msg.predicate, msg.value}}, {}),
_event_mode);
}
void
-EventWriter::operator()(const Undo&)
+EventWriter::operator()(const Undo& msg)
{
_engine.enqueue_event(
- new Events::Undo(_engine, _respondee, _request_id, now(), false),
+ new Events::Undo(_engine, _respondee, msg.seq, now(), false),
_event_mode);
}
void
-EventWriter::operator()(const Redo&)
+EventWriter::operator()(const Redo& msg)
{
_engine.enqueue_event(
- new Events::Undo(_engine, _respondee, _request_id, now(), true),
+ new Events::Undo(_engine, _respondee, msg.seq, now(), true),
_event_mode);
}
@@ -172,7 +165,7 @@ void
EventWriter::operator()(const Get& msg)
{
_engine.enqueue_event(
- new Events::Get(_engine, _respondee, _request_id, now(), msg.subject),
+ new Events::Get(_engine, _respondee, msg.seq, now(), msg.subject),
_event_mode);
}
diff --git a/src/server/EventWriter.hpp b/src/server/EventWriter.hpp
index 4e8eaa4c..74c27b27 100644
--- a/src/server/EventWriter.hpp
+++ b/src/server/EventWriter.hpp
@@ -50,8 +50,6 @@ public:
_respondee = respondee;
}
- virtual void set_response_id(int32_t id);
-
void message(const Message& msg) override;
void set_event_mode(Event::Mode mode) { _event_mode = mode; }
@@ -77,7 +75,6 @@ public:
protected:
Engine& _engine;
SPtr<Interface> _respondee;
- int32_t _request_id;
Event::Mode _event_mode;
private: