diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ingen/ClientInterface.hpp | 5 | ||||
-rw-r--r-- | include/ingen/Status.hpp | 81 | ||||
-rw-r--r-- | include/ingen/client/SigClientInterface.hpp | 10 | ||||
-rw-r--r-- | include/ingen/client/ThreadedSigClientInterface.hpp | 13 |
4 files changed, 90 insertions, 19 deletions
diff --git a/include/ingen/ClientInterface.hpp b/include/ingen/ClientInterface.hpp index a72c4743..0bed231c 100644 --- a/include/ingen/ClientInterface.hpp +++ b/include/ingen/ClientInterface.hpp @@ -25,6 +25,7 @@ #include "raul/URI.hpp" #include "ingen/CommonInterface.hpp" +#include "ingen/Status.hpp" namespace Raul { class Path; } @@ -40,9 +41,7 @@ class ClientInterface : public CommonInterface public: virtual ~ClientInterface() {} - virtual void response_ok(int32_t id) = 0; - - virtual void response_error(int32_t id, const std::string& msg) = 0; + virtual void response(int32_t id, Status status) = 0; virtual void error(const std::string& msg) = 0; diff --git a/include/ingen/Status.hpp b/include/ingen/Status.hpp new file mode 100644 index 00000000..0e19435a --- /dev/null +++ b/include/ingen/Status.hpp @@ -0,0 +1,81 @@ +/* This file is part of Ingen. + * Copyright 2012 David Robillard <http://drobilla.net> + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_STATUS_HPP +#define INGEN_STATUS_HPP + +namespace Ingen { + +enum Status { + SUCCESS, + FAILURE, + + BAD_INDEX, + BAD_OBJECT_TYPE, + BAD_VALUE_TYPE, + CLIENT_NOT_FOUND, + CREATION_FAILED, + DIRECTION_MISMATCH, + EXISTS, + INTERNAL_ERROR, + INVALID_PARENT_PATH, + INVALID_POLY, + NOT_FOUND, + NOT_MOVABLE, + NO_SPACE, + PARENT_DIFFERS, + PARENT_NOT_FOUND, + PLUGIN_NOT_FOUND, + PORT_NOT_FOUND, + TYPE_MISMATCH, + UNKNOWN_TYPE +}; + +static inline const char* +ingen_status_string(Status st) +{ + switch (st) { + case SUCCESS: return "Success"; + case FAILURE: return "Failure"; + + case BAD_INDEX: return "Invalid index"; + case BAD_OBJECT_TYPE: return "Invalid object type"; + case BAD_VALUE_TYPE: return "Invalid value type"; + case CLIENT_NOT_FOUND: return "Client not found"; + case CREATION_FAILED: return "Creation failed"; + case DIRECTION_MISMATCH: return "Direction mismatch"; + case EXISTS: return "Object exists"; + case INTERNAL_ERROR: return "Internal error" ; + case INVALID_PARENT_PATH: return "Invalid parent path"; + case INVALID_POLY: return "Invalid polyphony"; + case NOT_FOUND: return "Object not found"; + case NOT_MOVABLE: return "Object not movable"; + case NO_SPACE: return "Insufficient space"; + case PARENT_DIFFERS: return "Parent differs"; + case PARENT_NOT_FOUND: return "Parent not found"; + case PORT_NOT_FOUND: return "Port not found"; + case PLUGIN_NOT_FOUND: return "Plugin not found"; + case TYPE_MISMATCH: return "Type mismatch"; + case UNKNOWN_TYPE: return "Unknown type"; + } + + return "Unknown error"; +} + +} // namespace Ingen + +#endif // INGEN_STATUS_HPP diff --git a/include/ingen/client/SigClientInterface.hpp b/include/ingen/client/SigClientInterface.hpp index ae42b169..559d1b15 100644 --- a/include/ingen/client/SigClientInterface.hpp +++ b/include/ingen/client/SigClientInterface.hpp @@ -44,8 +44,7 @@ public: Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; } - INGEN_SIGNAL(response_ok, void, int32_t) - INGEN_SIGNAL(response_error, void, int32_t, std::string) + INGEN_SIGNAL(response, void, int32_t, Status) INGEN_SIGNAL(bundle_begin, void) INGEN_SIGNAL(bundle_end, void) INGEN_SIGNAL(error, void, std::string) @@ -78,11 +77,8 @@ protected: void bundle_end() { EMIT(bundle_end); } - void response_ok(int32_t id) - { EMIT(response_ok, id); } - - void response_error(int32_t id, const std::string& msg) - { EMIT(response_error, id, msg); } + void response(int32_t id, Status status) + { EMIT(response, id, status); } void error(const std::string& msg) { EMIT(error, msg); } diff --git a/include/ingen/client/ThreadedSigClientInterface.hpp b/include/ingen/client/ThreadedSigClientInterface.hpp index 3de2eaea..6ded560e 100644 --- a/include/ingen/client/ThreadedSigClientInterface.hpp +++ b/include/ingen/client/ThreadedSigClientInterface.hpp @@ -53,8 +53,7 @@ class ThreadedSigClientInterface : public SigClientInterface public: ThreadedSigClientInterface(uint32_t queue_size) : _sigs(queue_size) - , response_ok_slot(_signal_response_ok.make_slot()) - , response_error_slot(_signal_response_error.make_slot()) + , response_slot(_signal_response.make_slot()) , error_slot(_signal_error.make_slot()) , new_port_slot(_signal_new_port.make_slot()) , put_slot(_signal_put.make_slot()) @@ -77,11 +76,8 @@ public: void bundle_end() { push_sig(bundle_end_slot); } - void response_ok(int32_t id) - { push_sig(sigc::bind(response_ok_slot, id)); } - - void response_error(int32_t id, const std::string& msg) - { push_sig(sigc::bind(response_error_slot, id, msg)); } + void response(int32_t id, Status status) + { push_sig(sigc::bind(response_slot, id, status)); } void error(const std::string& msg) { push_sig(sigc::bind(error_slot, msg)); } @@ -130,8 +126,7 @@ private: sigc::slot<void> bundle_begin_slot; sigc::slot<void> bundle_end_slot; - sigc::slot<void, int32_t> response_ok_slot; - sigc::slot<void, int32_t, std::string> response_error_slot; + sigc::slot<void, int32_t, Status> response_slot; sigc::slot<void, std::string> error_slot; sigc::slot<void, Raul::URI, Raul::URI, Raul::Symbol> new_plugin_slot; sigc::slot<void, Raul::Path, Raul::URI, uint32_t, bool> new_port_slot; |