From 9cd4eddfb41c4573d4acd4f625572c4cdff50497 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 1 Aug 2007 03:20:35 +0000 Subject: More SWIGification. Engine->Client calls/messages implemented... and segfault somewhere in Python :/ . git-svn-id: http://svn.drobilla.net/lad/ingen@664 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/ClientBroadcaster.cpp | 52 +++++++++++------------ src/libs/engine/ClientBroadcaster.hpp | 11 +++-- src/libs/engine/DirectResponder.hpp | 8 ++-- src/libs/engine/OSCClientSender.hpp | 2 + src/libs/engine/OSCEngineReceiver.cpp | 4 +- src/libs/engine/OSCResponder.cpp | 8 ++-- src/libs/engine/OSCResponder.hpp | 2 +- src/libs/engine/QueuedEngineInterface.cpp | 2 +- src/libs/engine/QueuedEngineInterface.hpp | 2 +- src/libs/engine/events/RegisterClientEvent.cpp | 2 +- src/libs/engine/events/RegisterClientEvent.hpp | 6 +-- src/libs/engine/events/RequestAllObjectsEvent.cpp | 2 +- src/libs/engine/events/RequestAllObjectsEvent.hpp | 2 +- src/libs/engine/events/RequestMetadataEvent.cpp | 2 +- src/libs/engine/events/RequestMetadataEvent.hpp | 10 ++--- src/libs/engine/events/RequestObjectEvent.cpp | 6 +-- src/libs/engine/events/RequestObjectEvent.hpp | 6 +-- src/libs/engine/events/RequestPluginEvent.hpp | 6 +-- src/libs/engine/events/RequestPluginsEvent.hpp | 4 +- src/libs/engine/events/RequestPortValueEvent.hpp | 8 ++-- 20 files changed, 73 insertions(+), 72 deletions(-) (limited to 'src/libs/engine') diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 8547543a..5023b2e0 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -41,9 +41,9 @@ namespace Ingen { /** Register a client to receive messages over the notification band. */ void -ClientBroadcaster::register_client(const string& uri, SharedPtr client) +ClientBroadcaster::register_client(const string& uri, ClientInterface* client) { - ClientMap::iterator i = _clients.find(uri); + Clients::iterator i = _clients.find(uri); if (i == _clients.end()) { _clients[uri] = client; @@ -79,15 +79,15 @@ ClientBroadcaster::unregister_client(const string& uri) * (A responder is passed to remove the dependency on liblo addresses in request * events, in anticipation of libom and multiple ways of responding to clients). */ -SharedPtr +ClientInterface* ClientBroadcaster::client(const string& uri) { - ClientMap::iterator i = _clients.find(uri); + Clients::iterator i = _clients.find(uri); if (i != _clients.end()) { return (*i).second; } else { cerr << "[ClientBroadcaster] Failed to find client: " << uri << endl; - return SharedPtr(); + return NULL; } } @@ -95,12 +95,12 @@ ClientBroadcaster::client(const string& uri) void ClientBroadcaster::send_error(const string& msg) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->error(msg); } void -ClientBroadcaster::send_plugins_to(SharedPtr client, const list& plugin_list) +ClientBroadcaster::send_plugins_to(ClientInterface* client, const list& plugin_list) { #if 0 // FIXME: This probably isn't actually thread safe @@ -161,7 +161,7 @@ ClientBroadcaster::send_plugins_to(SharedPtr client, const list void ClientBroadcaster::send_plugins(const list& plugin_list) { - for (ClientMap::const_iterator c = _clients.begin(); c != _clients.end(); ++c) + for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c) send_plugins_to((*c).second, plugin_list); } @@ -169,16 +169,16 @@ ClientBroadcaster::send_plugins(const list& plugin_list) void ClientBroadcaster::send_node(const Node* node, bool recursive) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - ObjectSender::send_node((*i).second.get(), node, recursive); + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + ObjectSender::send_node((*i).second, node, recursive); } void ClientBroadcaster::send_port(const Port* port) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - ObjectSender::send_port((*i).second.get(), port); + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + ObjectSender::send_port((*i).second, port); } @@ -186,21 +186,21 @@ void ClientBroadcaster::send_destroyed(const string& path) { assert(path != "/"); - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->object_destroyed(path); } void ClientBroadcaster::send_patch_cleared(const string& patch_path) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_cleared(patch_path); } void ClientBroadcaster::send_connection(const Connection* const c) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->connection(c->src_port()->path(), c->dst_port()->path()); } @@ -208,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->disconnection(src_port_path, dst_port_path); } @@ -216,7 +216,7 @@ ClientBroadcaster::send_disconnection(const string& src_port_path, const string& void ClientBroadcaster::send_patch_enable(const string& patch_path) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_enabled(patch_path); } @@ -224,7 +224,7 @@ ClientBroadcaster::send_patch_enable(const string& patch_path) void ClientBroadcaster::send_patch_disable(const string& patch_path) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->patch_disabled(patch_path); } @@ -236,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->metadata_update(node_path, key, value); } @@ -250,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->control_change(port_path, value); } @@ -258,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->program_add(node_path, bank, program, name); } @@ -266,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->program_remove(node_path, bank, program); } @@ -278,8 +278,8 @@ ClientBroadcaster::send_program_remove(const string& node_path, int bank, int pr void ClientBroadcaster::send_patch(const Patch* const p, bool recursive) { - for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) - ObjectSender::send_patch((*i).second.get(), p, recursive); + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + ObjectSender::send_patch((*i).second, p, recursive); } @@ -288,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 (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) (*i).second->object_renamed(old_path, new_path); } @@ -300,7 +300,7 @@ ClientBroadcaster::send_all_objects() { cerr << "FIXME: send_all" << endl; - //for (ClientMap::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + //for (Clients::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 3103c4d9..034476f5 100644 --- a/src/libs/engine/ClientBroadcaster.hpp +++ b/src/libs/engine/ClientBroadcaster.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "interface/ClientInterface.hpp" #include "types.hpp" @@ -55,10 +54,10 @@ using Shared::ClientInterface; class ClientBroadcaster { public: - void register_client(const string& uri, SharedPtr client); + void register_client(const string& uri, ClientInterface* client); bool unregister_client(const string& uri); - SharedPtr client(const string& uri); + ClientInterface* client(const string& uri); // Notification band: @@ -88,11 +87,11 @@ public: void send_program_add(const string& node_path, int bank, int program, const string& name); void send_program_remove(const string& node_path, int bank, int program); - void send_plugins_to(SharedPtr, const list& plugin_list); + void send_plugins_to(ClientInterface*, const list& plugin_list); private: - typedef std::map > ClientMap; - ClientMap _clients; + typedef std::map Clients; + Clients _clients; }; diff --git a/src/libs/engine/DirectResponder.hpp b/src/libs/engine/DirectResponder.hpp index 739cd017..7bd35dcd 100644 --- a/src/libs/engine/DirectResponder.hpp +++ b/src/libs/engine/DirectResponder.hpp @@ -30,7 +30,7 @@ namespace Ingen { class DirectResponder : public Shared::Responder { public: - DirectResponder(SharedPtr client, int32_t id) + DirectResponder(Shared::ClientInterface* client, int32_t id) : _client(client), _id(id) {} @@ -39,11 +39,11 @@ public: void respond_ok() { _client->response(_id, true, ""); } void respond_error(const string& msg) { _client->response(_id, false, msg); } - SharedPtr client() { return _client; } + Shared::ClientInterface* client() { return _client; } private: - SharedPtr _client; - int32_t _id; + Shared::ClientInterface* _client; + int32_t _id; }; diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp index 769bb0b9..6cf8abbe 100644 --- a/src/libs/engine/OSCClientSender.hpp +++ b/src/libs/engine/OSCClientSender.hpp @@ -53,6 +53,8 @@ public: const string& url() const { return _url; } const lo_address address() const { return _address; } + void subscribe(Shared::EngineInterface* engine) { } + //void plugins(); // FIXME remove diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index 011f950c..a2b98017 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -252,7 +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(url); + ClientInterface* client = me->_engine.broadcaster()->client(url); if (client) client->disable(); else @@ -329,7 +329,7 @@ OSCEngineReceiver::_register_client_cb(const char* path, const char* types, lo_a lo_address addr = lo_message_get_source(msg); char* const url = lo_address_get_url(addr); - SharedPtr client(new OSCClientSender((const char*)url)); + ClientInterface* client = new OSCClientSender((const char*)url); register_client(url, client); free(url); diff --git a/src/libs/engine/OSCResponder.cpp b/src/libs/engine/OSCResponder.cpp index a966a2d3..e43ba49a 100644 --- a/src/libs/engine/OSCResponder.cpp +++ b/src/libs/engine/OSCResponder.cpp @@ -54,7 +54,7 @@ OSCResponder::~OSCResponder() void OSCResponder::respond_ok() { - SharedPtr client = this->client(); + ClientInterface* client = this->client(); if (client) client->enable(); @@ -71,7 +71,7 @@ OSCResponder::respond_ok() void OSCResponder::respond_error(const string& msg) { - SharedPtr client = this->client(); + ClientInterface* client = this->client(); if (client) client->enable(); @@ -85,13 +85,13 @@ OSCResponder::respond_error(const string& msg) } -SharedPtr +ClientInterface* OSCResponder::client() { if (_broadcaster) return _broadcaster->client(client_uri()); else - return SharedPtr(); + return NULL; } } // namespace OM diff --git a/src/libs/engine/OSCResponder.hpp b/src/libs/engine/OSCResponder.hpp index b536c169..e4049160 100644 --- a/src/libs/engine/OSCResponder.hpp +++ b/src/libs/engine/OSCResponder.hpp @@ -54,7 +54,7 @@ public: std::string client_uri() { return _url; } - SharedPtr client(); + Shared::ClientInterface* client(); private: ClientBroadcaster* _broadcaster; diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 6055d8bd..a27a55f5 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -74,7 +74,7 @@ QueuedEngineInterface::disable_responses() void -QueuedEngineInterface::register_client(const string& uri, SharedPtr client) +QueuedEngineInterface::register_client(const string& uri, ClientInterface* client) { push_queued(new RegisterClientEvent(_engine, _responder, now(), uri, client)); } diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp index 7b0f32d4..9d48074e 100644 --- a/src/libs/engine/QueuedEngineInterface.hpp +++ b/src/libs/engine/QueuedEngineInterface.hpp @@ -68,7 +68,7 @@ public: virtual void disable_responses(); // Client registration - virtual void register_client(const string& uri, SharedPtr client); + virtual void register_client(const string& uri, ClientInterface* client); virtual void unregister_client(const string& uri); diff --git a/src/libs/engine/events/RegisterClientEvent.cpp b/src/libs/engine/events/RegisterClientEvent.cpp index ac2dbbc3..ac38d88c 100644 --- a/src/libs/engine/events/RegisterClientEvent.cpp +++ b/src/libs/engine/events/RegisterClientEvent.cpp @@ -27,7 +27,7 @@ RegisterClientEvent::RegisterClientEvent(Engine& engine, SharedPtr responder, SampleCount timestamp, const string& uri, - SharedPtr client) + ClientInterface* client) : QueuedEvent(engine, responder, timestamp) , _uri(uri) , _client(client) diff --git a/src/libs/engine/events/RegisterClientEvent.hpp b/src/libs/engine/events/RegisterClientEvent.hpp index 90528956..a653a8bd 100644 --- a/src/libs/engine/events/RegisterClientEvent.hpp +++ b/src/libs/engine/events/RegisterClientEvent.hpp @@ -39,14 +39,14 @@ public: SharedPtr responder, SampleCount timestamp, const string& uri, - SharedPtr client); + ClientInterface* client); void pre_process(); void post_process(); private: - string _uri; - SharedPtr _client; + string _uri; + ClientInterface* _client; }; diff --git a/src/libs/engine/events/RequestAllObjectsEvent.cpp b/src/libs/engine/events/RequestAllObjectsEvent.cpp index 4b068536..d82b6779 100644 --- a/src/libs/engine/events/RequestAllObjectsEvent.cpp +++ b/src/libs/engine/events/RequestAllObjectsEvent.cpp @@ -49,7 +49,7 @@ RequestAllObjectsEvent::post_process() // Everything is a child of the root patch, so this sends it all Patch* root = _engine.object_store()->find_patch("/"); if (root) - ObjectSender::send_patch(_client.get(), root, true); + ObjectSender::send_patch(_client, root, true); } else { _responder->respond_error("Unable to find client to send all objects"); diff --git a/src/libs/engine/events/RequestAllObjectsEvent.hpp b/src/libs/engine/events/RequestAllObjectsEvent.hpp index 91dfefc3..016e35c7 100644 --- a/src/libs/engine/events/RequestAllObjectsEvent.hpp +++ b/src/libs/engine/events/RequestAllObjectsEvent.hpp @@ -42,7 +42,7 @@ public: void post_process(); private: - SharedPtr _client; + ClientInterface* _client; }; diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp index 9540d738..fa0ecafb 100644 --- a/src/libs/engine/events/RequestMetadataEvent.cpp +++ b/src/libs/engine/events/RequestMetadataEvent.cpp @@ -33,7 +33,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, SharedPtr()) + _client(NULL) { } diff --git a/src/libs/engine/events/RequestMetadataEvent.hpp b/src/libs/engine/events/RequestMetadataEvent.hpp index ed33e4af..db41fd32 100644 --- a/src/libs/engine/events/RequestMetadataEvent.hpp +++ b/src/libs/engine/events/RequestMetadataEvent.hpp @@ -44,11 +44,11 @@ public: void post_process(); private: - string _path; - string _key; - Raul::Atom _value; - GraphObject* _object; - SharedPtr _client; + string _path; + string _key; + Raul::Atom _value; + GraphObject* _object; + ClientInterface* _client; }; diff --git a/src/libs/engine/events/RequestObjectEvent.cpp b/src/libs/engine/events/RequestObjectEvent.cpp index 745b10c1..f8343df0 100644 --- a/src/libs/engine/events/RequestObjectEvent.cpp +++ b/src/libs/engine/events/RequestObjectEvent.cpp @@ -68,21 +68,21 @@ RequestObjectEvent::post_process() Patch* const patch = dynamic_cast(_object); if (patch) { _responder->respond_ok(); - ObjectSender::send_patch(_client.get(), patch, true); + ObjectSender::send_patch(_client, patch, true); return; } Node* const node = dynamic_cast(_object); if (node) { _responder->respond_ok(); - ObjectSender::send_node(_client.get(), node, true); + ObjectSender::send_node(_client, node, true); return; } Port* const port = dynamic_cast(_object); if (port) { _responder->respond_ok(); - ObjectSender::send_port(_client.get(), port); + ObjectSender::send_port(_client, port); return; } diff --git a/src/libs/engine/events/RequestObjectEvent.hpp b/src/libs/engine/events/RequestObjectEvent.hpp index 6731182a..58f7d73e 100644 --- a/src/libs/engine/events/RequestObjectEvent.hpp +++ b/src/libs/engine/events/RequestObjectEvent.hpp @@ -45,9 +45,9 @@ public: void post_process(); private: - string _path; - GraphObject* _object; - SharedPtr _client; + string _path; + GraphObject* _object; + ClientInterface* _client; }; diff --git a/src/libs/engine/events/RequestPluginEvent.hpp b/src/libs/engine/events/RequestPluginEvent.hpp index 26e5a8fa..8c927ed5 100644 --- a/src/libs/engine/events/RequestPluginEvent.hpp +++ b/src/libs/engine/events/RequestPluginEvent.hpp @@ -45,9 +45,9 @@ public: void post_process(); private: - string _uri; - const Plugin* _plugin; - SharedPtr _client; + string _uri; + const Plugin* _plugin; + ClientInterface* _client; }; diff --git a/src/libs/engine/events/RequestPluginsEvent.hpp b/src/libs/engine/events/RequestPluginsEvent.hpp index fae8bf94..489478e4 100644 --- a/src/libs/engine/events/RequestPluginsEvent.hpp +++ b/src/libs/engine/events/RequestPluginsEvent.hpp @@ -45,8 +45,8 @@ public: void post_process(); private: - SharedPtr _client; - std::list _plugins; + ClientInterface* _client; + std::list _plugins; }; diff --git a/src/libs/engine/events/RequestPortValueEvent.hpp b/src/libs/engine/events/RequestPortValueEvent.hpp index 1a20b90f..da843947 100644 --- a/src/libs/engine/events/RequestPortValueEvent.hpp +++ b/src/libs/engine/events/RequestPortValueEvent.hpp @@ -45,10 +45,10 @@ public: void post_process(); private: - string _port_path; - Port* _port; - Sample _value; - SharedPtr _client; + string _port_path; + Port* _port; + Sample _value; + ClientInterface* _client; }; -- cgit v1.2.1