From cc384f6f622cc10fd83616256080b80dc2123aaf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 14 Sep 2006 02:27:02 +0000 Subject: Cleaned up client-side model code significantly (made everything private so only Store can change the state of models). Extremely broken, just committing to move code between machines :). git-svn-id: http://svn.drobilla.net/lad/ingen@133 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/NodeFactory.cpp | 12 ++++++++++++ src/libs/engine/NodeFactory.h | 4 +++- src/libs/engine/OSCEngineReceiver.cpp | 12 +++++------- src/libs/engine/QueuedEngineInterface.cpp | 13 +++++-------- src/libs/engine/QueuedEngineInterface.h | 1 - src/libs/engine/events/AddNodeEvent.cpp | 25 +++++++++++++++++++------ src/libs/engine/events/AddNodeEvent.h | 13 ++++++++++--- 7 files changed, 54 insertions(+), 26 deletions(-) (limited to 'src/libs/engine') diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp index 9ab03a73..33b1842d 100644 --- a/src/libs/engine/NodeFactory.cpp +++ b/src/libs/engine/NodeFactory.cpp @@ -92,6 +92,18 @@ NodeFactory::~NodeFactory() } +const Plugin* +NodeFactory::plugin(const string& uri) +{ + // FIXME: this needs.. well, fixing + for (list::iterator i = _plugins.begin(); i != _plugins.end(); ++i) + if ((*i)->uri() == uri) + return (*i); + + return NULL; +} + + void NodeFactory::load_plugins() { diff --git a/src/libs/engine/NodeFactory.h b/src/libs/engine/NodeFactory.h index 25408b2d..1fd6c2d4 100644 --- a/src/libs/engine/NodeFactory.h +++ b/src/libs/engine/NodeFactory.h @@ -56,6 +56,8 @@ public: const list& plugins() { return _plugins; } + const Plugin* plugin(const string& uri); + private: #ifdef HAVE_LADSPA void load_ladspa_plugins(); @@ -76,7 +78,7 @@ private: list _libraries; list _internal_plugins; - list _plugins; + list _plugins; // FIXME: make a map bool _has_loaded; }; diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index afed89fd..92ab08f0 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -88,8 +88,8 @@ OSCEngineReceiver::OSCEngineReceiver(CountedPtr engine, size_t queue_siz lo_server_add_method(_server, "/om/synth/disable_patch", "is", disable_patch_cb, this); lo_server_add_method(_server, "/om/synth/clear_patch", "is", clear_patch_cb, this); lo_server_add_method(_server, "/om/synth/create_port", "issi", create_port_cb, this); - lo_server_add_method(_server, "/om/synth/create_node", "issssi", create_node_cb, this); - lo_server_add_method(_server, "/om/synth/create_node", "isssi", create_node_by_uri_cb, this); + lo_server_add_method(_server, "/om/synth/create_node", "isssi", create_node_cb, this); + lo_server_add_method(_server, "/om/synth/create_node", "issi", create_node_by_uri_cb, this); lo_server_add_method(_server, "/om/synth/destroy", "is", destroy_cb, this); lo_server_add_method(_server, "/om/synth/rename", "iss", rename_cb, this); lo_server_add_method(_server, "/om/synth/connect", "iss", connect_cb, this); @@ -487,7 +487,6 @@ OSCEngineReceiver::m_create_port_cb(const char* path, const char* types, lo_arg* *

\b /om/synth/create_node - Add a node into a given patch (load a plugin by URI) * \arg \b response-id (integer) * \arg \b node-path (string) - Full path of the new node (ie. /patch2/subpatch/newnode) - * \arg \b type (string) - Plugin type ("Internal", "LV2", "DSSI", "LADSPA") * \arg \b plug-uri (string) - URI of the plugin to load * \arg \b poly (integer-boolean) - Whether node is polyphonic (0 = false, 1 = true)

