summaryrefslogtreecommitdiffstats
path: root/src/progs/ingenuity
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs/ingenuity')
-rw-r--r--src/progs/ingenuity/App.cpp37
-rw-r--r--src/progs/ingenuity/App.h26
-rw-r--r--src/progs/ingenuity/Configuration.cpp6
-rw-r--r--src/progs/ingenuity/ConnectWindow.cpp139
-rw-r--r--src/progs/ingenuity/ConnectWindow.h5
-rw-r--r--src/progs/ingenuity/ControlGroups.cpp25
-rw-r--r--src/progs/ingenuity/ControlPanel.cpp11
-rw-r--r--src/progs/ingenuity/Controller.cpp175
-rw-r--r--src/progs/ingenuity/Controller.h110
-rw-r--r--src/progs/ingenuity/DSSIController.cpp10
-rw-r--r--src/progs/ingenuity/LoadPatchWindow.cpp9
-rw-r--r--src/progs/ingenuity/LoadPluginWindow.cpp4
-rw-r--r--src/progs/ingenuity/LoadSubpatchWindow.cpp5
-rw-r--r--src/progs/ingenuity/Loader.cpp15
-rw-r--r--src/progs/ingenuity/Loader.h17
-rw-r--r--src/progs/ingenuity/Makefile.am10
-rw-r--r--src/progs/ingenuity/NewSubpatchWindow.cpp5
-rw-r--r--src/progs/ingenuity/NodeController.cpp13
-rw-r--r--src/progs/ingenuity/OmFlowCanvas.cpp39
-rw-r--r--src/progs/ingenuity/OmModule.cpp7
-rw-r--r--src/progs/ingenuity/OmPortModule.cpp7
-rw-r--r--src/progs/ingenuity/PatchController.cpp29
-rw-r--r--src/progs/ingenuity/PatchTreeWindow.cpp11
-rw-r--r--src/progs/ingenuity/PatchView.cpp6
-rw-r--r--src/progs/ingenuity/PatchWindow.cpp15
-rw-r--r--src/progs/ingenuity/PortController.cpp4
-rw-r--r--src/progs/ingenuity/RenameWindow.cpp4
-rw-r--r--src/progs/ingenuity/SubpatchModule.cpp5
-rw-r--r--src/progs/ingenuity/main.cpp34
29 files changed, 295 insertions, 488 deletions
diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp
index 1a7d7760..ecf94a92 100644
--- a/src/progs/ingenuity/App.cpp
+++ b/src/progs/ingenuity/App.cpp
@@ -35,7 +35,6 @@
#include "PatchWindow.h"
#include "MessagesWindow.h"
#include "ConfigWindow.h"
-#include "Controller.h"
#include "GladeFactory.h"
#include "util/Path.h"
#include "ObjectModel.h"
@@ -44,6 +43,7 @@
#include "Configuration.h"
#include "ConnectWindow.h"
#include "Store.h"
+#include "Loader.h"
#ifdef HAVE_LASH
#include "LashController.h"
#endif
@@ -61,9 +61,9 @@ class OmPort;
App* App::_instance = 0;
-App::App(CountedPtr<SigClientInterface> listener)
-: _listener(listener),
- _store(new Store(listener)),
+App::App()
+: _store(NULL),
+ _loader(NULL),
_configuration(new Configuration()),
_about_dialog(NULL),
_enable_signal(true)
@@ -71,16 +71,13 @@ App::App(CountedPtr<SigClientInterface> listener)
Glib::RefPtr<Gnome::Glade::Xml> glade_xml = GladeFactory::new_glade_reference();
glade_xml->get_widget_derived("connect_win", _connect_window);
- //glade_xml->get_widget_derived("new_patch_win", _new_patch_window);
- //glade_xml->get_widget_derived("load_patch_win", _load_patch_window);
- glade_xml->get_widget_derived("config_win", _config_window);
+ glade_xml->get_widget_derived("messages_win", _messages_window);
glade_xml->get_widget_derived("patch_tree_win", _patch_tree_window);
-// glade_xml->get_widget_derived("main_patches_treeview", _objects_treeview);
+ glade_xml->get_widget_derived("config_win", _config_window);
glade_xml->get_widget("about_win", _about_dialog);
+
_config_window->configuration(_configuration);
-
- glade_xml->get_widget_derived("messages_win", _messages_window);
}
@@ -89,12 +86,28 @@ App::~App()
}
void
-App::instantiate(CountedPtr<SigClientInterface>& listener)
+App::instantiate()
{
if (!_instance)
- _instance = new App(listener);
+ _instance = new App();
}
+
+void
+App::attach(CountedPtr<ModelEngineInterface>& engine, CountedPtr<SigClientInterface>& client)
+{
+ assert( ! _engine);
+ assert( ! _client);
+ assert( ! _store);
+ assert( ! _loader);
+
+ _engine = engine;
+ _client = client;
+ _store = new Store(client);
+ _loader = new Loader(engine);
+}
+
+
void
App::error_message(const string& str)
{
diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h
index 2d56e445..06d52ca3 100644
--- a/src/progs/ingenuity/App.h
+++ b/src/progs/ingenuity/App.h
@@ -34,6 +34,7 @@ namespace Ingen { namespace Client {
class PluginModel;
class Store;
class SigClientInterface;
+ class ModelEngineInterface;
} }
using namespace Ingen::Client;
@@ -59,6 +60,7 @@ class PatchTreeView;
class PatchTreeWindow;
class ConnectWindow;
class Configuration;
+class Loader;
/** Singleton master class most everything is contained within.
@@ -81,7 +83,9 @@ public:
void add_patch_window(PatchWindow* pw);
void remove_patch_window(PatchWindow* pw);
- int num_open_patch_windows();
+ int num_open_patch_windows();
+
+ void attach(CountedPtr<ModelEngineInterface>& engine, CountedPtr<SigClientInterface>& client);
ConnectWindow* connect_window() const { return _connect_window; }
Gtk::Dialog* about_dialog() const { return _about_dialog; }
@@ -90,22 +94,23 @@ public:
PatchTreeWindow* patch_tree() const { return _patch_tree_window; }
Configuration* configuration() const { return _configuration; }
Store* store() const { return _store; }
+ Loader* loader() const { return _loader; }
- const CountedPtr<SigClientInterface>& client() const { return _listener; }
-
- static void instantiate(CountedPtr<SigClientInterface>& listener);
+ const CountedPtr<ModelEngineInterface>& engine() const { return _engine; }
+ const CountedPtr<SigClientInterface>& client() const { return _client; }
static inline App& instance() { assert(_instance); return *_instance; }
+ static void instantiate();
protected:
- App(CountedPtr<SigClientInterface> listener);
+ App();
static App* _instance;
- //bool connect_callback();
- //bool idle_callback();
-
- CountedPtr<SigClientInterface> _listener;
- Store* _store;
+ CountedPtr<ModelEngineInterface> _engine;
+ CountedPtr<SigClientInterface> _client;
+
+ Store* _store;
+ Loader* _loader;
Configuration* _configuration;
@@ -116,7 +121,6 @@ protected:
PatchTreeWindow* _patch_tree_window;
ConfigWindow* _config_window;
Gtk::Dialog* _about_dialog;
- Gtk::Button* _engine_error_close_button;
/** Used to avoid feedback loops with (eg) process checkbutton
* FIXME: Maybe this should be globally implemented at the Controller level,
diff --git a/src/progs/ingenuity/Configuration.cpp b/src/progs/ingenuity/Configuration.cpp
index 4cb473cb..e383cf87 100644
--- a/src/progs/ingenuity/Configuration.cpp
+++ b/src/progs/ingenuity/Configuration.cpp
@@ -25,7 +25,8 @@
#include "PatchController.h"
#include "PatchModel.h"
#include "OmFlowCanvas.h"
-#include "Controller.h"
+#include "Loader.h"
+#include "App.h"
using std::cerr; using std::cout; using std::endl;
using std::map; using std::string;
@@ -131,7 +132,8 @@ Configuration::save_settings(string filename)
void
Configuration::apply_settings()
{
- Controller::instance().set_patch_path(m_patch_path);
+ cerr << "FIXME: patch path" << endl;
+ //App::instance().loader()->set_patch_path(m_patch_path);
}
diff --git a/src/progs/ingenuity/ConnectWindow.cpp b/src/progs/ingenuity/ConnectWindow.cpp
index d4027e20..16b2adea 100644
--- a/src/progs/ingenuity/ConnectWindow.cpp
+++ b/src/progs/ingenuity/ConnectWindow.cpp
@@ -14,26 +14,62 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "ConnectWindow.h"
#include <string>
#include <time.h>
#include <sys/time.h>
#include <stdlib.h>
+#include "config.h"
+#include "ConnectWindow.h"
#include "interface/ClientKey.h"
+#include "OSCModelEngineInterface.h"
+#include "OSCClientReceiver.h"
#include "ThreadedSigClientInterface.h"
-#include "Controller.h"
#include "Store.h"
#include "PatchController.h"
#include "PatchModel.h"
#include "App.h"
+#ifdef MONOLITHIC_INGENUITY
+ #include "engine/QueuedEngineInterface.h"
+ #include "engine/Engine.h"
+ #include "engine/DirectResponder.h"
+ #include "engine/tuning.h"
+#endif
using Ingen::Client::ThreadedSigClientInterface;
+using Ingen::QueuedEngineInterface;
namespace Ingenuity {
+// Paste together some interfaces to get the combination we want
+
+
+struct OSCSigEmitter : public OSCClientReceiver, public ThreadedSigClientInterface {
+public:
+ OSCSigEmitter(size_t queue_size, int listen_port)
+ : Ingen::Shared::ClientInterface()
+ , OSCClientReceiver(listen_port)
+ , ThreadedSigClientInterface(queue_size)
+ {
+ }
+};
+
+
+struct QueuedModelEngineInterface : public QueuedEngineInterface, public ModelEngineInterface {
+ QueuedModelEngineInterface(CountedPtr<Ingen::Engine> engine)
+ : Ingen::Shared::EngineInterface()
+ , Ingen::QueuedEngineInterface(engine, Ingen::event_queue_size, Ingen::event_queue_size)
+ {
+ QueuedEventSource::start();
+ }
+};
+
+
+// ConnectWindow
+
+
ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml)
: Gtk::Dialog(cobject)
-, _client(NULL)
+, _mode(CONNECT_REMOTE)
, _ping_id(-1)
, _attached(false)
{
@@ -61,9 +97,8 @@ ConnectWindow::ConnectWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::
void
ConnectWindow::start()
{
- _client = App::instance().client();
- assert(_client);
resize(100, 100);
+ init();
show();
}
@@ -78,38 +113,82 @@ ConnectWindow::init()
_disconnect_button->set_sensitive(false);
_port_spinbutton->set_sensitive(false);
_launch_radio->set_sensitive(true);
+#ifdef MONOLITHIC_INGENUITY
+ _internal_radio->set_sensitive(true);
+#else
_internal_radio->set_sensitive(false);
+#endif
server_toggled();
_progress_label->set_text(string("Disconnected"));
}
+/** Launch (if applicable) and connect to the Engine.
+ *
+ * This will create the EngineInterface and ClientInterface and initialize
+ * the App with them.
+ */
void
ConnectWindow::connect()
{
+ assert(!_attached);
+ assert(!App::instance().engine());
+ assert(!App::instance().client());
+
_connect_button->set_sensitive(false);
- if (_server_radio->get_active()) {
- Controller::instance().set_engine_url(_url_entry->get_text());
+ if (_mode == CONNECT_REMOTE) {
+ CountedPtr<ModelEngineInterface> engine(new OSCModelEngineInterface(_url_entry->get_text()));
+ OSCSigEmitter* ose = new OSCSigEmitter(1024, 16181); // FIXME: args
+ CountedPtr<SigClientInterface> client(ose);
+ App::instance().attach(engine, client);
+
Glib::signal_timeout().connect(
sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(ose, &ThreadedSigClientInterface::emit_signals), 2, G_PRIORITY_HIGH_IDLE);
- } else if (_launch_radio->get_active()) {
+ } else if (_mode == LAUNCH_REMOTE) {
+ /*
int port = _port_spinbutton->get_value_as_int();
char port_str[6];
snprintf(port_str, 6, "%u", port);
const string port_arg = string("--port=").append(port_str);
- Controller::instance().set_engine_url(
+ App::instance().engine()->set_engine_url(
string("osc.udp://localhost:").append(port_str));
if (fork() == 0) { // child
- cerr << "Executing 'om " << port_arg << "' ..." << endl;
- execlp("om", port_arg.c_str(), 0);
+ cerr << "Executing 'ingen " << port_arg << "' ..." << endl;
+ execlp("ingen", port_arg.c_str(), (char*)NULL);
} else {
Glib::signal_timeout().connect(
sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100);
- }
+ }*/
+ throw;
+#ifdef MONOLITHIC_INGENUITY
+ } else if (_mode == INTERNAL) {
+ CountedPtr<Ingen::Engine> engine(new Ingen::Engine());
+ QueuedModelEngineInterface* qmei = new QueuedModelEngineInterface(engine);
+ CountedPtr<ModelEngineInterface> engine_interface(qmei);
+ ThreadedSigClientInterface* tsci = new ThreadedSigClientInterface(Ingen::event_queue_size);
+ CountedPtr<SigClientInterface> client(tsci);
+
+ App::instance().attach(engine_interface, client);
+
+ qmei->set_responder(CountedPtr<Ingen::Responder>(new Ingen::DirectResponder(client, 1)));
+ engine->set_event_source(qmei);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(engine.get(), &Ingen::Engine::main_iteration), 1000);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(this, &ConnectWindow::gtk_callback), 100);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(tsci, &ThreadedSigClientInterface::emit_signals), 2, G_PRIORITY_HIGH_IDLE);
+#endif
}
}
@@ -152,6 +231,7 @@ ConnectWindow::server_toggled()
{
_url_entry->set_sensitive(true);
_port_spinbutton->set_sensitive(false);
+ _mode = CONNECT_REMOTE;
}
@@ -160,15 +240,16 @@ ConnectWindow::launch_toggled()
{
_url_entry->set_sensitive(false);
_port_spinbutton->set_sensitive(true);
+ _mode = LAUNCH_REMOTE;
}
void
ConnectWindow::internal_toggled()
{
- // Not quite yet...
_url_entry->set_sensitive(false);
_port_spinbutton->set_sensitive(false);
+ _mode = INTERNAL;
}
@@ -188,44 +269,47 @@ ConnectWindow::gtk_callback()
/* Connecting to engine */
if (stage == 0) {
+
assert(!_attached);
- assert(_client);
+ assert(App::instance().engine());
+ assert(App::instance().client());
// FIXME
- //assert(!Controller::instance().is_attached());
- _progress_label->set_text(string("Connecting to engine at ").append(
- Controller::instance().engine_url()).append("..."));
+ //assert(!App::instance().engine()->is_attached());
+ _progress_label->set_text("Connecting to engine...");
present();
- _client->response_sig.connect(sigc::mem_fun(this, &ConnectWindow::response_received));
+ App::instance().client()->response_sig.connect(sigc::mem_fun(this, &ConnectWindow::response_received));
_ping_id = rand();
while (_ping_id == -1)
_ping_id = rand();
- Controller::instance().attach(_ping_id);
+ App::instance().engine()->set_next_response_id(_ping_id);
+ App::instance().engine()->ping();
++stage;
} else if (stage == 1) {
if (_attached) {
- Controller::instance().activate();
+ App::instance().engine()->activate();
++stage;
} else {
const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f +
(now.tv_usec - last.tv_usec) * 0.001f;
if (ms_since_last > 1000) {
- Controller::instance().attach(_ping_id);
+ App::instance().engine()->set_next_response_id(_ping_id);
+ App::instance().engine()->ping();
last = now;
}
}
} else if (stage == 2) {
_progress_label->set_text(string("Registering as client..."));
- //Controller::instance().register_client(Controller::instance().client_hooks());
+ //App::instance().engine()->register_client(App::instance().engine()->client_hooks());
// FIXME
//auto_ptr<ClientInterface> client(new ThreadedSigClientInterface();
- Controller::instance().register_client(ClientKey(), _client);
- Controller::instance().load_plugins();
+ App::instance().engine()->register_client(ClientKey(), App::instance().client());
+ App::instance().engine()->load_plugins();
++stage;
} else if (stage == 3) {
// Register idle callback to process events and whatnot
@@ -238,7 +322,7 @@ ConnectWindow::gtk_callback()
5, G_PRIORITY_DEFAULT_IDLE);*/
_progress_label->set_text(string("Requesting plugins..."));
- Controller::instance().request_plugins();
+ App::instance().engine()->request_plugins();
++stage;
} else if (stage == 4) {
// Wait for first plugins message
@@ -261,7 +345,7 @@ ConnectWindow::gtk_callback()
//}
} else if (stage == 6) {
_progress_label->set_text(string("Waiting for root patch..."));
- Controller::instance().request_all_objects();
+ App::instance().engine()->request_all_objects();
++stage;
} else if (stage == 7) {
if (App::instance().store()->num_objects() > 0) {
@@ -272,8 +356,7 @@ ConnectWindow::gtk_callback()
++stage;
}
} else if (stage == 8) {
- _progress_label->set_text(string("Connected to engine at ").append(
- Controller::instance().engine_url()));
+ _progress_label->set_text("Connected to engine");
++stage;
} else if (stage == 9) {
stage = -1;
diff --git a/src/progs/ingenuity/ConnectWindow.h b/src/progs/ingenuity/ConnectWindow.h
index fba6b9d8..d74f6032 100644
--- a/src/progs/ingenuity/ConnectWindow.h
+++ b/src/progs/ingenuity/ConnectWindow.h
@@ -46,6 +46,8 @@ public:
void response_received(int32_t id, bool, string) { if ((id) == _ping_id) _attached = true; }
private:
+ enum Mode { CONNECT_REMOTE, LAUNCH_REMOTE, INTERNAL };
+
void server_toggled();
void launch_toggled();
void internal_toggled();
@@ -57,8 +59,7 @@ private:
bool gtk_callback();
- CountedPtr<SigClientInterface> _client;
-
+ Mode _mode;
int32_t _ping_id;
bool _attached;
diff --git a/src/progs/ingenuity/ControlGroups.cpp b/src/progs/ingenuity/ControlGroups.cpp
index 7c84d898..93a1cb5b 100644
--- a/src/progs/ingenuity/ControlGroups.cpp
+++ b/src/progs/ingenuity/ControlGroups.cpp
@@ -14,12 +14,14 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <cmath>
+#include <iostream>
+#include "ModelEngineInterface.h"
#include "ControlGroups.h"
#include "ControlPanel.h"
#include "PortModel.h"
-#include "Controller.h"
-#include <cmath>
-#include <iostream>
+#include "App.h"
+
using std::cerr; using std::cout; using std::endl;
using namespace Ingen::Client;
@@ -53,9 +55,10 @@ ControlGroup::ControlGroup(ControlPanel* panel, CountedPtr<PortModel> pm, bool s
void
ControlGroup::metadata_update(const string& key, const string& value)
{
- if (key == "user-min")
+ // FIXME: this isn't right
+ if (key == "user-min" || key == "min")
set_min(atof(value.c_str()));
- else if (key == "user-max")
+ else if (key == "user-max" || key == "max")
set_max(atof(value.c_str()));
}
@@ -79,10 +82,12 @@ SliderControlGroup::SliderControlGroup(ControlPanel* panel, CountedPtr<PortModel
m_slider.set_increments(1.0, 10.0);
// Compensate for crazy plugins
+ // FIXME
+ /*
if (m_port_model->user_max() <= m_port_model->user_min()) {
m_port_model->user_max(m_port_model->user_min() + 1.0);
m_slider.set_range(m_port_model->user_min(), m_port_model->user_max());
- }
+ }*/
m_slider.property_draw_value() = false;
set_name(pm->name());
@@ -205,7 +210,7 @@ SliderControlGroup::min_changed()
if (m_enable_signal) {
char temp_buf[16];
snprintf(temp_buf, 16, "%f", min);
- Controller::instance().set_metadata(m_port_model->path(), "user-min", temp_buf);
+ App::instance().engine()->set_metadata(m_port_model->path(), "user-min", temp_buf);
}
}
@@ -226,7 +231,7 @@ SliderControlGroup::max_changed()
if (m_enable_signal) {
char temp_buf[16];
snprintf(temp_buf, 16, "%f", max);
- Controller::instance().set_metadata(m_port_model->path(), "user-max", temp_buf);
+ App::instance().engine()->set_metadata(m_port_model->path(), "user-max", temp_buf);
}
}
@@ -281,11 +286,11 @@ SliderControlGroup::slider_pressed(GdkEvent* ev)
//cerr << "Pressed: " << ev->type << endl;
if (ev->type == GDK_BUTTON_PRESS) {
m_enabled = false;
- cerr << "SLIDER FIXME\n";
+ //cerr << "SLIDER FIXME\n";
//GtkClientInterface::instance()->set_ignore_port(m_port_model->path());
} else if (ev->type == GDK_BUTTON_RELEASE) {
m_enabled = true;
- cerr << "SLIDER FIXME\n";
+ //cerr << "SLIDER FIXME\n";
//GtkClientInterface::instance()->clear_ignore_port();
}
diff --git a/src/progs/ingenuity/ControlPanel.cpp b/src/progs/ingenuity/ControlPanel.cpp
index 82d2beba..0841a818 100644
--- a/src/progs/ingenuity/ControlPanel.cpp
+++ b/src/progs/ingenuity/ControlPanel.cpp
@@ -14,13 +14,14 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "ControlPanel.h"
#include "PatchModel.h"
#include "NodeModel.h"
#include "PortModel.h"
#include "ControlGroups.h"
#include "PatchController.h"
-#include "Controller.h"
namespace Ingenuity {
@@ -124,6 +125,10 @@ ControlPanel::add_port(PortController* port)
cg->disable();
else
cg->enable();
+
+ cerr << "FIXME: Control panel add port\n";
+ // pm->connection_sig.connect(bind(sigc::mem_fun(this, &ControlPanel::connection), pm))
+ // pm->disconnection_sig.connect(bind(sigc::mem_fun(this, &ControlPanel::disconnection), pm))
}
//port->set_control_panel(this);
@@ -223,10 +228,10 @@ ControlPanel::value_changed(const Path& port_path, float val)
// m_mirror->set_port_value(port_path, val);
if (m_all_voices_radio->get_active()) {
- Controller::instance().set_port_value(port_path, val);
+ App::instance().engine()->set_port_value(port_path, val);
} else {
int voice = m_voice_spinbutton->get_value_as_int();
- Controller::instance().set_port_value(port_path, voice, val);
+ App::instance().engine()->set_port_value(port_path, voice, val);
}
}
}
diff --git a/src/progs/ingenuity/Controller.cpp b/src/progs/ingenuity/Controller.cpp
deleted file mode 100644
index a007ece8..00000000
--- a/src/progs/ingenuity/Controller.cpp
+++ /dev/null
@@ -1,175 +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 "PatchModel.h"
-#include "PatchController.h"
-#include "OSCModelEngineInterface.h"
-#include "PatchLibrarian.h"
-#include "Controller.h"
-#include "Loader.h"
-#include "interface/ClientKey.h"
-
-namespace Ingenuity {
-
-
-/// Singleton instance
-Controller* Controller::_instance = 0;
-
-
-Controller::Controller(const string& engine_url)
-: OSCModelEngineInterface(engine_url),
- m_patch_librarian(new PatchLibrarian(this)),
- m_loader(new Loader(m_patch_librarian))
-{
- m_loader->launch();
-}
-
-
-Controller::~Controller()
-{
- // FIXME
- //if (is_attached()) {
- unregister_client(ClientKey()); // FIXME
- //detach();
- //}
-
- delete m_loader;
- delete m_patch_librarian;
-}
-
-
-/** "Attach" to the Om engine.
- * See documentation OSCModelEngineInterface::attach.
- */
-void
-Controller::attach(int32_t ping_id)
-{
- OSCModelEngineInterface::attach(ping_id, false);
-}
-
-/*
-void
-Controller::register_client_and_wait()
-{
-// int id = get_next_request_id();
-// set_wait_response_id(id);
- OSCModelEngineInterface::register_client();
-// wait_for_response();
- cout << "[Controller] Registered with engine. maybe. fixme." << endl;
-}
-*/
-void Controller::set_engine_url(const string& url) { _engine_url = url; }
-
-void
-Controller::create_node_from_model(const NodeModel* nm)
-{
- //push_added_node(nm);
- OSCModelEngineInterface::create_node_from_model(nm);
- char temp_buf[16];
- snprintf(temp_buf, 16, "%f", nm->x());
- set_metadata(nm->path(), "module-x", temp_buf);
- snprintf(temp_buf, 16, "%f", nm->y());
- set_metadata(nm->path(), "module-y", temp_buf);
-}
-
-void
-Controller::create_patch_from_model(const PatchModel* pm)
-{
- //push_added_patch(pm);
-
- //int id = get_next_request_id();
- //set_wait_response_id(id);
- OSCModelEngineInterface::create_patch_from_model(pm);
- if (pm->parent()) {
- // wait_for_response();
- char temp_buf[16];
- snprintf(temp_buf, 16, "%f", pm->x());
- set_metadata(pm->path(), "module-x", temp_buf);
- snprintf(temp_buf, 16, "%f", pm->y());
- set_metadata(pm->path(), "module-y", temp_buf);
- }
- enable_patch(pm->path());
-}
-
-
-void
-Controller::set_patch_path(const string& path)
-{
- m_patch_librarian->path(path);
-}
-
-
-/** Load patch in a seperate thread.
- * This will return immediately and the patch will be loaded in the background.
- * FIXME: merge parameter makes no sense, always true */
-void
-Controller::load_patch(PatchModel* model, bool wait, bool merge)
-{
- //push_added_patch(model);
- m_loader->load_patch(model, wait, merge);
-}
-
-
-/** Load patch in a seperate thread.
- * This will return immediately and the patch will be saved in the background. */
-void
-Controller::save_patch(PatchModel* model, const string& filename, bool recursive)
-{
- m_loader->save_patch(model, filename, recursive);
-}
-
-
-#if 0
-/** Returns the added node with the given path and removes it from the cache.
- */
-NodeModel*
-Controller::yank_added_node(const string& path)
-{
- NodeModel* nm = NULL;
-
- for (list<NodeModel*>::iterator i = m_added_nodes.begin(); i != m_added_nodes.end(); ++i) {
- if ((*i)->path() == path) {
- nm = *i;
- m_added_nodes.erase(i);
- break;
- }
- }
-
- return nm;
-}
-
-
-/** Returns the added patch with the given path and removes it from the cache.
- */
-PatchModel*
-Controller::yank_added_patch(const string& path)
-{
- PatchModel* pm = NULL;
-
- for (list<PatchModel*>::iterator i = m_added_patches.begin(); i != m_added_patches.end(); ++i) {
- if ((*i)->path() == path) {
- pm = *i;
- m_added_patches.erase(i);
- break;
- }
- }
-
- return pm;
-}
-#endif
-
-} // namespace Ingenuity
-
diff --git a/src/progs/ingenuity/Controller.h b/src/progs/ingenuity/Controller.h
deleted file mode 100644
index 6a855758..00000000
--- a/src/progs/ingenuity/Controller.h
+++ /dev/null
@@ -1,110 +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
- */
-
-#ifndef CONTROLLER_H
-#define CONTROLLER_H
-
-#include <cassert>
-#include <string>
-#include <list>
-#include <glibmm.h>
-#include "PluginModel.h"
-#include "OSCModelEngineInterface.h"
-
-namespace Ingen { namespace Client {
-class PatchModel;
-class NodeModel;
-class PatchLibrarian;
-} }
-
-using std::string; using std::list;
-using namespace Ingen::Client;
-
-namespace Ingenuity {
-
-class PatchController;
-class Loader;
-
-
-/** Singleton engine controller for the entire app.
- *
- * This is hardly more than a trivial wrapper for OSCModelEngineInterface, suggesting something
- * needs a rethink around here..
- *
- * This needs to be either eliminated or the name changed to OmController. Probably
- * best to keep around in case multiple engine control support comes around?
- *
- * \ingroup Ingenuity
- */
-class Controller : public OSCModelEngineInterface
-{
-public:
- ~Controller();
-
- void attach(int32_t ping_id);
-
- //void register_client_and_wait();
-
- void set_engine_url(const string& url);
-
- void create_node_from_model(const NodeModel* nm);
-
- void load_patch(PatchModel* model, bool wait = true, bool merge = false);
- void save_patch(PatchModel* model, const string& filename, bool recursive);
-
- void create_patch_from_model(const PatchModel* pm);
-
- //void lash_restore_finished();
-
- void set_patch_path(const string& path);
-
- /*
- void push_added_node(NodeModel* nm) { m_added_nodes.push_back(nm); }
- NodeModel* yank_added_node(const string& path);
-
- void push_added_patch(PatchModel* pm) { m_added_patches.push_back(pm); }
- PatchModel* yank_added_patch(const string& path);
- */
-
- static void instantiate(const string& engine_url)
- { if (!_instance) _instance = new Controller(engine_url); }
-
- inline static Controller& instance() { assert(_instance); return *_instance; }
-
-private:
- Controller(const string& engine_url);
- static Controller* _instance;
-
- PatchLibrarian* m_patch_librarian;
- Loader* m_loader;
-
- /** Used to cache added nodes so client can remember some values when the
- * new node notification comes (location, etc). Used to prevent the node
- * jumping locations during the delay between new node and the module-x/y
- * metadata notifications */
- //list<NodeModel*> m_added_nodes;
-
- /** Used to cache added patches in the same was as m_added_nodes. Used to
- * rember filename so File->Save can work without prompting (filename can't
- * be sent to the server as metadata, because a client on another machine
- * doesn't want that information) */
- //list<PatchModel*> m_added_patches;
-};
-
-
-} // namespace Ingenuity
-
-#endif // CONTROLLER_H
diff --git a/src/progs/ingenuity/DSSIController.cpp b/src/progs/ingenuity/DSSIController.cpp
index 7419f8c1..6bc75c70 100644
--- a/src/progs/ingenuity/DSSIController.cpp
+++ b/src/progs/ingenuity/DSSIController.cpp
@@ -20,9 +20,10 @@
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
+#include "App.h"
#include "NodeModel.h"
#include "DSSIModule.h"
-#include "Controller.h"
+#include "ModelEngineInterface.h"
namespace Ingenuity {
@@ -115,7 +116,7 @@ DSSIController::update_program_menu()
void
DSSIController::send_program_change(int bank, int program)
{
- Controller::instance().set_program(node_model()->path(), bank, program);
+ App::instance().engine()->set_program(node_model()->path(), bank, program);
}
@@ -142,12 +143,14 @@ DSSIController::create_module(OmFlowCanvas* canvas)
bool
DSSIController::attempt_to_show_gui()
{
+ cerr << "FIXME: DSSI GUI" << endl;
+#if 0
// Shamelessley "inspired by" jack-dssi-host
// Copyright 2004 Chris Cannam, Steve Harris and Sean Bolton.
const bool verbose = false;
- string engine_url = Controller::instance().engine_url();
+ string engine_url = App::instance().engine()->engine_url();
// Hack off last character if it's a /
if (engine_url[engine_url.length()-1] == '/')
engine_url = engine_url.substr(0, engine_url.length()-1);
@@ -263,6 +266,7 @@ DSSIController::attempt_to_show_gui()
free(subpath);
free(dllBase);
+#endif
return false;
}
diff --git a/src/progs/ingenuity/LoadPatchWindow.cpp b/src/progs/ingenuity/LoadPatchWindow.cpp
index 81726f2a..a847e0fd 100644
--- a/src/progs/ingenuity/LoadPatchWindow.cpp
+++ b/src/progs/ingenuity/LoadPatchWindow.cpp
@@ -21,7 +21,8 @@
#include "Configuration.h"
#include "PatchController.h"
#include "PatchModel.h"
-#include "Controller.h"
+#include "ModelEngineInterface.h"
+#include "Loader.h"
namespace Ingenuity {
@@ -108,14 +109,14 @@ LoadPatchWindow::ok_clicked()
poly = m_poly_spinbutton->get_value_as_int();
if (m_replace)
- Controller::instance().clear_patch(m_patch_controller->model()->path());
+ App::instance().engine()->clear_patch(m_patch_controller->model()->path());
PatchModel* pm = new PatchModel(m_patch_controller->model()->path(), poly);
pm->filename(get_filename());
pm->set_metadata("filename", get_filename());
pm->set_parent(m_patch_controller->patch_model()->parent());
- //Controller::instance().push_added_patch(pm);
- Controller::instance().load_patch(pm, true, true);
+ //App::instance().engine()->push_added_patch(pm);
+ App::instance().loader()->load_patch(pm, true, true);
hide();
}
diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp
index 99fd4704..b6c2ca67 100644
--- a/src/progs/ingenuity/LoadPluginWindow.cpp
+++ b/src/progs/ingenuity/LoadPluginWindow.cpp
@@ -22,12 +22,12 @@
#include "PatchController.h"
#include "PatchView.h"
#include "NodeModel.h"
-#include "Controller.h"
#include "App.h"
#include "PatchWindow.h"
#include "OmFlowCanvas.h"
#include "PatchModel.h"
#include "Store.h"
+#include "ModelEngineInterface.h"
using std::cout; using std::cerr; using std::endl;
@@ -294,7 +294,7 @@ LoadPluginWindow::add_clicked()
nm->x(m_new_module_x);
nm->y(m_new_module_y);
- Controller::instance().create_node_from_model(nm);
+ App::instance().engine()->create_node_from_model(nm);
++m_plugin_name_offset;
m_node_name_entry->set_text(generate_module_name(m_plugin_name_offset));
diff --git a/src/progs/ingenuity/LoadSubpatchWindow.cpp b/src/progs/ingenuity/LoadSubpatchWindow.cpp
index 0ec98771..832c917f 100644
--- a/src/progs/ingenuity/LoadSubpatchWindow.cpp
+++ b/src/progs/ingenuity/LoadSubpatchWindow.cpp
@@ -23,9 +23,10 @@
#include "PatchView.h"
#include "OmFlowCanvas.h"
#include "NodeModel.h"
-#include "Controller.h"
#include "PatchModel.h"
#include "Configuration.h"
+#include "ModelEngineInterface.h"
+#include "Loader.h"
namespace Ingenuity {
@@ -163,7 +164,7 @@ LoadSubpatchWindow::ok_clicked()
pm->set_metadata("module-x", temp_buf);
snprintf(temp_buf, 16, "%16f", m_new_module_y);
pm->set_metadata("module-y", temp_buf);
- Controller::instance().load_patch(pm);
+ App::instance().loader()->load_patch(pm, true, false);
App::instance().configuration()->set_patch_folder(pm->filename().substr(0, pm->filename().find_last_of("/")));
diff --git a/src/progs/ingenuity/Loader.cpp b/src/progs/ingenuity/Loader.cpp
index 13a4e896..fed49603 100644
--- a/src/progs/ingenuity/Loader.cpp
+++ b/src/progs/ingenuity/Loader.cpp
@@ -140,14 +140,25 @@ SaveSessionEvent::execute()
//////// Loader //////////
-Loader::Loader(PatchLibrarian* const patch_librarian)
-: m_patch_librarian(patch_librarian),
+Loader::Loader(CountedPtr<ModelEngineInterface> engine)
+: m_patch_librarian(new PatchLibrarian(engine)),
m_event(NULL),
m_thread_exit_flag(false)
{
assert(m_patch_librarian != NULL);
pthread_mutex_init(&m_mutex, NULL);
pthread_cond_init(&m_cond, NULL);
+
+ // FIXME: rework this so the thread is only present when it's doing something (save mem)
+ launch();
+}
+
+
+Loader::~Loader()
+{
+ m_thread_exit_flag = true;
+ pthread_join(m_thread, NULL);
+ delete m_patch_librarian;
}
diff --git a/src/progs/ingenuity/Loader.h b/src/progs/ingenuity/Loader.h
index df9166d2..7ff6f189 100644
--- a/src/progs/ingenuity/Loader.h
+++ b/src/progs/ingenuity/Loader.h
@@ -19,18 +19,19 @@
#include <string>
#include <cassert>
+#include "ModelEngineInterface.h"
using std::string;
namespace Ingen { namespace Client {
class PatchLibrarian;
class PatchModel;
+ class ModelEngineInterface;
} }
-using Ingen::Client::PatchLibrarian;
-using Ingen::Client::PatchModel;
-
+using namespace Ingen::Client;
namespace Ingenuity {
-
+
+
/** Event to run in the Loader thread.
*
* \ingroup Ingenuity
@@ -113,15 +114,17 @@ private:
*
* This is a seperate thread so it can send all the loading message without
* blocking everything else, so the app can respond to the incoming events
- * caused as a result of the patch loading.
+ * caused as a result of the patch loading, while the patch loads.
*
* \ingroup Ingenuity
*/
class Loader
{
public:
- Loader(PatchLibrarian* const patch_librarian);
- ~Loader() { m_thread_exit_flag = true; }
+ Loader(CountedPtr<ModelEngineInterface> engine);
+ ~Loader();
+
+ PatchLibrarian& librarian() { return *m_patch_librarian; }
void launch();
void exit() { m_thread_exit_flag = true; }
diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am
index aa04d3fb..a014286c 100644
--- a/src/progs/ingenuity/Makefile.am
+++ b/src/progs/ingenuity/Makefile.am
@@ -6,10 +6,16 @@ MAINTAINERCLEANFILES = Makefile.in
sharefilesdir = $(pkgdatadir)
dist_sharefiles_DATA = ingenuity.glade om-icon.png
-AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ -DWITH_RTTI
+AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@
ingenuity_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libomclient.la
ingenuity_DEPENDENCIES = ../../libs/client/libomclient.la
+# FIXME: make engine have a separate include dir
+if MONOLITHIC_INGENUITY
+AM_CXXFLAGS += -I$(top_srcdir)/src/libs
+ingenuity_LDADD += @JACK_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libingen.la
+ingenuity_DEPENDENCIES += ../../libs/engine/libingen.la
+endif
bin_PROGRAMS = ingenuity
ingenuity_SOURCES = \
@@ -24,8 +30,6 @@ ingenuity_SOURCES = \
Configuration.cpp \
GladeFactory.h \
GladeFactory.cpp \
- Controller.h \
- Controller.cpp \
GtkObjectController.h \
GtkObjectController.cpp \
PatchController.h \
diff --git a/src/progs/ingenuity/NewSubpatchWindow.cpp b/src/progs/ingenuity/NewSubpatchWindow.cpp
index 84f9bb7f..49122a21 100644
--- a/src/progs/ingenuity/NewSubpatchWindow.cpp
+++ b/src/progs/ingenuity/NewSubpatchWindow.cpp
@@ -14,12 +14,13 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "NewSubpatchWindow.h"
#include "PatchController.h"
#include "PatchView.h"
#include "OmFlowCanvas.h"
#include "NodeModel.h"
-#include "Controller.h"
#include "PatchModel.h"
namespace Ingenuity {
@@ -98,7 +99,7 @@ NewSubpatchWindow::ok_clicked()
pm->set_metadata("module-x", temp_buf);
snprintf(temp_buf, 16, "%16f", m_new_module_y);
pm->set_metadata("module-y", temp_buf);
- Controller::instance().create_patch_from_model(pm);
+ App::instance().engine()->create_patch_from_model(pm);
hide();
}
diff --git a/src/progs/ingenuity/NodeController.cpp b/src/progs/ingenuity/NodeController.cpp
index bd98346b..331a714e 100644
--- a/src/progs/ingenuity/NodeController.cpp
+++ b/src/progs/ingenuity/NodeController.cpp
@@ -17,6 +17,7 @@
#include "NodeController.h"
#include <iostream>
#include <gtkmm.h>
+#include "App.h"
#include "OmModule.h"
#include "NodeModel.h"
#include "PortModel.h"
@@ -28,11 +29,11 @@
#include "OmFlowCanvas.h"
#include "RenameWindow.h"
#include "GladeFactory.h"
-#include "Controller.h"
#include "PatchWindow.h"
#include "PatchModel.h"
#include "NodePropertiesWindow.h"
#include "Store.h"
+#include "ModelEngineInterface.h"
using std::cerr; using std::endl;
namespace Ingenuity {
@@ -199,7 +200,7 @@ NodeController::add_port(CountedPtr<PortModel> pm)
assert(pm->parent() == node_model());
assert(node_model()->get_port(pm->name()) == pm);
- cout << "[NodeController] Adding port " << pm->path() << endl;
+ //cout << "[NodeController] Adding port " << pm->path() << endl;
// FIXME: leak
PortController* pc = new PortController(pm);
@@ -240,7 +241,7 @@ NodeController::show_control_window()
void
NodeController::on_menu_destroy()
{
- Controller::instance().destroy(node_model()->path());
+ App::instance().engine()->destroy(node_model()->path());
}
@@ -298,7 +299,7 @@ NodeController::on_menu_clone()
nm->polyphonic(node_model()->polyphonic());
nm->x(node_model()->x() + 20);
nm->y(node_model()->y() + 20);
- Controller::instance().create_node_from_model(nm);
+ App::instance().engine()->create_node_from_model(nm);
*/
}
@@ -306,13 +307,13 @@ NodeController::on_menu_clone()
void
NodeController::on_menu_learn()
{
- Controller::instance().midi_learn(node_model()->path());
+ App::instance().engine()->midi_learn(node_model()->path());
}
void
NodeController::on_menu_disconnect_all()
{
- Controller::instance().disconnect_all(node_model()->path());
+ App::instance().engine()->disconnect_all(node_model()->path());
}
diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp
index 7d4bd3a4..ac5f8beb 100644
--- a/src/progs/ingenuity/OmFlowCanvas.cpp
+++ b/src/progs/ingenuity/OmFlowCanvas.cpp
@@ -17,7 +17,8 @@
#include "OmFlowCanvas.h"
#include <cassert>
#include <flowcanvas/FlowCanvas.h>
-#include "Controller.h"
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "PatchController.h"
#include "PatchModel.h"
#include "PatchWindow.h"
@@ -106,19 +107,19 @@ OmFlowCanvas::connect(const Port* src_port, const Port* dst_port)
+ src->name() + "-" + dst->name());
nm->x(dst->module()->property_x() - dst->module()->width() - 20);
nm->y(dst->module()->property_y());
- Controller::instance().create_node_from_model(nm);
- Controller::instance().connect(src->model()->path(), nm->path() + "/MIDI_In");
- Controller::instance().connect(nm->path() + "/Out_(CR)", dst->model()->path());
- Controller::instance().midi_learn(nm->path());
+ App::instance().engine()->create_node_from_model(nm);
+ App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In");
+ App::instance().engine()->connect(nm->path() + "/Out_(CR)", dst->model()->path());
+ App::instance().engine()->midi_learn(nm->path());
// Set control node range to port's user range
- Controller::instance().set_port_value_queued(nm->path().base_path() + "Min",
+ App::instance().engine()->set_port_value_queued(nm->path().base_path() + "Min",
atof(dst->model()->get_metadata("user-min").c_str()));
- Controller::instance().set_port_value_queued(nm->path().base_path() + "Max",
+ App::instance().engine()->set_port_value_queued(nm->path().base_path() + "Max",
atof(dst->model()->get_metadata("user-max").c_str()));
} else {
- Controller::instance().connect(src->model()->path(),
+ App::instance().engine()->connect(src->model()->path(),
dst->model()->path());
}
}
@@ -130,7 +131,7 @@ OmFlowCanvas::disconnect(const Port* src_port, const Port* dst_port)
assert(src_port != NULL);
assert(dst_port != NULL);
- Controller::instance().disconnect(((OmPort*)src_port)->model()->path(),
+ App::instance().engine()->disconnect(((OmPort*)src_port)->model()->path(),
((OmPort*)dst_port)->model()->path());
}
@@ -168,7 +169,7 @@ void
OmFlowCanvas::destroy_selected()
{
for (list<Module*>::iterator m = m_selected_modules.begin(); m != m_selected_modules.end(); ++m)
- Controller::instance().destroy(((OmModule*)(*m))->node()->path());
+ App::instance().engine()->destroy(((OmModule*)(*m))->node()->path());
}
@@ -193,13 +194,13 @@ void
OmFlowCanvas::menu_add_port(const string& name, const string& type, bool is_output)
{
const Path& path = m_patch_controller->path().base_path() + generate_port_name(name);
- Controller::instance().create_port(path, type, is_output);
+ App::instance().engine()->create_port(path, type, is_output);
char temp_buf[16];
snprintf(temp_buf, 16, "%d", m_last_click_x);
- Controller::instance().set_metadata(path, "module-x", temp_buf);
+ App::instance().engine()->set_metadata(path, "module-x", temp_buf);
snprintf(temp_buf, 16, "%d", m_last_click_y);
- Controller::instance().set_metadata(path, "module-y", temp_buf);
+ App::instance().engine()->set_metadata(path, "module-y", temp_buf);
}
@@ -221,7 +222,7 @@ void
OmFlowCanvas::menu_add_audio_input()
{
string name = "audio_in";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "AUDIO", false);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "AUDIO", false);
}
@@ -229,7 +230,7 @@ void
OmFlowCanvas::menu_add_audio_output()
{
string name = "audio_out";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "AUDIO", true);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "AUDIO", true);
}
@@ -237,7 +238,7 @@ void
OmFlowCanvas::menu_add_control_input()
{
string name = "control_in";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "CONTROL", false);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "CONTROL", false);
}
@@ -245,7 +246,7 @@ void
OmFlowCanvas::menu_add_control_output()
{
string name = "control_out";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "CONTROL", true);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "CONTROL", true);
}
@@ -253,7 +254,7 @@ void
OmFlowCanvas::menu_add_midi_input()
{
string name = "midi_in";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "MIDI", false);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "MIDI", false);
}
@@ -261,7 +262,7 @@ void
OmFlowCanvas::menu_add_midi_output()
{
string name = "midi_out";
- Controller::instance().create_port(m_patch_controller->path().base_path() + name, "MIDI", true);
+ App::instance().engine()->create_port(m_patch_controller->path().base_path() + name, "MIDI", true);
}
*/
diff --git a/src/progs/ingenuity/OmModule.cpp b/src/progs/ingenuity/OmModule.cpp
index 2de109ea..e34665a7 100644
--- a/src/progs/ingenuity/OmModule.cpp
+++ b/src/progs/ingenuity/OmModule.cpp
@@ -16,7 +16,8 @@
#include "OmModule.h"
#include <cassert>
-#include "Controller.h"
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "OmFlowCanvas.h"
#include "PatchModel.h"
#include "NodeModel.h"
@@ -64,12 +65,12 @@ OmModule::store_location()
m_node->node_model()->x(property_x());
snprintf(temp_buf, 16, "%f", m_node->node_model()->x());
m_node->node_model()->set_metadata("module-x", temp_buf); // just in case?
- Controller::instance().set_metadata(m_node->node_model()->path(), "module-x", temp_buf);
+ App::instance().engine()->set_metadata(m_node->node_model()->path(), "module-x", temp_buf);
m_node->node_model()->y(property_y());
snprintf(temp_buf, 16, "%f", m_node->node_model()->y());
m_node->node_model()->set_metadata("module-y", temp_buf); // just in case?
- Controller::instance().set_metadata(m_node->node_model()->path(), "module-y", temp_buf);
+ App::instance().engine()->set_metadata(m_node->node_model()->path(), "module-y", temp_buf);
}
diff --git a/src/progs/ingenuity/OmPortModule.cpp b/src/progs/ingenuity/OmPortModule.cpp
index c1a54378..e5c5fca6 100644
--- a/src/progs/ingenuity/OmPortModule.cpp
+++ b/src/progs/ingenuity/OmPortModule.cpp
@@ -16,7 +16,8 @@
#include "OmPortModule.h"
#include <cassert>
-#include "Controller.h"
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "OmFlowCanvas.h"
#include "PatchModel.h"
#include "NodeModel.h"
@@ -50,12 +51,12 @@ OmPortModule::store_location()
//m_port->port_model()->x(property_x());
snprintf(temp_buf, 16, "%f", property_x().get_value());
//m_port->port_model()->set_metadata("module-x", temp_buf); // just in case?
- Controller::instance().set_metadata(m_port->port_model()->path(), "module-x", temp_buf);
+ App::instance().engine()->set_metadata(m_port->port_model()->path(), "module-x", temp_buf);
//m_port->port_model()->y(property_y());
snprintf(temp_buf, 16, "%f", property_y().get_value());
//m_port->port_model()->set_metadata("module-y", temp_buf); // just in case?
- Controller::instance().set_metadata(m_port->port_model()->path(), "module-y", temp_buf);
+ App::instance().engine()->set_metadata(m_port->port_model()->path(), "module-y", temp_buf);
}
diff --git a/src/progs/ingenuity/PatchController.cpp b/src/progs/ingenuity/PatchController.cpp
index 49c7491c..86e548c7 100644
--- a/src/progs/ingenuity/PatchController.cpp
+++ b/src/progs/ingenuity/PatchController.cpp
@@ -27,7 +27,6 @@
#include "PatchView.h"
#include "flowcanvas/Module.h"
#include "PluginModel.h"
-#include "Controller.h"
#include "SubpatchModule.h"
#include "DSSIModule.h"
#include "PatchWindow.h"
@@ -390,34 +389,8 @@ PatchController::create_connection(CountedPtr<ConnectionModel> cm)
cm->src_port_path().name(),
dst_parent_name,
cm->dst_port_path().name());
-
- // Disable control slider from destination node control window
-
- cerr << "FIXME: create_connection\n";
- /*PortController* p = Store::instance().port(cm->dst_port_path());
- assert(p != NULL);
-
- if (p->control_panel() != NULL)
- p->control_panel()->disable_port(p->path());*/
-
- // FIXME: don't use canvas as a model (search object store)
- /*OmModule* m = (OmModule*)m_patch_view->canvas()->find_module(
- cm->dst_port_path().parent().name());
-
- if (m != NULL) {
- OmPort* p = m->port(cm->dst_port_path().name());
- if (p != NULL && p->connections().size() == 1) {
- p->model()->connected(true);
- assert(m->node_model()->controller() != NULL);
- NodeControlWindow* cw = (((NodeController*)
- m->node_model()->controller())->control_window());
- if (cw != NULL)
- cw->control_panel()->disable_port(cm->dst_port_path());
- }
- }*/
}
-
NodeController*
PatchController::create_controller_for_node(CountedPtr<NodeModel> node)
{
@@ -529,8 +502,6 @@ PatchController::add_port(CountedPtr<PortModel> pm)
assert(pm->parent() == m_patch_model);
assert(patch_model()->get_port(pm->name()));
- cerr << "ADDING PORT " << pm->name() << "TO PATCH: " << patch_model()->path() << endl;
-
//cerr << "[PatchController] Adding port " << pm->path() << endl;
/*if (patch_model()->get_port(pm->name())) {
diff --git a/src/progs/ingenuity/PatchTreeWindow.cpp b/src/progs/ingenuity/PatchTreeWindow.cpp
index 0c5fdcf0..47bfc485 100644
--- a/src/progs/ingenuity/PatchTreeWindow.cpp
+++ b/src/progs/ingenuity/PatchTreeWindow.cpp
@@ -14,8 +14,10 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "App.h"
+#include "ModelEngineInterface.h"
+#include "OSCEngineSender.h"
#include "PatchTreeWindow.h"
-#include "Controller.h"
#include "PatchController.h"
#include "PatchWindow.h"
#include "SubpatchModule.h"
@@ -70,7 +72,8 @@ PatchTreeWindow::add_patch(PatchController* pc)
Gtk::TreeModel::iterator iter = m_patch_treestore->append();
Gtk::TreeModel::Row row = *iter;
if (pm->path() == "/") {
- string root_name = Controller::instance().engine_url();
+ CountedPtr<OSCEngineSender> osc_sender = App::instance().engine();
+ string root_name = osc_sender ? osc_sender->engine_url() : "Internal";
// Hack off trailing '/' if it's there (ugly)
//if (root_name.substr(root_name.length()-1,1) == "/")
// root_name = root_name.substr(0, root_name.length()-1);
@@ -178,12 +181,12 @@ PatchTreeWindow::event_patch_enabled_toggled(const Glib::ustring& path_str)
if ( ! pc->patch_model()->enabled()) {
if (m_enable_signal)
- Controller::instance().enable_patch(patch_path);
+ App::instance().engine()->enable_patch(patch_path);
//pc->enable();
row[m_patch_tree_columns.enabled_col] = true;
} else {
if (m_enable_signal)
- Controller::instance().disable_patch(patch_path);
+ App::instance().engine()->disable_patch(patch_path);
//pc->disable();
row[m_patch_tree_columns.enabled_col] = false;
}
diff --git a/src/progs/ingenuity/PatchView.cpp b/src/progs/ingenuity/PatchView.cpp
index 41e74b1c..644e0253 100644
--- a/src/progs/ingenuity/PatchView.cpp
+++ b/src/progs/ingenuity/PatchView.cpp
@@ -19,6 +19,7 @@
#include <cassert>
#include <fstream>
#include "App.h"
+#include "ModelEngineInterface.h"
#include "OmFlowCanvas.h"
#include "PatchController.h"
#include "LoadPluginWindow.h"
@@ -28,7 +29,6 @@
#include "NodeControlWindow.h"
#include "PatchPropertiesWindow.h"
#include "PatchTreeWindow.h"
-#include "Controller.h"
namespace Ingenuity {
@@ -101,10 +101,10 @@ PatchView::process_toggled()
return;
if (m_process_checkbutton->get_active()) {
- Controller::instance().enable_patch(m_patch->model()->path());
+ App::instance().engine()->enable_patch(m_patch->model()->path());
App::instance().patch_tree()->patch_enabled(m_patch->model()->path());
} else {
- Controller::instance().disable_patch(m_patch->model()->path());
+ App::instance().engine()->disable_patch(m_patch->model()->path());
App::instance().patch_tree()->patch_disabled(m_patch->model()->path());
}
}
diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp
index 69e8f7de..60fa966b 100644
--- a/src/progs/ingenuity/PatchWindow.cpp
+++ b/src/progs/ingenuity/PatchWindow.cpp
@@ -19,6 +19,7 @@
#include <cassert>
#include <fstream>
#include "App.h"
+#include "ModelEngineInterface.h"
#include "PatchView.h"
#include "OmFlowCanvas.h"
#include "PatchController.h"
@@ -32,10 +33,10 @@
#include "ConfigWindow.h"
#include "MessagesWindow.h"
#include "PatchTreeWindow.h"
-#include "Controller.h"
#include "BreadCrumb.h"
#include "Store.h"
#include "ConnectWindow.h"
+#include "Loader.h"
namespace Ingenuity {
@@ -88,7 +89,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
m_load_subpatch_window->set_transient_for(*this);
m_menu_view_control_window->property_sensitive() = false;
- //m_status_bar->push(Controller::instance().engine_url());
+ //m_status_bar->push(App::instance().engine()->engine_url());
//m_status_bar->pack_start(*Gtk::manage(new Gtk::Image(Gtk::Stock::CONNECT, Gtk::ICON_SIZE_MENU)), false, false);
/*m_menu_open->signal_activate().connect(
@@ -397,7 +398,7 @@ PatchWindow::event_save()
if (model->filename() == "")
event_save_as();
else
- Controller::instance().save_patch(model, model->filename(), false);
+ App::instance().loader()->save_patch(model, model->filename(), false);
}
@@ -452,7 +453,7 @@ PatchWindow::event_save_as()
fin.close();
if (confirm) {
- Controller::instance().save_patch(m_patch->patch_model().get(), filename, recursive);
+ App::instance().loader()->save_patch(m_patch->patch_model().get(), filename, recursive);
m_patch->patch_model()->filename(filename);
}
}
@@ -544,7 +545,7 @@ PatchWindow::event_quit()
if (ret == 1) {
App::instance().quit();
} else if (ret == 2) {
- Controller::instance().quit();
+ App::instance().engine()->quit();
App::instance().quit();
}
// Otherwise cancelled, do nothing
@@ -554,14 +555,14 @@ PatchWindow::event_quit()
void
PatchWindow::event_destroy()
{
- Controller::instance().destroy(m_patch->model()->path());
+ App::instance().engine()->destroy(m_patch->model()->path());
}
void
PatchWindow::event_clear()
{
- Controller::instance().clear_patch(m_patch->model()->path());
+ App::instance().engine()->clear_patch(m_patch->model()->path());
}
void
diff --git a/src/progs/ingenuity/PortController.cpp b/src/progs/ingenuity/PortController.cpp
index a26c14eb..0668a9e0 100644
--- a/src/progs/ingenuity/PortController.cpp
+++ b/src/progs/ingenuity/PortController.cpp
@@ -57,7 +57,7 @@ PortController::destroy()
void
PortController::create_module(OmFlowCanvas* canvas)
{
- cerr << "Creating port module " << m_model->path() << endl;
+ //cerr << "Creating port module " << m_model->path() << endl;
const string x_str = m_model->get_metadata("module-x");
const string y_str = m_model->get_metadata("module-y");
@@ -99,8 +99,6 @@ PortController::metadata_update(const string& key, const string& value)
m_control_panel->set_range_max(m_model->path(), atof(value.c_str()));
}
*/
- cerr << "FIXME: PortController::metadata_update" << endl;
-
if (m_module != NULL) {
if (key == "module-x") {
float x = atof(value.c_str());
diff --git a/src/progs/ingenuity/RenameWindow.cpp b/src/progs/ingenuity/RenameWindow.cpp
index 52f5bc98..dfe4b07b 100644
--- a/src/progs/ingenuity/RenameWindow.cpp
+++ b/src/progs/ingenuity/RenameWindow.cpp
@@ -17,11 +17,11 @@
#include "RenameWindow.h"
#include <cassert>
#include <string>
-#include "Controller.h"
#include "ObjectModel.h"
#include "GtkObjectController.h"
#include "Store.h"
#include "App.h"
+#include "ModelEngineInterface.h"
using std::string;
namespace Ingenuity {
@@ -105,7 +105,7 @@ RenameWindow::ok_clicked()
assert(name.length() > 0);
assert(name.find("/") == string::npos);
- Controller::instance().rename(m_object->model()->path(), name);
+ App::instance().engine()->rename(m_object->model()->path(), name);
hide();
}
diff --git a/src/progs/ingenuity/SubpatchModule.cpp b/src/progs/ingenuity/SubpatchModule.cpp
index 3133c7c9..36fecff3 100644
--- a/src/progs/ingenuity/SubpatchModule.cpp
+++ b/src/progs/ingenuity/SubpatchModule.cpp
@@ -17,6 +17,8 @@
#include "SubpatchModule.h"
#include <cassert>
#include <iostream>
+#include "App.h"
+#include "ModelEngineInterface.h"
#include "OmModule.h"
#include "NodeControlWindow.h"
#include "PatchModel.h"
@@ -24,7 +26,6 @@
#include "OmFlowCanvas.h"
#include "PatchController.h"
#include "OmPort.h"
-#include "Controller.h"
using std::cerr; using std::cout; using std::endl;
namespace Ingenuity {
@@ -96,7 +97,7 @@ SubpatchModule::show_dialog()
void
SubpatchModule::menu_remove()
{
- Controller::instance().destroy(m_patch->model()->path());
+ App::instance().engine()->destroy(m_patch->model()->path());
}
} // namespace Ingenuity
diff --git a/src/progs/ingenuity/main.cpp b/src/progs/ingenuity/main.cpp
index 034a1c85..d200c3d6 100644
--- a/src/progs/ingenuity/main.cpp
+++ b/src/progs/ingenuity/main.cpp
@@ -18,34 +18,14 @@
#include "cmdline.h"
#include "ConnectWindow.h"
#include "App.h"
-#include "Store.h"
-#include "Controller.h"
#include "Configuration.h"
#ifdef HAVE_LASH
#include "LashController.h"
#endif
-#include "ThreadedSigClientInterface.h"
-#include "OSCClientReceiver.h"
-using Ingen::Shared::ClientInterface;
using namespace Ingenuity;
-class OSCSigEmitter : public OSCClientReceiver, public ThreadedSigClientInterface {
-public:
- OSCSigEmitter(size_t queue_size, int listen_port)
- : Ingen::Shared::ClientInterface()
- , OSCClientReceiver(listen_port)
- , ThreadedSigClientInterface(queue_size)
- {
- Glib::signal_timeout().connect(
- sigc::mem_fun((ThreadedSigClientInterface*)this,
- &ThreadedSigClientInterface::emit_signals),
- 5, G_PRIORITY_DEFAULT_IDLE);
- }
-};
-
-
int
main(int argc, char** argv)
{
@@ -68,26 +48,22 @@ main(int argc, char** argv)
Gnome::Canvas::init();
Gtk::Main gtk_main(argc, argv);
- CountedPtr<SigClientInterface> emitter(new OSCSigEmitter(1024, 16181));
-
/* Instantiate all singletons */
- App::instantiate(emitter);
-
- Controller::instantiate(engine_url);
+ App::instantiate();
/* Load settings */
App::instance().configuration()->load_settings();
App::instance().configuration()->apply_settings();
- #ifdef HAVE_LASH
+#ifdef HAVE_LASH
lash_args_t* lash_args = lash_extract_args(&argc, &argv);
- #endif
+#endif
//gtk_main.signal_quit().connect(sigc::ptr_fun(cleanup));
- #ifdef HAVE_LASH
+#ifdef HAVE_LASH
LashController* lash_controller = new LashController(lash_args);
- #endif
+#endif
App::instance().connect_window()->start();
gtk_main.run();