summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
Diffstat (limited to 'ingen')
-rw-r--r--ingen/AtomWriter.hpp5
-rw-r--r--ingen/Interface.hpp53
-rw-r--r--ingen/Message.hpp15
-rw-r--r--ingen/Tee.hpp7
-rw-r--r--ingen/client/ClientStore.hpp2
-rw-r--r--ingen/client/SigClientInterface.hpp2
6 files changed, 49 insertions, 35 deletions
diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp
index 21fcb933..20d152e6 100644
--- a/ingen/AtomWriter.hpp
+++ b/ingen/AtomWriter.hpp
@@ -42,8 +42,6 @@ public:
return Raul::URI("ingen:/clients/atom_writer");
}
- void set_response_id(int32_t id);
-
void message(const Message& message) override;
void operator()(const BundleBegin&);
@@ -67,7 +65,7 @@ private:
void forge_uri(const Raul::URI& uri);
void forge_properties(const Properties& properties);
void forge_arc(const Raul::Path& tail, const Raul::Path& head);
- void forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type);
+ void forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type, int32_t id);
void forge_context(Resource::Graph ctx);
void finish_msg();
@@ -77,7 +75,6 @@ private:
AtomSink& _sink;
AtomForgeSink _out;
LV2_Atom_Forge _forge;
- int32_t _id;
};
} // namespace Ingen
diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp
index 68f21304..a516892c 100644
--- a/ingen/Interface.hpp
+++ b/ingen/Interface.hpp
@@ -21,6 +21,7 @@
#ifndef INGEN_INTERFACE_HPP
#define INGEN_INTERFACE_HPP
+#include <cstdint>
#include <string>
#include "ingen/Message.hpp"
@@ -44,7 +45,9 @@ namespace Ingen {
class INGEN_API Interface
{
public:
- virtual ~Interface() {}
+ Interface() : _seq(0) {}
+
+ virtual ~Interface() = default;
virtual Raul::URI uri() const = 0;
@@ -54,22 +57,27 @@ public:
virtual void set_respondee(SPtr<Interface> respondee) {}
- /** Set the ID to use to respond to the next message.
- * Setting the ID to 0 will disable responses.
+ virtual void message(const Message& msg) = 0;
+
+ /** @name Convenience API
+ * @{
*/
- virtual void set_response_id(int32_t id) = 0;
- virtual void message(const Message& message) = 0;
+ inline void operator()(const Message& msg) { message(msg); }
+
+ inline void set_response_id(int32_t id) {
+ _seq = id;
+ }
- inline void bundle_begin() { message(BundleBegin{}); }
+ inline void bundle_begin() { message(BundleBegin{_seq++}); }
- inline void bundle_end() { message(BundleEnd{}); }
+ inline void bundle_end() { message(BundleEnd{_seq++}); }
inline void put(const Raul::URI& uri,
const Properties& properties,
Resource::Graph ctx = Resource::Graph::DEFAULT)
{
- message(Put{uri, properties, ctx});
+ message(Put{_seq++, uri, properties, ctx});
}
inline void delta(const Raul::URI& uri,
@@ -77,34 +85,34 @@ public:
const Properties& add,
Resource::Graph ctx = Resource::Graph::DEFAULT)
{
- message(Delta{uri, remove, add, ctx});
+ message(Delta{_seq++, uri, remove, add, ctx});
}
inline void copy(const Raul::URI& old_uri, const Raul::URI& new_uri)
{
- message(Copy{old_uri, new_uri});
+ message(Copy{_seq++, old_uri, new_uri});
}
inline void move(const Raul::Path& old_path, const Raul::Path& new_path)
{
- message(Move{old_path, new_path});
+ message(Move{_seq++, old_path, new_path});
}
- inline void del(const Raul::URI& uri) { message(Del{uri}); }
+ inline void del(const Raul::URI& uri) { message(Del{_seq++, uri}); }
inline void connect(const Raul::Path& tail, const Raul::Path& head)
{
- message(Connect{tail, head});
+ message(Connect{_seq++, tail, head});
}
inline void disconnect(const Raul::Path& tail, const Raul::Path& head)
{
- message(Disconnect{tail, head});
+ message(Disconnect{_seq++, tail, head});
}
inline void disconnect_all(const Raul::Path& graph, const Raul::Path& path)
{
- message(DisconnectAll{graph, path});
+ message(DisconnectAll{_seq++, graph, path});
}
inline void set_property(const Raul::URI& subject,
@@ -112,14 +120,14 @@ public:
const Atom& value,
Resource::Graph ctx = Resource::Graph::DEFAULT)
{
- message(SetProperty{subject, predicate, value, ctx});
+ message(SetProperty{_seq++, subject, predicate, value, ctx});
}
- inline void undo() { message(Undo{}); }
+ inline void undo() { message(Undo{_seq++}); }
- inline void redo() { message(Redo{}); }
+ inline void redo() { message(Redo{_seq++}); }
- inline void get(const Raul::URI& uri) { message(Get{uri}); }
+ inline void get(const Raul::URI& uri) { message(Get{_seq++, uri}); }
inline void response(int32_t id,
Status status,
@@ -128,8 +136,13 @@ public:
}
inline void error(const std::string& error_message) {
- message(Error{error_message});
+ message(Error{_seq++, error_message});
}
+
+ /** @} */
+
+private:
+ int32_t _seq;
};
} // namespace Ingen
diff --git a/ingen/Message.hpp b/ingen/Message.hpp
index d4118dcb..fd5231ad 100644
--- a/ingen/Message.hpp
+++ b/ingen/Message.hpp
@@ -37,31 +37,37 @@ namespace Ingen {
struct BundleBegin
{
+ int32_t seq;
};
struct BundleEnd
{
+ int32_t seq;
};
struct Connect
{
+ int32_t seq;
Raul::Path tail;
Raul::Path head;
};
struct Copy
{
+ int32_t seq;
Raul::URI old_uri;
Raul::URI new_uri;
};
struct Del
{
+ int32_t seq;
Raul::URI uri;
};
struct Delta
{
+ int32_t seq;
Raul::URI uri;
Properties remove;
Properties add;
@@ -70,34 +76,40 @@ struct Delta
struct Disconnect
{
+ int32_t seq;
Raul::Path tail;
Raul::Path head;
};
struct DisconnectAll
{
+ int32_t seq;
Raul::Path graph;
Raul::Path path;
};
struct Error
{
+ int32_t seq;
std::string message;
};
struct Get
{
+ int32_t seq;
Raul::URI subject;
};
struct Move
{
+ int32_t seq;
Raul::Path old_path;
Raul::Path new_path;
};
struct Put
{
+ int32_t seq;
Raul::URI uri;
Properties properties;
Resource::Graph ctx;
@@ -105,6 +117,7 @@ struct Put
struct Redo
{
+ int32_t seq;
};
struct Response
@@ -116,6 +129,7 @@ struct Response
struct SetProperty
{
+ int32_t seq;
Raul::URI subject;
Raul::URI predicate;
Atom value;
@@ -124,6 +138,7 @@ struct SetProperty
struct Undo
{
+ int32_t seq;
};
using Message = boost::variant<BundleBegin,
diff --git a/ingen/Tee.hpp b/ingen/Tee.hpp
index 12cccc91..f02d8602 100644
--- a/ingen/Tee.hpp
+++ b/ingen/Tee.hpp
@@ -54,13 +54,6 @@ public:
(*_sinks.begin())->set_respondee(respondee);
}
- void set_response_id(int32_t id) {
- std::lock_guard<std::mutex> lock(_sinks_mutex);
- for (const auto& s : _sinks) {
- s->set_response_id(id);
- }
- }
-
void message(const Message& message) override {
std::lock_guard<std::mutex> lock(_sinks_mutex);
for (const auto& s : _sinks) {
diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp
index 899273dc..2724df9a 100644
--- a/ingen/client/ClientStore.hpp
+++ b/ingen/client/ClientStore.hpp
@@ -92,8 +92,6 @@ public:
void operator()(const SetProperty&);
void operator()(const Undo&) {}
- void set_response_id(int32_t id) {}
-
INGEN_SIGNAL(new_object, void, SPtr<ObjectModel>);
INGEN_SIGNAL(new_plugin, void, SPtr<PluginModel>);
INGEN_SIGNAL(plugin_deleted, void, Raul::URI);
diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp
index 2934e8b1..04af2dd9 100644
--- a/ingen/client/SigClientInterface.hpp
+++ b/ingen/client/SigClientInterface.hpp
@@ -54,8 +54,6 @@ public:
virtual bool emit_signals() { return false; }
protected:
- void set_response_id(int32_t id) {}
-
void message(const Message& msg) override {
_signal_message(msg);
}