From bac31a50f17608c514afce5ad014316cccde3d5a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 24 Jul 2007 21:23:22 +0000 Subject: Scrapped ClientKey in favour of a URI string (towards a simpler closer-to-straight-C engine interface). Fixed client deregistration. Added metadata value requesting. git-svn-id: http://svn.drobilla.net/lad/ingen@614 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/ClientKey.hpp | 86 ------------------ src/common/interface/EngineInterface.hpp | 7 +- src/common/interface/Makefile.am | 1 - src/common/interface/Responder.hpp | 13 +-- src/libs/client/OSCEngineSender.cpp | 15 ++- src/libs/client/OSCEngineSender.hpp | 7 +- src/libs/engine/ClientBroadcaster.cpp | 106 ++++++++-------------- src/libs/engine/ClientBroadcaster.hpp | 21 ++--- src/libs/engine/OSCEngineReceiver.cpp | 27 ++---- src/libs/engine/OSCEngineReceiver.hpp | 1 + src/libs/engine/OSCResponder.cpp | 3 +- src/libs/engine/OSCResponder.hpp | 4 +- src/libs/engine/QueuedEngineInterface.cpp | 14 +-- src/libs/engine/QueuedEngineInterface.hpp | 8 +- src/libs/engine/events/RegisterClientEvent.cpp | 17 ++-- src/libs/engine/events/RegisterClientEvent.hpp | 6 +- src/libs/engine/events/RequestAllObjectsEvent.cpp | 2 +- src/libs/engine/events/RequestMetadataEvent.cpp | 2 +- src/libs/engine/events/RequestObjectEvent.cpp | 2 +- src/libs/engine/events/RequestPluginEvent.cpp | 2 +- src/libs/engine/events/RequestPluginsEvent.cpp | 2 +- src/libs/engine/events/RequestPortValueEvent.cpp | 2 +- src/libs/engine/events/UnregisterClientEvent.cpp | 6 +- src/libs/engine/events/UnregisterClientEvent.hpp | 7 +- src/libs/gui/ConnectWindow.cpp | 3 +- 25 files changed, 121 insertions(+), 243 deletions(-) delete mode 100644 src/common/interface/ClientKey.hpp (limited to 'src') diff --git a/src/common/interface/ClientKey.hpp b/src/common/interface/ClientKey.hpp deleted file mode 100644 index b007a647..00000000 --- a/src/common/interface/ClientKey.hpp +++ /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/EngineInterface.hpp b/src/common/interface/EngineInterface.hpp index af662f82..f727b1be 100644 --- a/src/common/interface/EngineInterface.hpp +++ b/src/common/interface/EngineInterface.hpp @@ -28,7 +28,6 @@ namespace Ingen { /** Shared code used on both client side and engine side (abstract interfaces). */ namespace Shared { -class ClientKey; class Responder; @@ -47,8 +46,8 @@ public: virtual void disable_responses() = 0; // Client registration - virtual void register_client(ClientKey key, SharedPtr client) = 0; - virtual void unregister_client(ClientKey key) = 0; + virtual void register_client(const string& uri, SharedPtr client) = 0; + virtual void unregister_client(const string& uri) = 0; // Engine commands @@ -125,6 +124,8 @@ public: virtual void request_object(const string& path) = 0; virtual void request_port_value(const string& port_path) = 0; + + virtual void request_metadata(const string& path, const string& key) = 0; virtual void request_plugins() = 0; diff --git a/src/common/interface/Makefile.am b/src/common/interface/Makefile.am index 7a8f641d..7b9f1f53 100644 --- a/src/common/interface/Makefile.am +++ b/src/common/interface/Makefile.am @@ -1,6 +1,5 @@ EXTRA_DIST = \ README \ ClientInterface.hpp \ - ClientKey.hpp \ Responder.hpp \ EngineInterface.hpp diff --git a/src/common/interface/Responder.hpp b/src/common/interface/Responder.hpp index fc8cdcf7..0ae0972a 100644 --- a/src/common/interface/Responder.hpp +++ b/src/common/interface/Responder.hpp @@ -21,15 +21,11 @@ #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. * @@ -39,8 +35,8 @@ using Shared::ClientInterface; * 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. + * a request, the Responder can be used to find the ClientInterface + * (by URI) 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 @@ -57,8 +53,9 @@ public: Responder() {} virtual ~Responder() {} - virtual ClientKey client_key() { return ClientKey(); } - virtual SharedPtr client() { return SharedPtr(); } + virtual std::string client_uri() { return ""; } + + virtual SharedPtr client() { return SharedPtr(); } virtual void set_id(int32_t id) {} diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp index 2e49eac3..988f2c5e 100644 --- a/src/libs/client/OSCEngineSender.cpp +++ b/src/libs/client/OSCEngineSender.cpp @@ -17,7 +17,6 @@ #include #include "OSCEngineSender.hpp" -#include "interface/ClientKey.hpp" #include using std::cout; using std::cerr; using std::endl; @@ -108,7 +107,7 @@ OSCEngineSender::attach(int32_t ping_id, bool block) * traversal. It is a parameter to remain compatible with EngineInterface. */ void -OSCEngineSender::register_client(ClientKey key, SharedPtr client) +OSCEngineSender::register_client(const string& uri, SharedPtr client) { // FIXME: use parameters.. er, somehow. assert(_engine_addr); @@ -117,7 +116,7 @@ OSCEngineSender::register_client(ClientKey key, SharedPtr clien void -OSCEngineSender::unregister_client(ClientKey key) +OSCEngineSender::unregister_client(const string& uri) { assert(_engine_addr); lo_send(_engine_addr, "/ingen/unregister_client", "i", next_id()); @@ -426,6 +425,16 @@ OSCEngineSender::request_port_value(const string& port_path) port_path.c_str()); } +void +OSCEngineSender::request_metadata(const string& object_path, const string& key) +{ + assert(_engine_addr); + lo_send(_engine_addr, "/ingen/request_metadata", "iss", + next_id(), + object_path.c_str(), + key.c_str()); +} + void OSCEngineSender::request_plugins() diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp index c9b37ec8..ea804d59 100644 --- a/src/libs/client/OSCEngineSender.hpp +++ b/src/libs/client/OSCEngineSender.hpp @@ -26,7 +26,6 @@ using std::string; using Ingen::Shared::EngineInterface; using Ingen::Shared::ClientInterface; -using Ingen::Shared::ClientKey; using Ingen::Shared::Responder; namespace Ingen { @@ -62,8 +61,8 @@ public: /* *** EngineInterface implementation below here *** */ // Client registration - void register_client(ClientKey key, SharedPtr client); - void unregister_client(ClientKey key); + void register_client(const string& uri, SharedPtr client); + void unregister_client(const string& uri); // Engine commands @@ -140,6 +139,8 @@ public: void request_object(const string& path); void request_port_value(const string& port_path); + + void request_metadata(const string& path, const string& key); void request_plugins(); diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 311e8792..8547543a 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -18,7 +18,6 @@ #include #include #include -#include "interface/ClientKey.hpp" #include "interface/ClientInterface.hpp" #include "ClientBroadcaster.hpp" #include "ObjectStore.hpp" @@ -42,59 +41,34 @@ namespace Ingen { /** Register a client to receive messages over the notification band. */ void -ClientBroadcaster::register_client(const ClientKey key, SharedPtr client) +ClientBroadcaster::register_client(const string& uri, SharedPtr client) { - bool found = false; - for (ClientList::iterator i = _clients.begin(); i != _clients.end(); ++i) - if ((*i).first == key) - found = true; - - if (!found) { - _clients.push_back(pair >(key, client)); - cout << "[ClientBroadcaster] Registered client " << key.uri() - << " (" << _clients.size() << " clients)" << endl; + ClientMap::iterator i = _clients.find(uri); + + if (i == _clients.end()) { + _clients[uri] = client; + cout << "[ClientBroadcaster] Registered client: " << uri << endl; } else { - cout << "[ClientBroadcaster] Client already registered." << endl; + cout << "[ClientBroadcaster] Client already registered: " << uri << endl; } } /** Remove a client from the list of registered clients. * - * The removed client is returned (not deleted). It is the caller's - * responsibility to delete the returned pointer, if it's not NULL. - * - * @return true if client was found and removed (and refcount decremented). + * @return true if client was found and removed. */ bool -ClientBroadcaster::unregister_client(const ClientKey& key) +ClientBroadcaster::unregister_client(const string& uri) { - cerr << "FIXME: unregister broken\n"; - return false; - -#if 0 - if (responder == NULL) - return NULL; - - // FIXME: remove filthy cast - const string url = lo_address_get_url(((OSCResponder*)responder)->source()); - ClientInterface* r = NULL; - - for (ClientList::iterator i = _clients.begin(); i != _clients.end(); ++i) { - if ((*i).second->url() == url) { - r = *i; - _clients.erase(i); - break; - } - } + size_t erased = _clients.erase(uri); - if (r != NULL) - cout << "[OSC] Unregistered client " << r->url() << " (" << _clients.size() << " clients)" << endl; + if (erased > 0) + cout << "Unregistered client: " << uri << endl; else - cerr << "[OSC] ERROR: Unable to find client to unregister!" << endl; - - return r; -#endif + cout << "Failed to find client to unregister: " << uri << endl; + + return (erased > 0); } @@ -106,22 +80,22 @@ ClientBroadcaster::unregister_client(const ClientKey& key) * events, in anticipation of libom and multiple ways of responding to clients). */ SharedPtr -ClientBroadcaster::client(const ClientKey& key) +ClientBroadcaster::client(const string& uri) { - for (ClientList::iterator i = _clients.begin(); i != _clients.end(); ++i) - if ((*i).first == key) - return (*i).second; - - cerr << "[ClientBroadcaster] Failed to find client " << key.uri() << endl; - - return SharedPtr(); + ClientMap::iterator i = _clients.find(uri); + if (i != _clients.end()) { + return (*i).second; + } else { + cerr << "[ClientBroadcaster] Failed to find client: " << uri << endl; + return SharedPtr(); + } } void ClientBroadcaster::send_error(const string& msg) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->error(msg); } @@ -187,7 +161,7 @@ ClientBroadcaster::send_plugins_to(SharedPtr client, const list void ClientBroadcaster::send_plugins(const list& plugin_list) { - for (ClientList::const_iterator c = _clients.begin(); c != _clients.end(); ++c) + for (ClientMap::const_iterator c = _clients.begin(); c != _clients.end(); ++c) send_plugins_to((*c).second, plugin_list); } @@ -195,7 +169,7 @@ ClientBroadcaster::send_plugins(const list& plugin_list) void ClientBroadcaster::send_node(const Node* node, bool recursive) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) ObjectSender::send_node((*i).second.get(), node, recursive); } @@ -203,7 +177,7 @@ ClientBroadcaster::send_node(const Node* node, bool recursive) void ClientBroadcaster::send_port(const Port* port) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) ObjectSender::send_port((*i).second.get(), port); } @@ -212,21 +186,21 @@ void ClientBroadcaster::send_destroyed(const string& path) { assert(path != "/"); - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->object_destroyed(path); } void ClientBroadcaster::send_patch_cleared(const string& patch_path) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_cleared(patch_path); } void ClientBroadcaster::send_connection(const Connection* const c) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->connection(c->src_port()->path(), c->dst_port()->path()); } @@ -234,7 +208,7 @@ ClientBroadcaster::send_connection(const Connection* const c) void ClientBroadcaster::send_disconnection(const string& src_port_path, const string& dst_port_path) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->disconnection(src_port_path, dst_port_path); } @@ -242,7 +216,7 @@ ClientBroadcaster::send_disconnection(const string& src_port_path, const string& void ClientBroadcaster::send_patch_enable(const string& patch_path) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_enabled(patch_path); } @@ -250,7 +224,7 @@ ClientBroadcaster::send_patch_enable(const string& patch_path) void ClientBroadcaster::send_patch_disable(const string& patch_path) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_disabled(patch_path); } @@ -262,7 +236,7 @@ ClientBroadcaster::send_patch_disable(const string& patch_path) void ClientBroadcaster::send_metadata_update(const string& node_path, const string& key, const Atom& value) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->metadata_update(node_path, key, value); } @@ -276,7 +250,7 @@ ClientBroadcaster::send_metadata_update(const string& node_path, const string& k void ClientBroadcaster::send_control_change(const string& port_path, float value) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->control_change(port_path, value); } @@ -284,7 +258,7 @@ ClientBroadcaster::send_control_change(const string& port_path, float value) void ClientBroadcaster::send_program_add(const string& node_path, int bank, int program, const string& name) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->program_add(node_path, bank, program, name); } @@ -292,7 +266,7 @@ ClientBroadcaster::send_program_add(const string& node_path, int bank, int progr void ClientBroadcaster::send_program_remove(const string& node_path, int bank, int program) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->program_remove(node_path, bank, program); } @@ -304,7 +278,7 @@ ClientBroadcaster::send_program_remove(const string& node_path, int bank, int pr void ClientBroadcaster::send_patch(const Patch* const p, bool recursive) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) ObjectSender::send_patch((*i).second.get(), p, recursive); } @@ -314,7 +288,7 @@ ClientBroadcaster::send_patch(const Patch* const p, bool recursive) void ClientBroadcaster::send_rename(const string& old_path, const string& new_path) { - for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->object_renamed(old_path, new_path); } @@ -326,7 +300,7 @@ ClientBroadcaster::send_all_objects() { cerr << "FIXME: send_all" << endl; - //for (ClientList::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + //for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) // (*i).second->send_all_objects(); } diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp index 87e321bb..3103c4d9 100644 --- a/src/libs/engine/ClientBroadcaster.hpp +++ b/src/libs/engine/ClientBroadcaster.hpp @@ -19,16 +19,17 @@ #define CLIENTBROADCASTER_H #include -#include -#include #include +#include #include #include #include #include "interface/ClientInterface.hpp" #include "types.hpp" -using std::list; using std::string; using std::pair; +using std::map; +using std::string; +using std::list; namespace Ingen { @@ -37,8 +38,7 @@ class Port; class Plugin; class Patch; class Connection; -namespace Shared { class ClientKey; class Responder; } -using Shared::ClientKey; +namespace Shared { class Responder; } using Shared::ClientInterface; @@ -55,10 +55,10 @@ using Shared::ClientInterface; class ClientBroadcaster { public: - void register_client(const ClientKey key, SharedPtr client); - bool unregister_client(const ClientKey& key); + void register_client(const string& uri, SharedPtr client); + bool unregister_client(const string& uri); - SharedPtr client(const ClientKey& key); + SharedPtr client(const string& uri); // Notification band: @@ -91,9 +91,8 @@ public: void send_plugins_to(SharedPtr, const list& plugin_list); private: - typedef list > > ClientList; - //list > _clients; - ClientList _clients; + typedef std::map > ClientMap; + ClientMap _clients; }; diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index d3d1b666..011f950c 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -22,7 +22,6 @@ #include "types.hpp" #include #include -#include "interface/ClientKey.hpp" #include "interface/ClientInterface.hpp" #include "OSCEngineReceiver.hpp" #include "QueuedEventSource.hpp" @@ -34,8 +33,6 @@ using std::cerr; using std::cout; using std::endl; namespace Ingen { -using Shared::ClientKey; - /*! \page engine_osc_namespace Engine OSC Namespace Documentation * @@ -255,8 +252,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, // Don't respond } else { me->disable_responses(); - SharedPtr client = me->_engine.broadcaster()->client( - ClientKey(ClientKey::OSC_URL, (const char*)url)); + SharedPtr client = me->_engine.broadcaster()->client(url); if (client) client->disable(); else @@ -334,7 +330,7 @@ OSCEngineReceiver::_register_client_cb(const char* path, const char* types, lo_a char* const url = lo_address_get_url(addr); SharedPtr client(new OSCClientSender((const char*)url)); - register_client(ClientKey(ClientKey::OSC_URL, (const char*)url), client); + register_client(url, client); free(url); return 0; @@ -351,7 +347,7 @@ OSCEngineReceiver::_unregister_client_cb(const char* path, const char* types, lo lo_address addr = lo_message_get_source(msg); char* url = lo_address_get_url(addr); - unregister_client(ClientKey(ClientKey::OSC_URL, url)); + unregister_client(url); free(url); return 0; @@ -757,12 +753,12 @@ OSCEngineReceiver::_metadata_set_cb(const char* path, const char* types, lo_arg* if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's') return 1; - const char* node_path = &argv[1]->s; + const char* object_path = &argv[1]->s; const char* key = &argv[2]->s; Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]); - set_metadata(node_path, key, value); + set_metadata(object_path, key, value); return 0; } @@ -779,18 +775,11 @@ OSCEngineReceiver::_metadata_set_cb(const char* path, const char* types, lo_arg* int OSCEngineReceiver::_metadata_get_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - /* - const char* node_path = &argv[1]->s; + const char* object_path = &argv[1]->s; const char* key = &argv[2]->s; - */ - cerr << "FIXME: OSC metadata request\n"; - // FIXME: Equivalent? - /* - RequestMetadataEvent* ev = new RequestMetadataEvent( - new OSCResponder(ClientKey(addr)), - node_path, key); - */ + request_metadata(object_path, key); + return 0; } diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp index 40a3801b..478af249 100644 --- a/src/libs/engine/OSCEngineReceiver.hpp +++ b/src/libs/engine/OSCEngineReceiver.hpp @@ -108,6 +108,7 @@ private: LO_HANDLER(request_plugin); LO_HANDLER(request_object); LO_HANDLER(request_port_value); + LO_HANDLER(request_metadata); LO_HANDLER(request_plugins); LO_HANDLER(request_all_objects); diff --git a/src/libs/engine/OSCResponder.cpp b/src/libs/engine/OSCResponder.cpp index 71104be4..a966a2d3 100644 --- a/src/libs/engine/OSCResponder.cpp +++ b/src/libs/engine/OSCResponder.cpp @@ -17,7 +17,6 @@ #include "OSCResponder.hpp" #include "ClientBroadcaster.hpp" -#include "interface/ClientKey.hpp" #include #include #include @@ -90,7 +89,7 @@ SharedPtr OSCResponder::client() { if (_broadcaster) - return _broadcaster->client(client_key()); + return _broadcaster->client(client_uri()); else return SharedPtr(); } diff --git a/src/libs/engine/OSCResponder.hpp b/src/libs/engine/OSCResponder.hpp index a7b0968d..b536c169 100644 --- a/src/libs/engine/OSCResponder.hpp +++ b/src/libs/engine/OSCResponder.hpp @@ -19,6 +19,7 @@ #define OSCRESPONDER_H #include +#include #include #include #include "interface/Responder.hpp" @@ -51,8 +52,7 @@ public: const char* url() const { return _url; } - Shared::ClientKey client_key() - { return Shared::ClientKey(Shared::ClientKey::OSC_URL, _url); } + std::string client_uri() { return _url; } SharedPtr client(); diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 2abb5a1c..f54f850a 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -25,9 +25,9 @@ namespace Ingen { QueuedEngineInterface::QueuedEngineInterface(Engine& engine, size_t queued_size, size_t stamped_size) -: QueuedEventSource(queued_size, stamped_size) -, _responder(SharedPtr(new Shared::Responder())) // NULL responder -, _engine(engine) + : QueuedEventSource(queued_size, stamped_size) + , _responder(SharedPtr(new Shared::Responder())) // NULL responder + , _engine(engine) { } @@ -74,16 +74,16 @@ QueuedEngineInterface::disable_responses() void -QueuedEngineInterface::register_client(ClientKey key, SharedPtr client) +QueuedEngineInterface::register_client(const string& uri, SharedPtr client) { - push_queued(new RegisterClientEvent(_engine, _responder, now(), key, client)); + push_queued(new RegisterClientEvent(_engine, _responder, now(), uri, client)); } void -QueuedEngineInterface::unregister_client(ClientKey key) +QueuedEngineInterface::unregister_client(const string& uri) { - push_queued(new UnregisterClientEvent(_engine, _responder, now(), key)); + push_queued(new UnregisterClientEvent(_engine, _responder, now(), uri)); } diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp index 204338bf..889b8f8e 100644 --- a/src/libs/engine/QueuedEngineInterface.hpp +++ b/src/libs/engine/QueuedEngineInterface.hpp @@ -24,7 +24,6 @@ #include #include "interface/EngineInterface.hpp" #include "interface/ClientInterface.hpp" -#include "interface/ClientKey.hpp" #include "interface/Responder.hpp" #include "QueuedEventSource.hpp" #include "Engine.hpp" @@ -32,7 +31,6 @@ using std::string; namespace Ingen { -using Shared::ClientKey; using Shared::ClientInterface; using Shared::EngineInterface; class Engine; @@ -70,8 +68,8 @@ public: virtual void disable_responses(); // Client registration - virtual void register_client(ClientKey key, SharedPtr client); - virtual void unregister_client(ClientKey key); + virtual void register_client(const string& uri, SharedPtr client); + virtual void unregister_client(const string& uri); // Engine commands @@ -148,6 +146,8 @@ public: virtual void request_object(const string& path); virtual void request_port_value(const string& port_path); + + virtual void request_metadata(const string& path, const string& key); virtual void request_plugins(); diff --git a/src/libs/engine/events/RegisterClientEvent.cpp b/src/libs/engine/events/RegisterClientEvent.cpp index ace2b3e0..ac2dbbc3 100644 --- a/src/libs/engine/events/RegisterClientEvent.cpp +++ b/src/libs/engine/events/RegisterClientEvent.cpp @@ -23,13 +23,14 @@ namespace Ingen { -RegisterClientEvent::RegisterClientEvent(Engine& engine, SharedPtr responder, - SampleCount timestamp, - ClientKey key, - SharedPtr client) -: QueuedEvent(engine, responder, timestamp) -, _key(key) -, _client(client) +RegisterClientEvent::RegisterClientEvent(Engine& engine, + SharedPtr responder, + SampleCount timestamp, + const string& uri, + SharedPtr client) + : QueuedEvent(engine, responder, timestamp) + , _uri(uri) + , _client(client) { } @@ -37,7 +38,7 @@ RegisterClientEvent::RegisterClientEvent(Engine& engine, SharedPtrregister_client(_key, _client); + _engine.broadcaster()->register_client(_uri, _client); QueuedEvent::pre_process(); } diff --git a/src/libs/engine/events/RegisterClientEvent.hpp b/src/libs/engine/events/RegisterClientEvent.hpp index be02fd41..90528956 100644 --- a/src/libs/engine/events/RegisterClientEvent.hpp +++ b/src/libs/engine/events/RegisterClientEvent.hpp @@ -19,12 +19,10 @@ #define REGISTERCLIENTEVENT_H #include "QueuedEvent.hpp" -#include "interface/ClientKey.hpp" #include "interface/ClientInterface.hpp" #include using std::string; using Ingen::Shared::ClientInterface; -using Ingen::Shared::ClientKey; using Ingen::Shared::Responder; namespace Ingen { @@ -40,14 +38,14 @@ public: RegisterClientEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, - ClientKey key, + const string& uri, SharedPtr client); void pre_process(); void post_process(); private: - ClientKey _key; + string _uri; SharedPtr _client; }; diff --git a/src/libs/engine/events/RequestAllObjectsEvent.cpp b/src/libs/engine/events/RequestAllObjectsEvent.cpp index a6940442..4b068536 100644 --- a/src/libs/engine/events/RequestAllObjectsEvent.cpp +++ b/src/libs/engine/events/RequestAllObjectsEvent.cpp @@ -34,7 +34,7 @@ RequestAllObjectsEvent::RequestAllObjectsEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); QueuedEvent::pre_process(); } diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp index 5000256f..b9696c4a 100644 --- a/src/libs/engine/events/RequestMetadataEvent.cpp +++ b/src/libs/engine/events/RequestMetadataEvent.cpp @@ -41,7 +41,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); if (_client) { _object = _engine.object_store()->find(_path); diff --git a/src/libs/engine/events/RequestObjectEvent.cpp b/src/libs/engine/events/RequestObjectEvent.cpp index 25f95d00..8efe37b7 100644 --- a/src/libs/engine/events/RequestObjectEvent.cpp +++ b/src/libs/engine/events/RequestObjectEvent.cpp @@ -43,7 +43,7 @@ RequestObjectEvent::RequestObjectEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); _object = _engine.object_store()->find(_path); QueuedEvent::pre_process(); diff --git a/src/libs/engine/events/RequestPluginEvent.cpp b/src/libs/engine/events/RequestPluginEvent.cpp index 4e1a1660..981c98e7 100644 --- a/src/libs/engine/events/RequestPluginEvent.cpp +++ b/src/libs/engine/events/RequestPluginEvent.cpp @@ -42,7 +42,7 @@ RequestPluginEvent::RequestPluginEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); _plugin = _engine.node_factory()->plugin(_uri); QueuedEvent::pre_process(); diff --git a/src/libs/engine/events/RequestPluginsEvent.cpp b/src/libs/engine/events/RequestPluginsEvent.cpp index 3976dd08..50271b7f 100644 --- a/src/libs/engine/events/RequestPluginsEvent.cpp +++ b/src/libs/engine/events/RequestPluginsEvent.cpp @@ -33,7 +33,7 @@ RequestPluginsEvent::RequestPluginsEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); // Take a copy to send in the post processing thread (to avoid problems // because std::list isn't thread safe) diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp index 7444068e..113369b3 100644 --- a/src/libs/engine/events/RequestPortValueEvent.cpp +++ b/src/libs/engine/events/RequestPortValueEvent.cpp @@ -42,7 +42,7 @@ RequestPortValueEvent::RequestPortValueEvent(Engine& engine, SharedPtrclient(_responder->client_key()); + _client = _engine.broadcaster()->client(_responder->client_uri()); _port = _engine.object_store()->find_port(_port_path); QueuedEvent::pre_process(); diff --git a/src/libs/engine/events/UnregisterClientEvent.cpp b/src/libs/engine/events/UnregisterClientEvent.cpp index be03f151..11424003 100644 --- a/src/libs/engine/events/UnregisterClientEvent.cpp +++ b/src/libs/engine/events/UnregisterClientEvent.cpp @@ -24,9 +24,9 @@ namespace Ingen { -UnregisterClientEvent::UnregisterClientEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, ClientKey key) +UnregisterClientEvent::UnregisterClientEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, const string& uri) : QueuedEvent(engine, responder, timestamp) -, _key(key) +, _uri(uri) { } @@ -34,7 +34,7 @@ UnregisterClientEvent::UnregisterClientEvent(Engine& engine, SharedPtrunregister_client(_key)) + if (_engine.broadcaster()->unregister_client(_uri)) _responder->respond_ok(); else _responder->respond_error("Unable to unregister client"); diff --git a/src/libs/engine/events/UnregisterClientEvent.hpp b/src/libs/engine/events/UnregisterClientEvent.hpp index 17d85b93..500c1250 100644 --- a/src/libs/engine/events/UnregisterClientEvent.hpp +++ b/src/libs/engine/events/UnregisterClientEvent.hpp @@ -19,7 +19,6 @@ #define UNREGISTERCLIENTEVENT_H #include "QueuedEvent.hpp" -#include "interface/ClientKey.hpp" #include using std::string; @@ -27,10 +26,8 @@ namespace Ingen { namespace Shared { class ClientInterface; - class ClientKey; } using Shared::ClientInterface; -using Shared::ClientKey; /** Unregisters an OSC client so it no longer receives notifications. @@ -43,12 +40,12 @@ public: UnregisterClientEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, - ClientKey key); + const string& uri); void post_process(); private: - ClientKey _key; + string _uri; }; diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp index f643b059..86660d40 100644 --- a/src/libs/gui/ConnectWindow.cpp +++ b/src/libs/gui/ConnectWindow.cpp @@ -23,7 +23,6 @@ #include #include #include "../../../../config/config.h" -#include "interface/ClientKey.hpp" #include "interface/EngineInterface.hpp" #include "engine/tuning.hpp" #include "engine/Engine.hpp" @@ -372,7 +371,7 @@ ConnectWindow::gtk_callback() //App::instance().engine()->register_client(App::instance().engine()->client_hooks()); // FIXME //auto_ptr client(new ThreadedSigClientInterface(); - App::instance().engine()->register_client(ClientKey(), App::instance().client()); + App::instance().engine()->register_client("FIXME_CLIENT_URI", App::instance().client()); App::instance().engine()->load_plugins(); ++_connect_stage; } else if (_connect_stage == 3) { -- cgit v1.2.1