diff options
author | David Robillard <d@drobilla.net> | 2017-12-16 17:57:49 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-12-16 18:05:19 +0100 |
commit | 7513e0b53a36e96b9e1fa1884b78077a95da3081 (patch) | |
tree | fc96befa9b2c2f5255ada0d589c524e22626c16d /tests | |
parent | 2b88ebdcb7a438a8419ab6a815742b115b2dce03 (diff) | |
download | ingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.tar.gz ingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.tar.bz2 ingen-7513e0b53a36e96b9e1fa1884b78077a95da3081.zip |
Add Message struct and remove tons of interface boilerplate
Diffstat (limited to 'tests')
-rw-r--r-- | tests/TestClient.hpp | 67 |
1 files changed, 15 insertions, 52 deletions
diff --git a/tests/TestClient.hpp b/tests/TestClient.hpp index 968e4423..90fc212b 100644 --- a/tests/TestClient.hpp +++ b/tests/TestClient.hpp @@ -17,6 +17,8 @@ #ifndef INGEN_TESTCLIENT_HPP #define INGEN_TESTCLIENT_HPP +#include <boost/variant.hpp> + #include "ingen/Interface.hpp" using namespace Ingen; @@ -29,62 +31,23 @@ public: Raul::URI uri() const { return Raul::URI("ingen:testClient"); } - void bundle_begin() {} - - void bundle_end() {} - - void put(const Raul::URI& uri, - const Properties& properties, - Resource::Graph ctx = Resource::Graph::DEFAULT) {} - - void delta(const Raul::URI& uri, - const Properties& remove, - const Properties& add, - Resource::Graph ctx = Resource::Graph::DEFAULT) {} - - void copy(const Raul::URI& old_uri, - const Raul::URI& new_uri) {} - - void move(const Raul::Path& old_path, - const Raul::Path& new_path) {} - - void del(const Raul::URI& uri) {} - - void connect(const Raul::Path& tail, - const Raul::Path& head) {} - - void disconnect(const Raul::Path& tail, - const Raul::Path& head) {} - - void disconnect_all(const Raul::Path& parent_patch_path, - const Raul::Path& path) {} - - void set_property(const Raul::URI& subject, - const Raul::URI& predicate, - const Atom& value, - Resource::Graph ctx = Resource::Graph::DEFAULT) {} - - void set_response_id(int32_t id) {} - - void get(const Raul::URI& uri) {} - - void undo() {} - - void redo() {} - - void response(int32_t id, Status status, const std::string& subject) { - if (status != Status::SUCCESS) { - _log.error(fmt("error on message %1%: %2% (%3%)\n") - % id % ingen_status_string(status) % subject); + void set_response_id(int32_t id) override {} + + void message(const Message& msg) override { + if (const Response* const response = boost::get<Response>(&msg)) { + if (response->status != Status::SUCCESS) { + _log.error(fmt("error on message %1%: %2% (%3%)\n") + % response->id + % ingen_status_string(response->status) + % response->subject); + exit(EXIT_FAILURE); + } + } else if (const Error* const error = boost::get<Error>(&msg)) { + _log.error(fmt("error: %1%\n") % error->message); exit(EXIT_FAILURE); } } - void error(const std::string& msg) { - _log.error(fmt("error: %1%\n") % msg); - exit(EXIT_FAILURE); - } - private: Log& _log; }; |