From bb1c49dfa484db080938cff6f8f70167c9026a1c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 24 Jul 2007 19:26:47 +0000 Subject: Consistently rename all C++ files .cpp/.hpp. Fix (some) inclusion guard names to not clash with other libs. git-svn-id: http://svn.drobilla.net/lad/ingen@613 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/ClientInterface.h | 124 --------------------------- src/common/interface/ClientInterface.hpp | 123 ++++++++++++++++++++++++++ src/common/interface/ClientKey.h | 86 ------------------- src/common/interface/ClientKey.hpp | 86 +++++++++++++++++++ src/common/interface/EngineInterface.h | 142 ------------------------------- src/common/interface/EngineInterface.hpp | 142 +++++++++++++++++++++++++++++++ src/common/interface/Makefile.am | 8 +- src/common/interface/Responder.h | 75 ---------------- src/common/interface/Responder.hpp | 74 ++++++++++++++++ 9 files changed, 429 insertions(+), 431 deletions(-) delete mode 100644 src/common/interface/ClientInterface.h create mode 100644 src/common/interface/ClientInterface.hpp delete mode 100644 src/common/interface/ClientKey.h create mode 100644 src/common/interface/ClientKey.hpp delete mode 100644 src/common/interface/EngineInterface.h create mode 100644 src/common/interface/EngineInterface.hpp delete mode 100644 src/common/interface/Responder.h create mode 100644 src/common/interface/Responder.hpp (limited to 'src/common/interface') diff --git a/src/common/interface/ClientInterface.h b/src/common/interface/ClientInterface.h deleted file mode 100644 index 68dcaac3..00000000 --- a/src/common/interface/ClientInterface.h +++ /dev/null @@ -1,124 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * 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 CLIENTINTERFACE_H -#define CLIENTINTERFACE_H - -#include -#include -#include -using std::string; - -namespace Ingen { -namespace Shared { - - -/** The (only) interface the engine uses to communicate with clients. - * - * Purely virtual (except for the destructor). - */ -class ClientInterface -{ -public: - - virtual ~ClientInterface() {} - - virtual void response(int32_t id, bool success, string msg) = 0; - - virtual void enable() = 0; - - /** Signifies the client does not wish to receive any messages until - * enable is called. Useful for performance and avoiding feedback. - */ - virtual void disable() = 0; - - /** Bundles are a group of messages that are guaranteed to be in an - * atomic unit with guaranteed order (eg a packet). For datagram - * protocols (like UDP) there is likely an upper limit on bundle size. - */ - virtual void bundle_begin() = 0; - virtual void bundle_end() = 0; - - /** Transfers are 'weak' bundles. These are used to break a large group - * of similar/related messages into larger chunks (solely for communication - * efficiency). A bunch of messages in a transfer will arrive as 1 or more - * bundles (so a transfer can exceep the maximum bundle (packet) size). - */ - virtual void transfer_begin() = 0; - virtual void transfer_end() = 0; - - virtual void error(string msg) = 0; - - virtual void num_plugins(uint32_t num_plugins) = 0; - - virtual void new_plugin(string uri, - string type_uri, - string name) = 0; - - virtual void new_patch(string path, uint32_t poly) = 0; - - virtual void new_node(string plugin_uri, - string node_path, - bool is_polyphonic, - uint32_t num_ports) = 0; - - virtual void new_port(string path, - string data_type, - bool is_output) = 0; - - virtual void patch_enabled(string path) = 0; - - virtual void patch_disabled(string path) = 0; - - virtual void patch_cleared(string path) = 0; - - virtual void object_renamed(string old_path, - string new_path) = 0; - - virtual void object_destroyed(string path) = 0; - - virtual void connection(string src_port_path, - string dst_port_path) = 0; - - virtual void disconnection(string src_port_path, - string dst_port_path) = 0; - - virtual void metadata_update(string subject_path, - string predicate, - Raul::Atom value) = 0; - - virtual void control_change(string port_path, - float value) = 0; - - virtual void program_add(string node_path, - uint32_t bank, - uint32_t program, - string program_name) = 0; - - virtual void program_remove(string node_path, - uint32_t bank, - uint32_t program) = 0; - -protected: - ClientInterface() {} -}; - - -} // namespace Shared -} // namespace Ingen - -#endif diff --git a/src/common/interface/ClientInterface.hpp b/src/common/interface/ClientInterface.hpp new file mode 100644 index 00000000..06114101 --- /dev/null +++ b/src/common/interface/ClientInterface.hpp @@ -0,0 +1,123 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * 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 CLIENTINTERFACE_H +#define CLIENTINTERFACE_H + +#include +#include +#include + +namespace Ingen { +namespace Shared { + + +/** The (only) interface the engine uses to communicate with clients. + * + * Purely virtual (except for the destructor). + */ +class ClientInterface +{ +public: + + virtual ~ClientInterface() {} + + virtual void response(int32_t id, bool success, std::string msg) = 0; + + virtual void enable() = 0; + + /** Signifies the client does not wish to receive any messages until + * enable is called. Useful for performance and avoiding feedback. + */ + virtual void disable() = 0; + + /** Bundles are a group of messages that are guaranteed to be in an + * atomic unit with guaranteed order (eg a packet). For datagram + * protocols (like UDP) there is likely an upper limit on bundle size. + */ + virtual void bundle_begin() = 0; + virtual void bundle_end() = 0; + + /** Transfers are 'weak' bundles. These are used to break a large group + * of similar/related messages into larger chunks (solely for communication + * efficiency). A bunch of messages in a transfer will arrive as 1 or more + * bundles (so a transfer can exceep the maximum bundle (packet) size). + */ + virtual void transfer_begin() = 0; + virtual void transfer_end() = 0; + + virtual void error(std::string msg) = 0; + + virtual void num_plugins(uint32_t num_plugins) = 0; + + virtual void new_plugin(std::string uri, + std::string type_uri, + std::string name) = 0; + + virtual void new_patch(std::string path, uint32_t poly) = 0; + + virtual void new_node(std::string plugin_uri, + std::string node_path, + bool is_polyphonic, + uint32_t num_ports) = 0; + + virtual void new_port(std::string path, + std::string data_type, + bool is_output) = 0; + + virtual void patch_enabled(std::string path) = 0; + + virtual void patch_disabled(std::string path) = 0; + + virtual void patch_cleared(std::string path) = 0; + + virtual void object_renamed(std::string old_path, + std::string new_path) = 0; + + virtual void object_destroyed(std::string path) = 0; + + virtual void connection(std::string src_port_path, + std::string dst_port_path) = 0; + + virtual void disconnection(std::string src_port_path, + std::string dst_port_path) = 0; + + virtual void metadata_update(std::string subject_path, + std::string predicate, + Raul::Atom value) = 0; + + virtual void control_change(std::string port_path, + float value) = 0; + + virtual void program_add(std::string node_path, + uint32_t bank, + uint32_t program, + std::string program_name) = 0; + + virtual void program_remove(std::string node_path, + uint32_t bank, + uint32_t program) = 0; + +protected: + ClientInterface() {} +}; + + +} // namespace Shared +} // namespace Ingen + +#endif diff --git a/src/common/interface/ClientKey.h b/src/common/interface/ClientKey.h deleted file mode 100644 index b007a647..00000000 --- a/src/common/interface/ClientKey.h +++ /dev/null @@ -1,86 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * 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 CLIENTKEY_H -#define CLIENTKEY_H - -#include - -namespace Ingen { -namespace Shared { - - -/** Key for looking up clients. - * - * This might actually be a lookup key (as in OSC clients) or a direct handle - * of some kind (eg pointer) (for in-process or shared memory clients). - * - * This is shared code, nothing client or server code specific should be here. - */ -class ClientKey -{ -public: - /** A key to identify a particular ClientInterface. - * - * There are two different OSC key types because one is for server side, - * and one is for client side. A client can not identify it's own URL to - * the host (for NAT traversal, etc) so it can only know the outgoing UDP - * port it's sending on. The server however identifies that client by the - * full incoming URL. - */ - enum Type { - NIL, ///< A NULL key (represents no client) - OSC_URL, ///< An OSC URL (remote host/client) - OSC_PORT, ///< A local OSC port - DIRECT ///< A direct in-process function call client - }; - - ClientKey() - : _type(NIL), - _uri("") - {} - - ClientKey(Type type, const std::string& uri) - : _type(type) - , _uri(uri) - {} - - /*ClientKey(Type type, int port) - : _type(OSC_PORT) - , _port(port) - {}*/ - - inline bool - operator==(const ClientKey& key) const - { - return (_type == key._type && _uri == key._uri); - } - - inline Type type() const { return _type; } - inline const std::string& uri() const { return _uri; } - -protected: - Type _type; - const std::string _uri; ///< URL for OSC_URL, (string) port number for OSC_PORT -}; - - -} // namespace Shared -} // namespace Ingen - -#endif // CLIENTKEY_H - diff --git a/src/common/interface/ClientKey.hpp b/src/common/interface/ClientKey.hpp new file mode 100644 index 00000000..b007a647 --- /dev/null +++ b/src/common/interface/ClientKey.hpp @@ -0,0 +1,86 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * 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 CLIENTKEY_H +#define CLIENTKEY_H + +#include + +namespace Ingen { +namespace Shared { + + +/** Key for looking up clients. + * + * This might actually be a lookup key (as in OSC clients) or a direct handle + * of some kind (eg pointer) (for in-process or shared memory clients). + * + * This is shared code, nothing client or server code specific should be here. + */ +class ClientKey +{ +public: + /** A key to identify a particular ClientInterface. + * + * There are two different OSC key types because one is for server side, + * and one is for client side. A client can not identify it's own URL to + * the host (for NAT traversal, etc) so it can only know the outgoing UDP + * port it's sending on. The server however identifies that client by the + * full incoming URL. + */ + enum Type { + NIL, ///< A NULL key (represents no client) + OSC_URL, ///< An OSC URL (remote host/client) + OSC_PORT, ///< A local OSC port + DIRECT ///< A direct in-process function call client + }; + + ClientKey() + : _type(NIL), + _uri("") + {} + + ClientKey(Type type, const std::string& uri) + : _type(type) + , _uri(uri) + {} + + /*ClientKey(Type type, int port) + : _type(OSC_PORT) + , _port(port) + {}*/ + + inline bool + operator==(const ClientKey& key) const + { + return (_type == key._type && _uri == key._uri); + } + + inline Type type() const { return _type; } + inline const std::string& uri() const { return _uri; } + +protected: + Type _type; + const std::string _uri; ///< URL for OSC_URL, (string) port number for OSC_PORT +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // CLIENTKEY_H + diff --git a/src/common/interface/EngineInterface.h b/src/common/interface/EngineInterface.h deleted file mode 100644 index 1701a78e..00000000 --- a/src/common/interface/EngineInterface.h +++ /dev/null @@ -1,142 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * Ingen is free software = 0; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef ENGINEINTERFACE_H -#define ENGINEINTERFACE_H - -#include -#include -#include -#include "interface/ClientInterface.h" -using std::string; - -namespace Ingen { -/** Shared code used on both client side and engine side (abstract interfaces). */ -namespace Shared { - -class ClientKey; -class Responder; - - -/** The (only) interface clients use to communicate with the engine. - * - * Purely virtual (except for the destructor). - */ -class EngineInterface -{ -public: - virtual ~EngineInterface() {} - - // Responses - virtual void set_responder(SharedPtr responder) = 0; - virtual void set_next_response_id(int32_t id) = 0; - virtual void disable_responses() = 0; - - // Client registration - virtual void register_client(ClientKey key, SharedPtr client) = 0; - virtual void unregister_client(ClientKey key) = 0; - - - // Engine commands - virtual void load_plugins() = 0; - virtual void activate() = 0; - virtual void deactivate() = 0; - virtual void quit() = 0; - - // Object commands - - virtual void create_patch(const string& path, - uint32_t poly) = 0; - - virtual void create_port(const string& path, - const string& data_type, - bool direction) = 0; - - virtual void create_node(const string& path, - const string& plugin_uri, - bool polyphonic) = 0; - - /** DEPRECATED */ - virtual void create_node(const string& path, - const string& plugin_type, - const string& library_name, - const string& plugin_label, - bool polyphonic) = 0; - - virtual void rename(const string& old_path, - const string& new_name) = 0; - - virtual void destroy(const string& path) = 0; - - virtual void clear_patch(const string& patch_path) = 0; - - virtual void enable_patch(const string& patch_path) = 0; - - virtual void disable_patch(const string& patch_path) = 0; - - virtual void connect(const string& src_port_path, - const string& dst_port_path) = 0; - - virtual void disconnect(const string& src_port_path, - const string& dst_port_path) = 0; - - virtual void disconnect_all(const string& node_path) = 0; - - virtual void set_port_value(const string& port_path, - float val) = 0; - - virtual void set_port_value(const string& port_path, - uint32_t voice, - float val) = 0; - - virtual void set_port_value_queued(const string& port_path, - float val) = 0; - - virtual void set_program(const string& node_path, - uint32_t bank, - uint32_t program) = 0; - - virtual void midi_learn(const string& node_path) = 0; - - virtual void set_metadata(const string& path, - const string& predicate, - const Raul::Atom& value) = 0; - - // Requests // - - virtual void ping() = 0; - - virtual void request_plugin(const string& uri) = 0; - - virtual void request_object(const string& path) = 0; - - virtual void request_port_value(const string& port_path) = 0; - - virtual void request_plugins() = 0; - - virtual void request_all_objects() = 0; - -protected: - EngineInterface() {} -}; - - -} // namespace Shared -} // namespace Ingen - -#endif // ENGINEINTERFACE_H - diff --git a/src/common/interface/EngineInterface.hpp b/src/common/interface/EngineInterface.hpp new file mode 100644 index 00000000..af662f82 --- /dev/null +++ b/src/common/interface/EngineInterface.hpp @@ -0,0 +1,142 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software = 0; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef ENGINEINTERFACE_H +#define ENGINEINTERFACE_H + +#include +#include +#include +#include "interface/ClientInterface.hpp" +using std::string; + +namespace Ingen { +/** Shared code used on both client side and engine side (abstract interfaces). */ +namespace Shared { + +class ClientKey; +class Responder; + + +/** The (only) interface clients use to communicate with the engine. + * + * Purely virtual (except for the destructor). + */ +class EngineInterface +{ +public: + virtual ~EngineInterface() {} + + // Responses + virtual void set_responder(SharedPtr responder) = 0; + virtual void set_next_response_id(int32_t id) = 0; + virtual void disable_responses() = 0; + + // Client registration + virtual void register_client(ClientKey key, SharedPtr client) = 0; + virtual void unregister_client(ClientKey key) = 0; + + + // Engine commands + virtual void load_plugins() = 0; + virtual void activate() = 0; + virtual void deactivate() = 0; + virtual void quit() = 0; + + // Object commands + + virtual void create_patch(const string& path, + uint32_t poly) = 0; + + virtual void create_port(const string& path, + const string& data_type, + bool direction) = 0; + + virtual void create_node(const string& path, + const string& plugin_uri, + bool polyphonic) = 0; + + /** DEPRECATED */ + virtual void create_node(const string& path, + const string& plugin_type, + const string& library_name, + const string& plugin_label, + bool polyphonic) = 0; + + virtual void rename(const string& old_path, + const string& new_name) = 0; + + virtual void destroy(const string& path) = 0; + + virtual void clear_patch(const string& patch_path) = 0; + + virtual void enable_patch(const string& patch_path) = 0; + + virtual void disable_patch(const string& patch_path) = 0; + + virtual void connect(const string& src_port_path, + const string& dst_port_path) = 0; + + virtual void disconnect(const string& src_port_path, + const string& dst_port_path) = 0; + + virtual void disconnect_all(const string& node_path) = 0; + + virtual void set_port_value(const string& port_path, + float val) = 0; + + virtual void set_port_value(const string& port_path, + uint32_t voice, + float val) = 0; + + virtual void set_port_value_queued(const string& port_path, + float val) = 0; + + virtual void set_program(const string& node_path, + uint32_t bank, + uint32_t program) = 0; + + virtual void midi_learn(const string& node_path) = 0; + + virtual void set_metadata(const string& path, + const string& predicate, + const Raul::Atom& value) = 0; + + // Requests // + + virtual void ping() = 0; + + virtual void request_plugin(const string& uri) = 0; + + virtual void request_object(const string& path) = 0; + + virtual void request_port_value(const string& port_path) = 0; + + virtual void request_plugins() = 0; + + virtual void request_all_objects() = 0; + +protected: + EngineInterface() {} +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // ENGINEINTERFACE_H + diff --git a/src/common/interface/Makefile.am b/src/common/interface/Makefile.am index 347e8186..7a8f641d 100644 --- a/src/common/interface/Makefile.am +++ b/src/common/interface/Makefile.am @@ -1,6 +1,6 @@ EXTRA_DIST = \ README \ - ClientInterface.h \ - ClientKey.h \ - Responder.h \ - EngineInterface.h + ClientInterface.hpp \ + ClientKey.hpp \ + Responder.hpp \ + EngineInterface.hpp diff --git a/src/common/interface/Responder.h b/src/common/interface/Responder.h deleted file mode 100644 index 6e809e1a..00000000 --- a/src/common/interface/Responder.h +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007 Dave Robillard - * - * 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 RESPONDER_H -#define RESPONDER_H - -#include -#include -#include -#include "interface/ClientKey.h" -#include "interface/ClientInterface.h" -using std::string; - -namespace Ingen { -namespace Shared { - -using Shared::ClientKey; -using Shared::ClientInterface; - - -/** Class to handle responding to clients. - * - * This is an abstract base class to fully abstract the details of client - * communication from the internals of the engine. - * - * Note that this class only handles sending responses to commands from - * clients, (ie OK or an error), not notifications (ie new node, - * disconnection) - that's what ClientInterface is for. If a command is - * a request, the ClientKey of the Responder can be used to find the - * ClientInterface which should receive the response. - * - * ClientInterface and Responder are seperate because responding might not - * actually get exposed to the client interface (eg in simulated blocking - * interfaces that wait for responses before returning). - * - * Note for messages that have a "response" and some broadcasted effect - * (eg setting a port value) the "response" MUST be sent first since Responder - * is responsible for controlling whether the client wishes to receive the - * notification. - */ -class Responder -{ -public: - Responder() {} - virtual ~Responder() {} - - virtual ClientKey client_key() { return ClientKey(); } - virtual SharedPtr client() { return SharedPtr(); } - - virtual void set_id(int32_t id) {} - - virtual void respond_ok() {} - virtual void respond_error(const string& msg) {} -}; - - -} // namespace Shared -} // namespace Ingen - -#endif // RESPONDER_H - diff --git a/src/common/interface/Responder.hpp b/src/common/interface/Responder.hpp new file mode 100644 index 00000000..fc8cdcf7 --- /dev/null +++ b/src/common/interface/Responder.hpp @@ -0,0 +1,74 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * 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 RESPONDER_H +#define RESPONDER_H + +#include +#include +#include +#include "interface/ClientKey.hpp" +#include "interface/ClientInterface.hpp" + +namespace Ingen { +namespace Shared { + +using Shared::ClientKey; +using Shared::ClientInterface; + + +/** Class to handle responding to clients. + * + * This is an abstract base class to fully abstract the details of client + * communication from the internals of the engine. + * + * Note that this class only handles sending responses to commands from + * clients, (ie OK or an error), not notifications (ie new node, + * disconnection) - that's what ClientInterface is for. If a command is + * a request, the ClientKey of the Responder can be used to find the + * ClientInterface which should receive the response. + * + * ClientInterface and Responder are seperate because responding might not + * actually get exposed to the client interface (eg in simulated blocking + * interfaces that wait for responses before returning). + * + * Note for messages that have a "response" and some broadcasted effect + * (eg setting a port value) the "response" MUST be sent first since Responder + * is responsible for controlling whether the client wishes to receive the + * notification. + */ +class Responder +{ +public: + Responder() {} + virtual ~Responder() {} + + virtual ClientKey client_key() { return ClientKey(); } + virtual SharedPtr client() { return SharedPtr(); } + + virtual void set_id(int32_t id) {} + + virtual void respond_ok() {} + virtual void respond_error(const std::string& msg) {} +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // RESPONDER_H + -- cgit v1.2.1