From 19045ab92aa7e996971584a0dc8780d1d58b498b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Dec 2009 21:37:50 +0000 Subject: New ingen module (library, not e.g. LV2 plugin) design. Much cleaner interface and general usage of Ingen as a library. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2314 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/client.cpp | 64 +++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 28 deletions(-) (limited to 'src/client/client.cpp') diff --git a/src/client/client.cpp b/src/client/client.cpp index 53d7810f..9512ba44 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -16,9 +16,9 @@ */ #include "ingen-config.h" - -#include -#include "client.hpp" +#include "raul/SharedPtr.hpp" +#include "module/Module.hpp" +#include "module/World.hpp" #ifdef HAVE_LIBLO #include "OSCEngineSender.hpp" #endif @@ -26,39 +26,47 @@ #include "HTTPEngineSender.hpp" #endif +using namespace Ingen; -using namespace std; - -namespace Ingen { -namespace Client { - - +#ifdef HAVE_LIBLO SharedPtr -new_remote_interface(Ingen::Shared::World* world, const std::string& url) +new_osc_interface(Ingen::Shared::World* world, const std::string& url) { - const string scheme = url.substr(0, url.find(":")); - -#ifdef HAVE_LIBLO - if (scheme == "osc.udp" || scheme == "osc.tcp") { - OSCEngineSender* oes = OSCEngineSender::create(url); - oes->attach(rand(), true); - return SharedPtr(oes); - } + Client::OSCEngineSender* oes = Client::OSCEngineSender::create(url); + oes->attach(rand(), true); + return SharedPtr(oes); +} #endif #ifdef HAVE_SOUP - if (scheme == "http") { - HTTPEngineSender* hes = new HTTPEngineSender(world, url); - hes->attach(rand(), true); - return SharedPtr(hes); - } +SharedPtr +new_http_interface(Ingen::Shared::World* world, const std::string& url) +{ + Client::HTTPEngineSender* hes = new Client::HTTPEngineSender(world, url); + hes->attach(rand(), true); + return SharedPtr(hes); +} #endif - cerr << "WARNING: Unknown URI scheme '" << scheme << "'" << endl; - return SharedPtr(); -} +struct IngenClientModule : public Ingen::Shared::Module { + void load(Ingen::Shared::World* world) { + world->interface_factories.insert(make_pair("osc.udp", &new_osc_interface)); + world->interface_factories.insert(make_pair("osc.tcp", &new_osc_interface)); + world->interface_factories.insert(make_pair("http", &new_http_interface)); + } +}; +static IngenClientModule* module = NULL; + +extern "C" { + +Ingen::Shared::Module* +ingen_module_load() { + if (!module) + module = new IngenClientModule(); + + return module; +} -} // namespace Client -} // namespace Ingen +} // extern "C" -- cgit v1.2.1