summaryrefslogtreecommitdiffstats
path: root/src/gui/App.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-16 17:57:49 +0100
committerDavid Robillard <d@drobilla.net>2017-12-16 18:05:19 +0100
commit7513e0b53a36e96b9e1fa1884b78077a95da3081 (patch)
treefc96befa9b2c2f5255ada0d589c524e22626c16d /src/gui/App.cpp
parent2b88ebdcb7a438a8419ab6a815742b115b2dce03 (diff)
downloadingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.tar.gz
ingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.tar.bz2
ingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.zip
Add Message struct and remove tons of interface boilerplate
Diffstat (limited to 'src/gui/App.cpp')
-rw-r--r--src/gui/App.cpp42
1 files changed, 18 insertions, 24 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index 15bdc796..789ead6d 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -180,32 +180,12 @@ App::attach(SPtr<SigClientInterface> client)
stderr,
ColorContext::Color::CYAN));
-#define DUMP_CONNECT(signal, method) \
- client->signal_##signal().connect( \
- sigc::mem_fun(*_dumper.get(), &StreamWriter::method));
-
- DUMP_CONNECT(object_deleted, del);
- DUMP_CONNECT(object_moved, move);
- DUMP_CONNECT(put, put);
- DUMP_CONNECT(delta, delta);
- DUMP_CONNECT(connection, connect);
- DUMP_CONNECT(disconnection, disconnect);
- DUMP_CONNECT(disconnect_all, disconnect_all);
- DUMP_CONNECT(property_change, set_property);
-
-#undef DUMP_CONNECT
+ client->signal_message().connect(
+ sigc::mem_fun(*_dumper.get(), &StreamWriter::message));
}
_graph_tree_window->init(*this, *_store);
-
- _client->signal_response().connect(
- sigc::mem_fun(this, &App::response));
- _client->signal_error().connect(
- sigc::mem_fun(this, &App::error_message));
- _client->signal_put().connect(
- sigc::mem_fun(this, &App::put));
- _client->signal_property_change().connect(
- sigc::mem_fun(this, &App::property_change));
+ _client->signal_message().connect(sigc::mem_fun(this, &App::message));
}
void
@@ -238,6 +218,20 @@ App::serialiser()
}
void
+App::message(const Message& msg)
+{
+ if (const Response* const r = boost::get<Response>(&msg)) {
+ response(r->id, r->status, r->subject);
+ } else if (const Error* const e = boost::get<Error>(&msg)) {
+ error_message(e->message);
+ } else if (const Put* const p = boost::get<Put>(&msg)) {
+ put(p->uri, p->properties, p->ctx);
+ } else if (const SetProperty* const s = boost::get<SetProperty>(&msg)) {
+ property_change(s->subject, s->predicate, s->value, s->ctx);
+ }
+}
+
+void
App::response(int32_t id, Status status, const std::string& subject)
{
if (status != Status::SUCCESS) {
@@ -269,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_property_change().emit(subject, key, value, ctx);
+ _client->signal_message().emit(SetProperty{subject, key, value, ctx});
}
}