\n \n */ @@ -495,13 +494,12 @@ int OSCEngineReceiver::m_create_node_by_uri_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { const char* node_path = &argv[1]->s; - const char* type = &argv[2]->s; - const char* plug_uri = &argv[3]->s; - const int poly = argv[4]->i; + const char* plug_uri = &argv[2]->s; + const int poly = argv[3]->i; // FIXME: make sure poly is valid - create_node(node_path, type, plug_uri, (poly == 1)); + create_node(node_path, plug_uri, (poly == 1)); return 0; } diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index b0903e29..ce56e569 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -140,17 +140,10 @@ void QueuedEngineInterface::create_port(const string& path, void QueuedEngineInterface::create_node(const string& path, - const string& plugin_type, const string& plugin_uri, bool polyphonic) { - // FIXME: ew - - Plugin* plugin = new Plugin(); - plugin->set_type(plugin_type); - plugin->uri(plugin_uri); - - push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), path, plugin, polyphonic)); + push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), path, plugin_uri, polyphonic)); } @@ -161,6 +154,9 @@ QueuedEngineInterface::create_node(const string& path, const string& plugin_label, bool polyphonic) { + cerr << "FIXME: deprecated create_node\n"; + throw; +#if 0 // FIXME: ew Plugin* plugin = new Plugin(); @@ -169,6 +165,7 @@ QueuedEngineInterface::create_node(const string& path, plugin->plug_label(plugin_label); push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), path, plugin, polyphonic)); +#endif } void diff --git a/src/libs/engine/QueuedEngineInterface.h b/src/libs/engine/QueuedEngineInterface.h index f9aaa0b4..10b120e8 100644 --- a/src/libs/engine/QueuedEngineInterface.h +++ b/src/libs/engine/QueuedEngineInterface.h @@ -89,7 +89,6 @@ public: bool direction); virtual void create_node(const string& path, - const string& plugin_type, const string& plugin_uri, bool polyphonic); diff --git a/src/libs/engine/events/AddNodeEvent.cpp b/src/libs/engine/events/AddNodeEvent.cpp index 19ff6bf5..6e42ef82 100644 --- a/src/libs/engine/events/AddNodeEvent.cpp +++ b/src/libs/engine/events/AddNodeEvent.cpp @@ -33,7 +33,7 @@ namespace Ingen { -AddNodeEvent::AddNodeEvent(Engine& engine, CountedPtr responder, SampleCount timestamp, const string& path, Plugin* plugin, bool poly) +/*AddNodeEvent::AddNodeEvent(Engine& engine, CountedPtr responder, SampleCount timestamp, const string& path, Plugin* plugin, bool poly) : QueuedEvent(engine, responder, timestamp), m_path(path), m_plugin(plugin), @@ -43,12 +43,24 @@ AddNodeEvent::AddNodeEvent(Engine& engine, CountedPtr responder, Samp m_process_order(NULL), m_node_already_exists(false) { +}*/ + +AddNodeEvent::AddNodeEvent(Engine& engine, CountedPtr responder, SampleCount timestamp, const string& path, + const string& plugin_uri, bool poly) +: QueuedEvent(engine, responder, timestamp), + m_path(path), + m_plugin_uri(plugin_uri), + m_poly(poly), + m_patch(NULL), + m_node(NULL), + m_process_order(NULL), + m_node_already_exists(false) +{ } AddNodeEvent::~AddNodeEvent() { - delete m_plugin; } @@ -62,12 +74,13 @@ AddNodeEvent::pre_process() } m_patch = _engine.object_store()->find_patch(m_path.parent()); + const Plugin* plugin = _engine.node_factory()->plugin(m_plugin_uri); - if (m_patch != NULL) { + if (m_patch && plugin) { if (m_poly) - m_node = _engine.node_factory()->load_plugin(m_plugin, m_path.name(), m_patch->internal_poly(), m_patch); + m_node = _engine.node_factory()->load_plugin(plugin, m_path.name(), m_patch->internal_poly(), m_patch); else - m_node = _engine.node_factory()->load_plugin(m_plugin, m_path.name(), 1, m_patch); + m_node = _engine.node_factory()->load_plugin(plugin, m_path.name(), 1, m_patch); if (m_node != NULL) { m_node->activate(); @@ -113,7 +126,7 @@ AddNodeEvent::post_process() } else if (m_node == NULL) { msg = "Unable to load node "; msg.append(m_path).append(" (you're missing the plugin \"").append( - m_plugin->uri()); + m_plugin_uri); _responder->respond_error(msg); } else { _responder->respond_ok(); diff --git a/src/libs/engine/events/AddNodeEvent.h b/src/libs/engine/events/AddNodeEvent.h index c7616c2b..b4345f90 100644 --- a/src/libs/engine/events/AddNodeEvent.h +++ b/src/libs/engine/events/AddNodeEvent.h @@ -39,7 +39,14 @@ class Plugin; class AddNodeEvent : public QueuedEvent { public: - AddNodeEvent(Engine& engine, CountedPtr responder, SampleCount timestamp, const string& path, Plugin* plugin, bool poly); + //AddNodeEvent(Engine& engine, CountedPtr responder, SampleCount timestamp, const string& path, Plugin* plugin, bool poly); + AddNodeEvent(Engine& engine, + CountedPtr responder, + SampleCount timestamp, + const string& node_path, + const string& plugin_uri, + bool poly); + ~AddNodeEvent(); void pre_process(); @@ -49,11 +56,11 @@ public: private: string m_patch_name; Path m_path; - Plugin* m_plugin; + string m_plugin_uri; bool m_poly; Patch* m_patch; Node* m_node; - Array* m_process_order; // Patch's new process order + Array* m_process_order; ///< Patch's new process order bool m_node_already_exists; }; -- cgit v1.2.1