summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-08 23:15:42 +0000
committerDavid Robillard <d@drobilla.net>2006-09-08 23:15:42 +0000
commitb853b3dde1f7028dd275f78433a6ad9b5b9f61c7 (patch)
tree0a3fa37cedd2ba49158e11168974387d1e0c3a37 /src/libs/client
parent9028938008fa22ca2fe0c4ac7677471ac499b63f (diff)
downloadingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.tar.gz
ingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.tar.bz2
ingen-b853b3dde1f7028dd275f78433a6ad9b5b9f61c7.zip
More cleanups
git-svn-id: http://svn.drobilla.net/lad/ingen@122 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/DirectSigClientInterface.h38
-rw-r--r--src/libs/client/Makefile.am2
-rw-r--r--src/libs/client/ModelEngineInterface.h13
-rw-r--r--src/libs/client/OSCClientReceiver.cpp11
-rw-r--r--src/libs/client/OSCClientReceiver.h1
-rw-r--r--src/libs/client/OSCEngineSender.cpp114
-rw-r--r--src/libs/client/OSCEngineSender.h10
-rw-r--r--src/libs/client/OSCModelEngineInterface.cpp366
-rw-r--r--src/libs/client/OSCModelEngineInterface.h85
-rw-r--r--src/libs/client/SigClientInterface.h59
-rw-r--r--src/libs/client/Store.cpp27
-rw-r--r--src/libs/client/Store.h12
-rw-r--r--src/libs/client/ThreadedSigClientInterface.h100
13 files changed, 208 insertions, 630 deletions
diff --git a/src/libs/client/DirectSigClientInterface.h b/src/libs/client/DirectSigClientInterface.h
index d57771cd..fe131188 100644
--- a/src/libs/client/DirectSigClientInterface.h
+++ b/src/libs/client/DirectSigClientInterface.h
@@ -50,61 +50,61 @@ private:
// ClientInterface function implementations to drive SigClientInterface signals
virtual void bundle_begin()
- { emit_bundle_begin(); }
+ { bundle_begin_sig.emit(); }
virtual void bundle_end()
- { emit_bundle_end(); }
+ { bundle_end_sig.emit(); }
virtual void error(const string& msg)
- { emit_error(msg); }
+ { error_sig.emit(msg); }
virtual void num_plugins(uint32_t num)
- { emit_num_plugins(num); }
+ { num_plugins_sig.emit(num); }
virtual void new_plugin(const string& type, const string& uri, const string& name)
- { emit_new_plugin(type, uri, name); }
+ { new_plugin_sig.emit(type, uri, name); }
virtual void new_patch(const string& path, uint32_t poly)
- { emit_new_patch(path, poly); }
+ { new_patch_sig.emit(path, poly); }
virtual void new_node(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports)
- { emit_new_node(plugin_type, plugin_uri, node_path, is_polyphonic, num_ports); }
+ { new_node_sig.emit(plugin_type, plugin_uri, node_path, is_polyphonic, num_ports); }
virtual void new_port(const string& path, const string& data_type, bool is_output)
- { emit_new_port(path, data_type, is_output); }
+ { new_port_sig.emit(path, data_type, is_output); }
virtual void patch_enabled(const string& path)
- { emit_patch_enabled(path); }
+ { patch_enabled_sig.emit(path); }
virtual void patch_disabled(const string& path)
- { emit_patch_disabled(path); }
+ { patch_disabled_sig.emit(path); }
virtual void patch_cleared(const string& path)
- { emit_patch_cleared(path); }
+ { patch_cleared_sig.emit(path); }
virtual void object_renamed(const string& old_path, const string& new_path)
- { emit_object_renamed(old_path, new_path); }
+ { object_renamed_sig.emit(old_path, new_path); }
virtual void object_destroyed(const string& path)
- { emit_object_destroyed(path); }
+ { object_destroyed_sig.emit(path); }
virtual void connection(const string& src_port_path, const string& dst_port_path)
- { emit_connection(src_port_path, dst_port_path); }
+ { connection_sig.emit(src_port_path, dst_port_path); }
virtual void disconnection(const string& src_port_path, const string& dst_port_path)
- { emit_disconnection(src_port_path, dst_port_path); }
+ { disconnection_sig.emit(src_port_path, dst_port_path); }
virtual void metadata_update(const string& subject_path, const string& predicate, const string& value)
- { emit_metadata_update(subject_path, predicate, value); }
+ { metadata_update_sig.emit(subject_path, predicate, value); }
virtual void control_change(const string& port_path, float value)
- { emit_control_change(port_path, value); }
+ { control_change_sig.emit(port_path, value); }
virtual void program_add(const string& node_path, uint32_t bank, uint32_t program, const string& program_name)
- { emit_program_add(node_path, bank, program, program_name); }
+ { program_add_sig.emit(node_path, bank, program, program_name); }
virtual void program_remove(const string& node_path, uint32_t bank, uint32_t program)
- { emit_program_remove(node_path, bank, program); }
+ { program_remove_sig.emit(node_path, bank, program); }
};
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index f8a9a1cf..effa2759 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -10,7 +10,6 @@ libomclient_la_SOURCES = \
OSCEngineSender.h \
OSCEngineSender.cpp \
OSCModelEngineInterface.h \
- OSCModelEngineInterface.cpp \
OSCClientReceiver.h \
OSCClientReceiver.cpp \
SigClientInterface.h \
@@ -18,6 +17,7 @@ libomclient_la_SOURCES = \
ThreadedSigClientInterface.h \
ThreadedSigClientInterface.cpp \
ModelEngineInterface.h \
+ ModelEngineInterface.cpp \
ModelClientInterface.h \
ModelClientInterface.cpp \
PresetModel.h \
diff --git a/src/libs/client/ModelEngineInterface.h b/src/libs/client/ModelEngineInterface.h
index 42b95d00..29d82d8d 100644
--- a/src/libs/client/ModelEngineInterface.h
+++ b/src/libs/client/ModelEngineInterface.h
@@ -22,12 +22,13 @@
#include "interface/EngineInterface.h"
using std::string;
-/** \defgroup IngenClient Client Library
- */
+class Path;
+/** \defgroup IngenClient Client Library */
namespace Ingen {
namespace Client {
+class ObjectModel;
class NodeModel;
class PresetModel;
class PatchModel;
@@ -42,11 +43,11 @@ class ModelEngineInterface : public virtual Shared::EngineInterface
public:
virtual ~ModelEngineInterface() {}
- virtual void create_patch_from_model(const PatchModel* pm) = 0;
- virtual void create_node_from_model(const NodeModel* nm) = 0;
+ virtual void create_patch_from_model(const PatchModel* pm);
+ virtual void create_node_from_model(const NodeModel* nm);
- virtual void set_all_metadata(const NodeModel* nm) = 0;
- virtual void set_preset(const string& patch_path, const PresetModel* pm) = 0;
+ virtual void set_all_metadata(const ObjectModel* nm);
+ virtual void set_preset(const Path& patch_path, const PresetModel* pm);
protected:
ModelEngineInterface() {}
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index 56d8ea14..1d52caa3 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -141,6 +141,7 @@ OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv
void
OSCClientReceiver::setup_callbacks()
{
+ lo_server_thread_add_method(_st, "/om/response", "iis", response_cb, this);
lo_server_thread_add_method(_st, "/om/num_plugins", "i", num_plugins_cb, this);
lo_server_thread_add_method(_st, "/om/plugin", "sss", plugin_cb, this);
lo_server_thread_add_method(_st, "/om/new_patch", "si", new_patch_cb, this);
@@ -358,6 +359,16 @@ OSCClientReceiver::m_control_change_cb(const char* path, const char* types, lo_a
}
+int
+OSCClientReceiver::m_response_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ assert(!strcmp(types, "iis"));
+ response(argv[0]->i, argv[1]->i, &argv[2]->s);
+
+ return 0;
+}
+
+
/** Number of plugins in engine, should precede /om/plugin messages in response
* to a /om/send_plugins
*/
diff --git a/src/libs/client/OSCClientReceiver.h b/src/libs/client/OSCClientReceiver.h
index 60fa9495..2d957a6a 100644
--- a/src/libs/client/OSCClientReceiver.h
+++ b/src/libs/client/OSCClientReceiver.h
@@ -93,6 +93,7 @@ private:
//int32_t _num_received_ports;
LO_HANDLER(error);
+ LO_HANDLER(response);
LO_HANDLER(num_plugins);
LO_HANDLER(plugin);
LO_HANDLER(plugin_list_end);
diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp
index cc70dc8e..10d9ab2e 100644
--- a/src/libs/client/OSCEngineSender.cpp
+++ b/src/libs/client/OSCEngineSender.cpp
@@ -14,8 +14,10 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <iostream>
#include "OSCEngineSender.h"
#include "interface/ClientKey.h"
+using std::cout; using std::cerr; using std::endl;
namespace Ingen {
namespace Client {
@@ -38,6 +40,62 @@ OSCEngineSender::~OSCEngineSender()
}
+/** Attempt to connect to the engine (by pinging it).
+ *
+ * This doesn't register a client (or otherwise affect the client/engine state).
+ * To check for success wait for the ping response with id @a ping_id (using the
+ * relevant OSCClientReceiver).
+ *
+ * Passing a client_port of 0 will automatically choose a free port. If the
+ * @a block parameter is true, this function will not return until a connection
+ * has successfully been made.
+ */
+void
+OSCEngineSender::attach(int32_t ping_id, bool block)
+{
+ cerr << "FIXME: attach\n";
+ //start_listen_thread(_client_port);
+
+ /*if (engine_url == "") {
+ string local_url = m_osc_listener->listen_url().substr(
+ 0, m_osc_listener->listen_url().find_last_of(":"));
+ local_url.append(":16180");
+ _engine_addr = lo_address_new_from_url(local_url.c_str());
+ } else {
+ _engine_addr = lo_address_new_from_url(engine_url.c_str());
+ }
+ */
+ _engine_addr = lo_address_new_from_url(_engine_url.c_str());
+
+ if (_engine_addr == NULL) {
+ cerr << "Unable to connect, aborting." << endl;
+ exit(EXIT_FAILURE);
+ }
+
+ cout << "[OSCEngineSender] Attempting to contact engine at " << _engine_url << " ..." << endl;
+
+ _id = ping_id;
+ this->ping();
+
+ /*if (block) {
+ set_wait_response_id(request_id);
+
+ while (1) {
+ if (m_response_semaphore.try_wait() != 0) {
+ cout << ".";
+ cout.flush();
+ ping(request_id);
+ usleep(100000);
+ } else {
+ cout << " connected." << endl;
+ m_waiting_for_response = false;
+ break;
+ }
+ }
+ }
+ */
+}
+
/* *** EngineInterface implementation below here *** */
@@ -103,7 +161,7 @@ OSCEngineSender::quit()
void
OSCEngineSender::create_patch(const string& path,
- uint32_t poly)
+ uint32_t poly)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/create_patch", "isi",
@@ -115,8 +173,8 @@ OSCEngineSender::create_patch(const string& path,
void
OSCEngineSender::create_port(const string& path,
- const string& data_type,
- bool is_output)
+ const string& data_type,
+ bool is_output)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/create_port", "issi",
@@ -129,9 +187,9 @@ OSCEngineSender::create_port(const string& path,
void
OSCEngineSender::create_node(const string& path,
- const string& plugin_type,
- const string& plugin_uri,
- bool polyphonic)
+ const string& plugin_type,
+ const string& plugin_uri,
+ bool polyphonic)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/create_node", "isssi",
@@ -143,9 +201,31 @@ OSCEngineSender::create_node(const string& path,
}
+/** Create a node using library name and plugin label (DEPRECATED).
+ *
+ * DO NOT USE THIS.
+ */
+void
+OSCEngineSender::create_node(const string& path,
+ const string& plugin_type,
+ const string& library_name,
+ const string& plugin_label,
+ bool polyphonic)
+{
+ assert(_engine_addr);
+ lo_send(_engine_addr, "/om/synth/create_node", "issssi",
+ next_id(),
+ path.c_str(),
+ plugin_type.c_str(),
+ library_name.c_str(),
+ plugin_label.c_str(),
+ (polyphonic ? 1 : 0));
+}
+
+
void
OSCEngineSender::rename(const string& old_path,
- const string& new_name)
+ const string& new_name)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/rename", "iss",
@@ -197,7 +277,7 @@ OSCEngineSender::disable_patch(const string& patch_path)
void
OSCEngineSender::connect(const string& src_port_path,
- const string& dst_port_path)
+ const string& dst_port_path)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/connect", "iss",
@@ -209,7 +289,7 @@ OSCEngineSender::connect(const string& src_port_path,
void
OSCEngineSender::disconnect(const string& src_port_path,
- const string& dst_port_path)
+ const string& dst_port_path)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/disconnect", "iss",
@@ -231,7 +311,7 @@ OSCEngineSender::disconnect_all(const string& node_path)
void
OSCEngineSender::set_port_value(const string& port_path,
- float val)
+ float val)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/set_port_value", "isf",
@@ -243,8 +323,8 @@ OSCEngineSender::set_port_value(const string& port_path,
void
OSCEngineSender::set_port_value(const string& port_path,
- uint32_t voice,
- float val)
+ uint32_t voice,
+ float val)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/set_port_value", "isif",
@@ -257,7 +337,7 @@ OSCEngineSender::set_port_value(const string& port_path,
void
OSCEngineSender::set_port_value_queued(const string& port_path,
- float val)
+ float val)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/synth/set_port_value_queued", "isf",
@@ -269,8 +349,8 @@ OSCEngineSender::set_port_value_queued(const string& port_path,
void
OSCEngineSender::set_program(const string& node_path,
- uint32_t bank,
- uint32_t program)
+ uint32_t bank,
+ uint32_t program)
{
assert(_engine_addr);
lo_send(_engine_addr,
@@ -293,8 +373,8 @@ OSCEngineSender::midi_learn(const string& node_path)
void
OSCEngineSender::set_metadata(const string& obj_path,
- const string& predicate,
- const string& value)
+ const string& predicate,
+ const string& value)
{
assert(_engine_addr);
lo_send(_engine_addr, "/om/metadata/set", "isss",
diff --git a/src/libs/client/OSCEngineSender.h b/src/libs/client/OSCEngineSender.h
index 91e2d559..3335a91f 100644
--- a/src/libs/client/OSCEngineSender.h
+++ b/src/libs/client/OSCEngineSender.h
@@ -47,11 +47,13 @@ public:
string engine_url() { return _engine_url; }
inline size_t next_id()
- { if (_id != -1) { _id = (_id == -2) ? 0 : _id+1; } return _id; }
+ { int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
void enable_responses() { _id = 0; }
void disable_responses() { _id = -1; }
+ void attach(int32_t ping_id, bool block);
+
/* *** EngineInterface implementation below here *** */
@@ -80,6 +82,12 @@ public:
const string& plugin_type,
const string& plugin_uri,
bool polyphonic);
+
+ void create_node(const string& path,
+ const string& plugin_type,
+ const string& library_name,
+ const string& plugin_label,
+ bool polyphonic);
void rename(const string& old_path,
const string& new_name);
diff --git a/src/libs/client/OSCModelEngineInterface.cpp b/src/libs/client/OSCModelEngineInterface.cpp
deleted file mode 100644
index 14f2fe3a..00000000
--- a/src/libs/client/OSCModelEngineInterface.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/* This file is part of Ingen. Copyright (C) 2006 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
- */
-
-#include "OSCModelEngineInterface.h"
-#include <list>
-#include <cassert>
-#include <cstdlib>
-#include <cstring>
-#include <iostream>
-#include <unistd.h>
-#include "OSCClientReceiver.h"
-#include "PatchModel.h"
-#include "ConnectionModel.h"
-#include "PresetModel.h"
-#include "ControlModel.h"
-#include "NodeModel.h"
-#include "PluginModel.h"
-
-using std::cerr; using std::cout; using std::endl;
-
-namespace Ingen {
-namespace Client {
-
-
-/** Construct a OSCModelEngineInterface with a user-provided ModelClientInterface object for notification
- * of engine events.
- */
-OSCModelEngineInterface::OSCModelEngineInterface(const string& engine_url)
-: OSCEngineSender(engine_url),
- m_request_id(0),
- m_is_attached(false),
- m_is_registered(false)
- /*m_blocking(false),
- m_waiting_for_response(false),
- m_wait_response_id(0),
- m_response_received(false),
- m_wait_response_was_affirmative(false),
- m_response_semaphore(0)*/
-{
-}
-
-
-OSCModelEngineInterface::~OSCModelEngineInterface()
-{
- detach();
-}
-
-
-/** Attempt to connect to the engine and notify it of our existance.
- *
- * Passing a client_port of 0 will automatically choose a free port. If the
- * @a block parameter is true, this function will not return until a connection
- * has successfully been made.
- */
-void
-OSCModelEngineInterface::attach(bool block)
-{
- cerr << "FIXME: listen thread\n";
- //start_listen_thread(_client_port);
-
- /*if (engine_url == "") {
- string local_url = m_osc_listener->listen_url().substr(
- 0, m_osc_listener->listen_url().find_last_of(":"));
- local_url.append(":16180");
- _engine_addr = lo_address_new_from_url(local_url.c_str());
- } else {
- _engine_addr = lo_address_new_from_url(engine_url.c_str());
- }
- */
- _engine_addr = lo_address_new_from_url(_engine_url.c_str());
-
- if (_engine_addr == NULL) {
- cerr << "Unable to connect, aborting." << endl;
- exit(EXIT_FAILURE);
- }
-
- char* lo_url = lo_address_get_url(_engine_addr);
- cout << "[OSCModelEngineInterface] Attempting to contact engine at " << lo_url << " ..." << endl;
-
- this->ping();
-
- m_is_attached = true; // FIXME
-
- /*if (block) {
- set_wait_response_id(request_id);
-
- while (1) {
- if (m_response_semaphore.try_wait() != 0) {
- cout << ".";
- cout.flush();
- ping(request_id);
- usleep(100000);
- } else {
- cout << " connected." << endl;
- m_waiting_for_response = false;
- break;
- }
- }
- }
- */
-
- free(lo_url);
-}
-
-void
-OSCModelEngineInterface::detach()
-{
- m_is_attached = false;
-}
-
-#if 0
-void
-OSCModelEngineInterface::start_listen_thread(int client_port)
-{
- if (m_st != NULL)
- return;
-
- if (client_port == 0) {
- m_st = lo_server_thread_new(NULL, error_cb);
- } else {
- char port_str[8];
- snprintf(port_str, 8, "%d", client_port);
- m_st = lo_server_thread_new(port_str, error_cb);
- }
-
- if (m_st == NULL) {
- cerr << "[OSCModelEngineInterface] Could not start OSC listener. Aborting." << endl;
- exit(EXIT_FAILURE);
- } else {
- cout << "[OSCModelEngineInterface] Started OSC listener on port " << lo_server_thread_get_port(m_st) << endl;
- }
-
- lo_server_thread_add_method(m_st, NULL, NULL, generic_cb, NULL);
-
- lo_server_thread_add_method(m_st, "/om/response/ok", "i", om_response_ok_cb, this);
- lo_server_thread_add_method(m_st, "/om/response/error", "is", om_response_error_cb, this);
-
-
- m_osc_listener = new OSCListener(m_st, m_client_hooks);
- m_osc_listener->setup_callbacks();
-
- // Display any uncaught messages to the console
- lo_server_thread_add_method(m_st, NULL, NULL, unknown_cb, NULL);
-
- lo_server_thread_start(m_st);
-}
-#endif
-
-///// OSC Commands /////
-
-
-
-/** Load a node.
- */
-void
-OSCModelEngineInterface::create_node_from_model(const NodeModel* nm)
-{
- assert(_engine_addr);
-
- // Load by URI
- if (nm->plugin()->uri().length() > 0) {
- lo_send(_engine_addr, "/om/synth/create_node", "isssi", next_id(),
- nm->path().c_str(),
- nm->plugin()->type_string(),
- nm->plugin()->uri().c_str(),
- (nm->polyphonic() ? 1 : 0));
- // Load by libname, label
- } else {
- //assert(nm->plugin()->lib_name().length() > 0);
- assert(nm->plugin()->plug_label().length() > 0);
- lo_send(_engine_addr, "/om/synth/create_node", "issssi", next_id(),
- nm->path().c_str(),
- nm->plugin()->type_string(),
- nm->plugin()->lib_name().c_str(),
- nm->plugin()->plug_label().c_str(),
- (nm->polyphonic() ? 1 : 0));
- }
-}
-
-
-/** Create a patch.
- */
-void
-OSCModelEngineInterface::create_patch_from_model(const PatchModel* pm)
-{
- assert(_engine_addr);
- lo_send(_engine_addr, "/om/synth/create_patch", "isi", next_id(), pm->path().c_str(), pm->poly());
-}
-
-
-/** Notify LASH restoring is finished */
-/*
-void
-OSCModelEngineInterface::lash_restore_finished()
-{
- assert(_engine_addr != NULL);
- int id = m_request_id++;
- lo_send(_engine_addr, "/om/lash/restore_finished", "i", id);
-}
-*/
-#if 0
-/** Set/add a piece of metadata.
- */
-void
-OSCModelEngineInterface::set_metadata(const string& obj_path,
- const string& key, const string& value)
-{
- assert(_engine_addr != NULL);
- int id = m_request_id++;
-
- // Deal with the "special" DSSI metadata strings
- if (key.substr(0, 16) == "dssi-configure--") {
- string path = "/dssi" + obj_path + "/configure";
- string dssi_key = key.substr(16);
- lo_send(_engine_addr, path.c_str(), "ss", dssi_key.c_str(), value.c_str());
- } else if (key == "dssi-program") {
- string path = "/dssi" + obj_path + "/program";
- string dssi_bank_str = value.substr(0, value.find("/"));
- int dssi_bank = atoi(dssi_bank_str.c_str());
- string dssi_program_str = value.substr(value.find("/")+1);
- int dssi_program = atoi(dssi_program_str.c_str());
- lo_send(_engine_addr, path.c_str(), "ii", dssi_bank, dssi_program);
- }
-
- // Normal metadata
- lo_send(_engine_addr, "/om/metadata/set", "isss", id,
- obj_path.c_str(), key.c_str(), value.c_str());
-}
-#endif
-
-/** Set all pieces of metadata in a NodeModel.
- */
-void
-OSCModelEngineInterface::set_all_metadata(const NodeModel* nm)
-{
- assert(_engine_addr != NULL);
-
- for (map<string, string>::const_iterator i = nm->metadata().begin(); i != nm->metadata().end(); ++i)
- set_metadata(nm->path(), (*i).first, (*i).second.c_str());
-}
-
-
-/** Set a preset by setting all relevant controls for a patch.
- */
-void
-OSCModelEngineInterface::set_preset(const string& patch_path, const PresetModel* const pm)
-{
- assert(patch_path.find("//") == string::npos);
- for (list<ControlModel>::const_iterator i = pm->controls().begin(); i != pm->controls().end(); ++i) {
- set_port_value_queued((*i).port_path(), (*i).value());
- usleep(1000);
- }
-}
-
-
-///// Requests /////
-
-
-#if 0
-/** Sets the response ID to be waited for on the next call to wait_for_response()
- */
-
-void
-OSCModelEngineInterface::set_wait_response_id(int id)
-{
- assert(!m_waiting_for_response);
- m_wait_response_id = id;
- m_response_received = false;
- m_waiting_for_response = true;
-}
-
-
-/** Waits for the response set by set_wait_response() from the server.
- *
- * Returns whether or not the response was positive (ie a success message)
- * or negative (ie an error)
- */
-bool
-OSCModelEngineInterface::wait_for_response()
-{
- cerr << "[OSCModelEngineInterface] Waiting for response " << m_wait_response_id << ": ";
- bool ret = true;
-
- assert(m_waiting_for_response);
- assert(!m_response_received);
-
- while (!m_response_received)
- m_response_semaphore.wait();
-
- cerr << " received." << endl;
-
- m_waiting_for_response = false;
- ret = m_wait_response_was_affirmative;
-
- return ret;
-}
-#endif
-
-///// Static OSC callbacks //////
-
-
-//// End static callbacks, member callbacks below ////
-
-/*
-int
-OSCModelEngineInterface::m_om_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data)
-{
- assert(argc == 1 && !strcmp(types, "i"));
-
- // FIXME
- if (!m_is_attached)
- m_is_attached = true;
-
- if (m_waiting_for_response) {
- const int request_id = argv[0]->i;
-
- if (request_id == m_wait_response_id) {
- m_response_received = true;
- m_wait_response_was_affirmative = true;
- m_response_semaphore.post();
- }
- }
-
- return 0;
-}
-
-
-int
-OSCModelEngineInterface::m_om_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data)
-{
- assert(argc == 2 && !strcmp(types, "is"));
-
- const int request_id = argv[0]->i;
- const char* msg = &argv[1]->s;
-
- if (m_waiting_for_response) {
- if (request_id == m_wait_response_id) {
- m_response_received = true;
- m_wait_response_was_affirmative = false;
- m_response_semaphore.post();
- }
- }
-
- cerr << "ERROR: " << msg << endl;
- //if (m_client_hooks != NULL)
- // m_client_hooks->error(msg);
-
- return 0;
-}
-*/
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/OSCModelEngineInterface.h b/src/libs/client/OSCModelEngineInterface.h
index f600fb8f..1ca263fa 100644
--- a/src/libs/client/OSCModelEngineInterface.h
+++ b/src/libs/client/OSCModelEngineInterface.h
@@ -14,99 +14,28 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef OSCCONTROLLER_H
-#define OSCCONTROLLER_H
+#ifndef OSCMODELENGINEINTERFACE_H
+#define OSCMODELENGINEINTERFACE_H
#include <string>
-#include <lo/lo.h>
-#include "util/Semaphore.h"
-#include "interface/EngineInterface.h"
#include "OSCEngineSender.h"
#include "ModelEngineInterface.h"
-using std::string;
-/** \defgroup IngenClient Client Library
- */
+using std::string;
+/** \defgroup IngenClient Client Library */
namespace Ingen {
namespace Client {
-class NodeModel;
-class PresetModel;
-class PatchModel;
-class ModelClientInterface;
-
-/** Old model-based OSC engine command interface.
- *
- * This is an old class from before when the well-defined interfaces between
- * engine and client were defined. I've wrapped it around OSCEngineSender
- * so all the common functions are implemented there, and implemented the
- * remaining functions using those, for compatibility. Hopefully something
- * better gets figured out and this can go away completely, but for now this
- * gets the existing clients working through EngineInterface in the easiest
- * way possible. This class needs to die.
- *
- * \ingroup IngenClient
- */
class OSCModelEngineInterface : public OSCEngineSender, public ModelEngineInterface
{
public:
- //OSCModelEngineInterface(ModelClientInterface* const client_hooks, const string& engine_url);
- OSCModelEngineInterface(const string& engine_url);
- ~OSCModelEngineInterface();
-
- void attach(bool block = true);
- void detach();
-
- bool is_attached() { return m_is_attached; }
-
- // FIXME: reimplement
- void set_wait_response_id(int32_t id) {}
- bool wait_for_response() { return false; }
- int get_next_request_id() { return m_request_id++; }
-
- /* *** Model alternatives to EngineInterface functions below *** */
-
- void create_patch_from_model(const PatchModel* pm);
- void create_node_from_model(const NodeModel* nm);
-
- void set_all_metadata(const NodeModel* nm);
- void set_preset(const string& patch_path, const PresetModel* const pm);
-
-protected:
- void start_listen_thread();
-
- int m_request_id;
-
- bool m_is_attached;
- bool m_is_registered;
- /*
- bool m_blocking;
- bool m_waiting_for_response;
- int m_wait_response_id;
- bool m_response_received;
- bool m_wait_response_was_affirmative;
-
- Semaphore m_response_semaphore;
- */
-private:
- // Prevent copies
- OSCModelEngineInterface(const OSCModelEngineInterface& copy);
- OSCModelEngineInterface& operator=(const OSCModelEngineInterface& copy);
+ OSCModelEngineInterface(const string& engine_url) : OSCEngineSender(engine_url) {}
};
-/*
-inline int
-OSCModelEngineInterface::om_response_ok_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* comm) {
- return ((OSCModelEngineInterface*)comm)->m_om_response_ok_cb(path, types, argv, argc, data);
-}
-inline int
-OSCModelEngineInterface::om_response_error_cb(const char* path, const char* types, lo_arg** argv, int argc, void* data, void* comm) {
- return ((OSCModelEngineInterface*)comm)->m_om_response_error_cb(path, types, argv, argc, data);
-}
-*/
+
} // namespace Client
} // namespace Ingen
-#endif // OSCCONTROLLER_H
+#endif // OSCMODELENGINEINTERFACE_H
diff --git a/src/libs/client/SigClientInterface.h b/src/libs/client/SigClientInterface.h
index 6e14de8c..de76f9c1 100644
--- a/src/libs/client/SigClientInterface.h
+++ b/src/libs/client/SigClientInterface.h
@@ -39,6 +39,7 @@ public:
// See the corresponding emitting functions below for parameter meanings
+ sigc::signal<void, int32_t,bool,const string&> response_sig;
sigc::signal<void> bundle_begin_sig;
sigc::signal<void> bundle_end_sig;
sigc::signal<void, const string&> error_sig;
@@ -59,64 +60,6 @@ public:
sigc::signal<void, const string&, uint32_t, uint32_t, const string&> program_add_sig;
sigc::signal<void, const string&, uint32_t, uint32_t> program_remove_sig;
-
- inline void emit_bundle_begin()
- { bundle_begin_sig.emit(); }
-
- inline void emit_bundle_end()
- { bundle_end_sig.emit(); }
-
- inline void emit_error(const string& msg)
- { error_sig.emit(msg); }
-
- inline void emit_num_plugins(uint32_t num)
- { num_plugins_sig.emit(num); }
-
- inline void emit_new_plugin(const string& type, const string& uri, const string& name)
- { new_plugin_sig.emit(type, uri, name); }
-
- inline void emit_new_patch(const string& path, uint32_t poly)
- { new_patch_sig.emit(path, poly); }
-
- inline void emit_new_node(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports)
- { new_node_sig.emit(plugin_type, plugin_uri, node_path, is_polyphonic, num_ports); }
-
- inline void emit_new_port(const string& path, const string& data_type, bool is_output)
- { new_port_sig.emit(path, data_type, is_output); }
-
- inline void emit_patch_enabled(const string& path)
- { patch_enabled_sig.emit(path); }
-
- inline void emit_patch_disabled(const string& path)
- { patch_disabled_sig.emit(path); }
-
- inline void emit_patch_cleared(const string& path)
- { patch_cleared_sig.emit(path); }
-
- inline void emit_object_renamed(const string& old_path, const string& new_path)
- { object_renamed_sig.emit(old_path, new_path); }
-
- inline void emit_object_destroyed(const string& path)
- { object_destroyed_sig.emit(path); }
-
- inline void emit_connection(const string& src_port_path, const string& dst_port_path)
- { connection_sig.emit(src_port_path, dst_port_path); }
-
- inline void emit_disconnection(const string& src_port_path, const string& dst_port_path)
- { disconnection_sig.emit(src_port_path, dst_port_path); }
-
- inline void emit_metadata_update(const string& subject_path, const string& predicate, const string& value)
- { metadata_update_sig.emit(subject_path, predicate, value); }
-
- inline void emit_control_change(const string& port_path, float value)
- { control_change_sig.emit(port_path, value); }
-
- inline void emit_program_add(const string& node_path, uint32_t bank, uint32_t program, const string& program_name)
- { program_add_sig.emit(node_path, bank, program, program_name); }
-
- inline void emit_program_remove(const string& node_path, uint32_t bank, uint32_t program)
- { program_remove_sig.emit(node_path, bank, program); }
-
protected:
SigClientInterface() {}
};
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 219ea13f..7fd011b7 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -27,24 +27,21 @@ namespace Ingen {
namespace Client {
-/// Singleton instance
-Store* Store::_instance = 0;
-
-Store::Store(SigClientInterface& emitter)
+Store::Store(CountedPtr<SigClientInterface> emitter)
{
//emitter.new_plugin_sig.connect(sigc::mem_fun(this, &Store::add_plugin));
- emitter.object_destroyed_sig.connect(sigc::mem_fun(this, &Store::destruction_event));
- emitter.new_plugin_sig.connect(sigc::mem_fun(this, &Store::new_plugin_event));
- emitter.new_patch_sig.connect(sigc::mem_fun(this, &Store::new_patch_event));
- emitter.new_node_sig.connect(sigc::mem_fun(this, &Store::new_node_event));
- emitter.new_port_sig.connect(sigc::mem_fun(this, &Store::new_port_event));
- emitter.patch_enabled_sig.connect(sigc::mem_fun(this, &Store::patch_enabled_event));
- emitter.patch_disabled_sig.connect(sigc::mem_fun(this, &Store::patch_disabled_event));
- emitter.connection_sig.connect(sigc::mem_fun(this, &Store::connection_event));
- emitter.disconnection_sig.connect(sigc::mem_fun(this, &Store::disconnection_event));
- emitter.metadata_update_sig.connect(sigc::mem_fun(this, &Store::metadata_update_event));
- emitter.control_change_sig.connect(sigc::mem_fun(this, &Store::control_change_event));
+ emitter->object_destroyed_sig.connect(sigc::mem_fun(this, &Store::destruction_event));
+ emitter->new_plugin_sig.connect(sigc::mem_fun(this, &Store::new_plugin_event));
+ emitter->new_patch_sig.connect(sigc::mem_fun(this, &Store::new_patch_event));
+ emitter->new_node_sig.connect(sigc::mem_fun(this, &Store::new_node_event));
+ emitter->new_port_sig.connect(sigc::mem_fun(this, &Store::new_port_event));
+ emitter->patch_enabled_sig.connect(sigc::mem_fun(this, &Store::patch_enabled_event));
+ emitter->patch_disabled_sig.connect(sigc::mem_fun(this, &Store::patch_disabled_event));
+ emitter->connection_sig.connect(sigc::mem_fun(this, &Store::connection_event));
+ emitter->disconnection_sig.connect(sigc::mem_fun(this, &Store::disconnection_event));
+ emitter->metadata_update_sig.connect(sigc::mem_fun(this, &Store::metadata_update_event));
+ emitter->control_change_sig.connect(sigc::mem_fun(this, &Store::control_change_event));
}
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index cb6c3206..8407c9fb 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -35,12 +35,14 @@ class PatchModel;
class NodeModel;
class PortModel;
-/** Singeton which holds all "Ingen Objects" for easy/fast lookup
+/** Automatically manages models of objects in the engine.
*
* \ingroup IngenClient
*/
class Store : public sigc::trackable { // FIXME: is trackable necessary?
public:
+ Store(CountedPtr<SigClientInterface> emitter);
+
CountedPtr<PluginModel> plugin(const string& uri);
CountedPtr<ObjectModel> object(const string& path);
/*CountedPtr<PatchModel> patch(const string& path);
@@ -53,15 +55,7 @@ public:
const map<string, CountedPtr<PluginModel> >& plugins() const { return m_plugins; }
- static void instantiate(SigClientInterface& emitter)
- { if (!_instance) _instance = new Store(emitter); }
-
- inline static Store& instance() { assert(_instance); return *_instance; }
-
private:
- Store(SigClientInterface& emitter);
-
- static Store* _instance;
void add_object(CountedPtr<ObjectModel> object);
CountedPtr<ObjectModel> remove_object(const string& path);
diff --git a/src/libs/client/ThreadedSigClientInterface.h b/src/libs/client/ThreadedSigClientInterface.h
index 985b1f26..afc756c4 100644
--- a/src/libs/client/ThreadedSigClientInterface.h
+++ b/src/libs/client/ThreadedSigClientInterface.h
@@ -44,27 +44,23 @@ class ThreadedSigClientInterface : virtual public SigClientInterface
public:
ThreadedSigClientInterface(uint32_t queue_size)
: _sigs(queue_size)
- , error_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_error))
- //, new_plugin_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_plugin_model))
- //, new_patch_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_patch_model))
- //, new_node_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_node_model))
- //, new_port_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_port_model))
- //, connection_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_connection_model))
- , new_plugin_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_plugin))
- , new_patch_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_patch))
- , new_node_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_node))
- , new_port_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_new_port))
- , connection_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_connection))
- , patch_enabled_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_patch_enabled))
- , patch_disabled_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_patch_disabled))
- , patch_cleared_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_patch_cleared))
- , object_destroyed_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_object_destroyed))
- , object_renamed_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_object_renamed))
- , disconnection_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_disconnection))
- , metadata_update_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_metadata_update))
- , control_change_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_control_change))
- , program_add_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_program_add))
- , program_remove_slot(sigc::mem_fun((SigClientInterface*)this, &SigClientInterface::emit_program_remove))
+ , response_slot(response_sig.make_slot())
+ , error_slot(error_sig.make_slot())
+ , new_plugin_slot(new_plugin_sig.make_slot())
+ , new_patch_slot(new_patch_sig.make_slot())
+ , new_node_slot(new_node_sig.make_slot())
+ , new_port_slot(new_port_sig.make_slot())
+ , connection_slot(connection_sig.make_slot())
+ , patch_enabled_slot(patch_enabled_sig.make_slot())
+ , patch_disabled_slot(patch_disabled_sig.make_slot())
+ , patch_cleared_slot(patch_cleared_sig.make_slot())
+ , object_destroyed_slot(object_destroyed_sig.make_slot())
+ , object_renamed_slot(object_renamed_sig.make_slot())
+ , disconnection_slot(disconnection_sig.make_slot())
+ , metadata_update_slot(metadata_update_sig.make_slot())
+ , control_change_slot(control_change_sig.make_slot())
+ , program_add_slot(program_add_sig.make_slot())
+ , program_remove_slot(program_remove_sig.make_slot())
{}
@@ -74,24 +70,12 @@ public:
void num_plugins(uint32_t num) { _num_plugins = num; }
+ void response(int32_t id, bool success, const string& msg)
+ { push_sig(sigc::bind(response_slot, id, success, msg)); }
+
void error(const string& msg)
{ push_sig(sigc::bind(error_slot, msg)); }
- /*
- void new_plugin_model(PluginModel* const pm)
- { push_sig(sigc::bind(new_plugin_slot, pm)); }
-
- void new_patch_model(PatchModel* const pm)
- { push_sig(sigc::bind(new_patch_slot, pm)); }
-
- void new_node_model(NodeModel* const nm)
- { assert(nm); push_sig(sigc::bind(new_node_slot, nm)); }
-
- void new_port_model(PortModel* const pm)
- { push_sig(sigc::bind(new_port_slot, pm)); }
- void connection_model(ConnectionModel* const cm)
- { push_sig(sigc::bind(connection_slot, cm)); }
- */
void new_plugin(const string& type, const string& uri, const string& name)
{ push_sig(sigc::bind(new_plugin_slot, type, uri, name)); }
@@ -146,30 +130,26 @@ private:
Queue<Closure> _sigs;
uint32_t _num_plugins;
- sigc::slot<void> bundle_begin_slot;
- sigc::slot<void> bundle_end_slot;
- sigc::slot<void, uint32_t> num_plugins_slot;
- sigc::slot<void, string> error_slot;
- /*sigc::slot<void, PluginModel*> new_plugin_slot;
- sigc::slot<void, PatchModel*> new_patch_slot;
- sigc::slot<void, NodeModel*> new_node_slot;
- sigc::slot<void, PortModel*> new_port_slot;
- sigc::slot<void, ConnectionModel*> connection_slot; */
- sigc::slot<void, string, string, string> new_plugin_slot;
- sigc::slot<void, string, uint32_t> new_patch_slot;
- sigc::slot<void, string, string, string, bool, int> new_node_slot;
- sigc::slot<void, string, string, bool> new_port_slot;
- sigc::slot<void, string, string> connection_slot;
- sigc::slot<void, string> patch_enabled_slot;
- sigc::slot<void, string> patch_disabled_slot;
- sigc::slot<void, string> patch_cleared_slot;
- sigc::slot<void, string> object_destroyed_slot;
- sigc::slot<void, string, string> object_renamed_slot;
- sigc::slot<void, string, string> disconnection_slot;
- sigc::slot<void, string, string, string> metadata_update_slot;
- sigc::slot<void, string, float> control_change_slot;
- sigc::slot<void, string, uint32_t, uint32_t, const string&> program_add_slot;
- sigc::slot<void, string, uint32_t, uint32_t> program_remove_slot;
+ sigc::slot<void> bundle_begin_slot;
+ sigc::slot<void> bundle_end_slot;
+ sigc::slot<void, uint32_t> num_plugins_slot;
+ sigc::slot<void, int32_t, bool, string> response_slot;
+ sigc::slot<void, string> error_slot;
+ sigc::slot<void, string, string, string> new_plugin_slot;
+ sigc::slot<void, string, uint32_t> new_patch_slot;
+ sigc::slot<void, string, string, string, bool, int> new_node_slot;
+ sigc::slot<void, string, string, bool> new_port_slot;
+ sigc::slot<void, string, string> connection_slot;
+ sigc::slot<void, string> patch_enabled_slot;
+ sigc::slot<void, string> patch_disabled_slot;
+ sigc::slot<void, string> patch_cleared_slot;
+ sigc::slot<void, string> object_destroyed_slot;
+ sigc::slot<void, string, string> object_renamed_slot;
+ sigc::slot<void, string, string> disconnection_slot;
+ sigc::slot<void, string, string, string> metadata_update_slot;
+ sigc::slot<void, string, float> control_change_slot;
+ sigc::slot<void, string, uint32_t, uint32_t, string> program_add_slot;
+ sigc::slot<void, string, uint32_t, uint32_t> program_remove_slot;
};