summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/demolition/DemolitionModel.cpp8
-rw-r--r--src/progs/demolition/Makefile.am4
-rw-r--r--src/progs/demolition/demolition.cpp3
-rw-r--r--src/progs/gtk/ControlInterface.cpp2
-rw-r--r--src/progs/gtk/DSSIController.cpp2
-rw-r--r--src/progs/gtk/DSSIController.h2
-rw-r--r--src/progs/gtk/LoadPluginWindow.cpp26
-rw-r--r--src/progs/gtk/LoadPluginWindow.h10
-rw-r--r--src/progs/gtk/NodeController.cpp23
-rw-r--r--src/progs/gtk/NodeController.h5
-rw-r--r--src/progs/gtk/NodePropertiesWindow.cpp2
-rw-r--r--src/progs/gtk/OmFlowCanvas.cpp5
-rw-r--r--src/progs/gtk/PatchController.cpp47
-rw-r--r--src/progs/gtk/PatchController.h8
-rw-r--r--src/progs/gtk/PortController.cpp4
-rw-r--r--src/progs/gtk/PortController.h2
-rw-r--r--src/progs/gtk/Store.cpp156
-rw-r--r--src/progs/gtk/Store.h26
-rw-r--r--src/progs/patch_loader/Makefile.am4
19 files changed, 207 insertions, 132 deletions
diff --git a/src/progs/demolition/DemolitionModel.cpp b/src/progs/demolition/DemolitionModel.cpp
index 786c08cd..b4faa533 100644
--- a/src/progs/demolition/DemolitionModel.cpp
+++ b/src/progs/demolition/DemolitionModel.cpp
@@ -64,7 +64,7 @@ DemolitionModel::random_node()
if (i == pm->nodes().end())
return NULL;
}
- return (*i).second;
+ return (*i).second.get();
}
}
//cout << "***************************** Not returning node *********" << endl;
@@ -89,7 +89,7 @@ DemolitionModel::random_node_in_patch(PatchModel* pm)
if (i == pm->nodes().end())
return NULL;
}
- return (*i).second;
+ return (*i).second.get();
}
@@ -108,7 +108,7 @@ DemolitionModel::random_port()
for (PortModelList::iterator p = ports.begin(); p != ports.end(); ++p, ++i)
if (i == index)
- return (*p);
+ return (*p).get();
return NULL; // shouldn't happen
}
@@ -128,7 +128,7 @@ DemolitionModel::random_port_in_node(NodeModel* node)
for (PortModelList::iterator p = ports.begin(); p != ports.end(); ++p, ++i)
if (i == index)
- return (*p);
+ return (*p).get();
return NULL; // shouldn't happen
}
diff --git a/src/progs/demolition/Makefile.am b/src/progs/demolition/Makefile.am
index 64fb3315..07caff5b 100644
--- a/src/progs/demolition/Makefile.am
+++ b/src/progs/demolition/Makefile.am
@@ -1,7 +1,7 @@
EXTRA_DIST = README
-om_demolition_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS)
-om_demolition_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS)
+om_demolition_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS) $(LSIGCPP_CFLAGS)
+om_demolition_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS)
bin_PROGRAMS = om_demolition
diff --git a/src/progs/demolition/demolition.cpp b/src/progs/demolition/demolition.cpp
index 84a08c84..93a37414 100644
--- a/src/progs/demolition/demolition.cpp
+++ b/src/progs/demolition/demolition.cpp
@@ -223,8 +223,7 @@ add_node()
PluginModel* plugin = model->random_plugin();
if (parent != NULL && plugin != NULL) {
- NodeModel* nm = new NodeModel(parent->path() +"/"+ random_name());
- nm->plugin(plugin);
+ NodeModel* nm = new NodeModel(plugin, parent->path() +"/"+ random_name());
cout << "Adding node " << nm->path() << endl;
engine->create_node_from_model(nm);
// Spread them out a bit for easier monitoring with om_gtk
diff --git a/src/progs/gtk/ControlInterface.cpp b/src/progs/gtk/ControlInterface.cpp
index f1fc44d9..eb5eee1b 100644
--- a/src/progs/gtk/ControlInterface.cpp
+++ b/src/progs/gtk/ControlInterface.cpp
@@ -45,7 +45,7 @@ void
ControlInterface::new_plugin_model(PluginModel* pm)
{
cerr << "NEW PLUGIN\n";
- Store::instance().add_plugin(pm);
+ //Store::instance().add_plugin(pm);
}
diff --git a/src/progs/gtk/DSSIController.cpp b/src/progs/gtk/DSSIController.cpp
index 570211c7..dedcbceb 100644
--- a/src/progs/gtk/DSSIController.cpp
+++ b/src/progs/gtk/DSSIController.cpp
@@ -27,7 +27,7 @@
namespace OmGtk {
-DSSIController::DSSIController(NodeModel* model)
+DSSIController::DSSIController(CountedPtr<NodeModel> model)
: NodeController(model),
m_banks_dirty(true)
{
diff --git a/src/progs/gtk/DSSIController.h b/src/progs/gtk/DSSIController.h
index 53f6fc8b..ca8da578 100644
--- a/src/progs/gtk/DSSIController.h
+++ b/src/progs/gtk/DSSIController.h
@@ -49,7 +49,7 @@ class DSSIModule;
class DSSIController : public NodeController
{
public:
- DSSIController(NodeModel* model);
+ DSSIController(CountedPtr<NodeModel> model);
virtual ~DSSIController() {}
diff --git a/src/progs/gtk/LoadPluginWindow.cpp b/src/progs/gtk/LoadPluginWindow.cpp
index b84ae39e..bd11320a 100644
--- a/src/progs/gtk/LoadPluginWindow.cpp
+++ b/src/progs/gtk/LoadPluginWindow.cpp
@@ -133,7 +133,7 @@ void
LoadPluginWindow::on_show()
{
if (!m_has_shown) {
- set_plugin_model(Store::instance().plugins());
+ set_plugin_list(Store::instance().plugins());
// Center on patch window
int m_w, m_h;
@@ -161,12 +161,12 @@ LoadPluginWindow::on_hide()
void
-LoadPluginWindow::set_plugin_model(const std::map<string, const PluginModel*>& m)
+LoadPluginWindow::set_plugin_list(const std::map<string, CountedPtr<PluginModel> >& m)
{
m_plugins_liststore->clear();
- const PluginModel* plugin = NULL;
- for (std::map<string, const PluginModel*>::const_iterator i = m.begin(); i != m.end(); ++i) {
+ CountedPtr<PluginModel> plugin = NULL;
+ for (std::map<string, CountedPtr<PluginModel> >::const_iterator i = m.begin(); i != m.end(); ++i) {
plugin = (*i).second;
Gtk::TreeModel::iterator iter = m_plugins_liststore->append();
@@ -186,7 +186,7 @@ LoadPluginWindow::set_plugin_model(const std::map<string, const PluginModel*>& m
void
-LoadPluginWindow::add_plugin(const PluginModel* const plugin)
+LoadPluginWindow::add_plugin(CountedPtr<PluginModel> plugin)
{
Gtk::TreeModel::iterator iter = m_plugins_liststore->append();
Gtk::TreeModel::Row row = *iter;
@@ -240,7 +240,7 @@ LoadPluginWindow::generate_module_name(int offset)
if (iter) {
Gtk::TreeModel::Row row = *iter;
- const PluginModel* const plugin = row.get_value(m_plugins_columns.m_col_plugin_model);
+ CountedPtr<PluginModel> plugin = row.get_value(m_plugins_columns.m_col_plugin_model);
char num_buf[3];
for (uint i=0; i < 99; ++i) {
name = plugin->plug_label();
@@ -270,7 +270,7 @@ LoadPluginWindow::add_clicked()
if (iter) { // If anything is selected
Gtk::TreeModel::Row row = *iter;
- const PluginModel* const plugin = row.get_value(m_plugins_columns.m_col_plugin_model);
+ CountedPtr<PluginModel> plugin = row.get_value(m_plugins_columns.m_col_plugin_model);
string name = m_node_name_entry->get_text();
if (name == "") {
name = generate_module_name();
@@ -283,8 +283,7 @@ LoadPluginWindow::add_clicked()
dialog.run();
} else {
const string path = m_patch_controller->model()->base_path() + name;
- NodeModel* nm = new NodeModel(path);
- nm->plugin(plugin);
+ NodeModel* nm = new NodeModel(plugin, path);
nm->polyphonic(polyphonic);
if (m_new_module_x == 0 && m_new_module_y == 0) {
@@ -340,10 +339,11 @@ LoadPluginWindow::filter_changed()
Gtk::TreeModel::iterator model_iter;
size_t num_visible = 0;
- const PluginModel* plugin = NULL;
- for (std::map<string, const PluginModel*>::const_iterator i = Store::instance().plugins().begin();
+
+ for (std::map<string, CountedPtr<PluginModel> >::const_iterator i = Store::instance().plugins().begin();
i != Store::instance().plugins().end(); ++i) {
- plugin = (*i).second;
+
+ const CountedPtr<PluginModel> plugin = (*i).second;
switch (criteria) {
case CriteriaColumns::NAME:
@@ -389,7 +389,7 @@ void
LoadPluginWindow::clear_clicked()
{
m_search_entry->set_text("");
- set_plugin_model(Store::instance().plugins());
+ set_plugin_list(Store::instance().plugins());
}
bool
diff --git a/src/progs/gtk/LoadPluginWindow.h b/src/progs/gtk/LoadPluginWindow.h
index adf11ab4..4bf302c2 100644
--- a/src/progs/gtk/LoadPluginWindow.h
+++ b/src/progs/gtk/LoadPluginWindow.h
@@ -23,7 +23,7 @@
#include <libglademm/xml.h>
#include <libglademm.h>
#include <gtkmm.h>
-
+#include "util/CountedPtr.h"
using LibOmClient::PluginModel;
@@ -55,8 +55,8 @@ public:
Gtk::TreeModelColumn<Glib::ustring> m_col_uri;
// Not displayed:
- Gtk::TreeModelColumn<Glib::ustring> m_col_label;
- Gtk::TreeModelColumn<const PluginModel*> m_col_plugin_model;
+ Gtk::TreeModelColumn<Glib::ustring> m_col_label;
+ Gtk::TreeModelColumn<CountedPtr<PluginModel> > m_col_plugin_model;
};
@@ -88,12 +88,12 @@ public:
LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& xml);
void patch_controller(PatchController* pc);
- void set_plugin_model(const std::map<string, const PluginModel*>& m);
+ void set_plugin_list(const std::map<string, CountedPtr<PluginModel> >& m);
void set_next_module_location(int x, int y)
{ m_new_module_x = x; m_new_module_y = y; }
- void add_plugin(const PluginModel* info);
+ void add_plugin(CountedPtr<PluginModel> plugin);
bool has_shown() const { return m_has_shown; }
protected:
diff --git a/src/progs/gtk/NodeController.cpp b/src/progs/gtk/NodeController.cpp
index ae3e5a9e..63994c00 100644
--- a/src/progs/gtk/NodeController.cpp
+++ b/src/progs/gtk/NodeController.cpp
@@ -46,11 +46,11 @@ NodeController::NodeController(CountedPtr<NodeModel> model)
m_properties_window(NULL),
m_bridge_port(NULL)
{
- assert(model->controller() == NULL);
+ assert(!model->controller());
model->set_controller(this);
// Create port controllers
- cerr << "FIXME: node" << endl;
+ cerr << "FIXME: NodeController()" << endl;
/*
for (list<PortModel*>::const_iterator i = node_model()->ports().begin();
i != node_model()->ports().end(); ++i) {
@@ -90,6 +90,8 @@ NodeController::NodeController(CountedPtr<NodeModel> model)
sigc::mem_fun(this, &NodeController::on_menu_learn)));
}
*/
+
+ model->new_port_sig.connect(sigc::mem_fun(this, &NodeController::add_port));
}
@@ -104,10 +106,13 @@ NodeController::create_module(OmFlowCanvas* canvas)
//cerr << "Creating node module " << m_model->path() << endl;
// If this is a DSSI plugin, DSSIController should be doing this
+ /*assert(node_model()->plugin());
assert(node_model()->plugin()->type() != PluginModel::DSSI);
assert(canvas != NULL);
- assert(m_module == NULL);
+ assert(m_module == NULL);*/
+ assert(canvas);
+ assert(node_model());
m_module = new OmModule(canvas, this);
create_all_ports();
@@ -184,7 +189,8 @@ NodeController::destroy()
assert(pc != NULL);
//remove_from_store();
- pc->remove_node(m_model->path().name());
+ //pc->remove_node(m_model->path().name());
+ cerr << "FIXME: remove node\n";
if (m_bridge_port != NULL)
m_bridge_port->destroy();
@@ -219,7 +225,7 @@ NodeController::metadata_update(const string& key, const string& value)
void
-NodeController::add_port(PortModel* pm)
+NodeController::add_port(CountedPtr<PortModel> pm)
{
assert(pm->parent() == NULL);
@@ -317,8 +323,7 @@ NodeController::on_menu_clone()
clone_name = clone_name + clone_postfix;
const string path = node_model()->parent_patch()->base_path() + clone_name;
- NodeModel* nm = new NodeModel(path);
- nm->plugin(node_model()->plugin());
+ NodeModel* nm = new NodeModel(node_model()->plugin(), path);
nm->polyphonic(node_model()->polyphonic());
nm->x(node_model()->x() + 20);
nm->y(node_model()->y() + 20);
@@ -369,7 +374,9 @@ NodeController::create_all_ports()
for (PortModelList::const_iterator i = node_model()->ports().begin();
i != node_model()->ports().end(); ++i) {
pc = dynamic_cast<PortController*>((*i)->controller());
- assert(pc != NULL);
+ // FIXME: leak
+ if (pc == NULL)
+ pc = new PortController(*i);
pc->create_port(m_module);
}
diff --git a/src/progs/gtk/NodeController.h b/src/progs/gtk/NodeController.h
index 7d732d2f..2199a9d5 100644
--- a/src/progs/gtk/NodeController.h
+++ b/src/progs/gtk/NodeController.h
@@ -64,7 +64,6 @@ public:
void set_path(const Path& new_path);
- virtual void add_port(PortModel* pm);
virtual void remove_port(const Path& path, bool resize_module) {}
virtual void program_add(int bank, int program, const string& name) {}
@@ -75,7 +74,7 @@ public:
void bridge_port(PortController* port) { m_bridge_port = port; }
PortController* as_port() { return m_bridge_port; }
- CountedPtr<NodeModel> node_model() { return CountedPtr<NodeModel>((NodeModel*)m_model.get()); }
+ CountedPtr<NodeModel> node_model() { return m_model; }
NodeControlWindow* control_window() { return m_control_window; }
void control_window(NodeControlWindow* cw) { m_control_window = cw; }
@@ -93,6 +92,8 @@ public:
virtual void disable_controls_menuitem();
protected:
+ virtual void add_port(CountedPtr<PortModel> pm);
+
void create_all_ports();
void on_menu_destroy();
diff --git a/src/progs/gtk/NodePropertiesWindow.cpp b/src/progs/gtk/NodePropertiesWindow.cpp
index 000fa6ac..b0028864 100644
--- a/src/progs/gtk/NodePropertiesWindow.cpp
+++ b/src/progs/gtk/NodePropertiesWindow.cpp
@@ -51,7 +51,7 @@ NodePropertiesWindow::set_node(CountedPtr<NodeModel> node_model)
m_node_path_label->set_text(node_model->path());
m_node_polyphonic_toggle->set_active(node_model->polyphonic());
- const PluginModel* const pm = node_model->plugin();
+ CountedPtr<PluginModel> pm = node_model->plugin();
m_plugin_type_label->set_text(pm->type_string());
m_plugin_uri_label->set_text(pm->uri());
diff --git a/src/progs/gtk/OmFlowCanvas.cpp b/src/progs/gtk/OmFlowCanvas.cpp
index a7e41ea2..cac5b87d 100644
--- a/src/progs/gtk/OmFlowCanvas.cpp
+++ b/src/progs/gtk/OmFlowCanvas.cpp
@@ -64,10 +64,9 @@ OmFlowCanvas::connect(const Port* src_port, const Port* dst_port)
dst->model()->type() == PortModel::CONTROL)
{
// FIXME: leaks?
- NodeModel* nm = new NodeModel(m_patch_controller->model()->base_path()
- + src->name() + "-" + dst->name());
PluginModel* pm = new PluginModel(PluginModel::Internal, "", "midi_control_in", "");
- nm->plugin(pm);
+ NodeModel* nm = new NodeModel(pm, m_patch_controller->model()->base_path()
+ + 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);
diff --git a/src/progs/gtk/PatchController.cpp b/src/progs/gtk/PatchController.cpp
index cbdf1472..90ffe005 100644
--- a/src/progs/gtk/PatchController.cpp
+++ b/src/progs/gtk/PatchController.cpp
@@ -70,6 +70,8 @@ PatchController::PatchController(CountedPtr<PatchModel> model)
else
cerr << "[PatchController] " << path() << " ERROR: Parent not found." << endl;
}*/
+
+ model->new_node_sig.connect(sigc::mem_fun(this, &PatchController::add_node));
}
@@ -194,7 +196,7 @@ PatchController::set_path(const Path& new_path)
// Rename nodes
for (NodeModelMap::const_iterator i = patch_model()->nodes().begin();
i != patch_model()->nodes().end(); ++i) {
- const NodeModel* const nm = (*i).second;
+ const NodeModel* const nm = (*i).second.get();
assert(nm != NULL);
NodeController* const nc = ((NodeController*)nm->controller());
assert(nc != NULL);
@@ -203,7 +205,7 @@ PatchController::set_path(const Path& new_path)
#ifdef DEBUG
// Be sure ports were renamed by their bridge nodes
- for (list<PortModel*>::const_iterator i = node_model()->ports().begin();
+ for (PortModelList::const_iterator i = node_model()->ports().begin();
i != node_model()->ports().end(); ++i) {
GtkObjectController* const pc = (GtkObjectController*)((*i)->controller());
assert(pc != NULL);
@@ -308,7 +310,7 @@ PatchController::create_view()
for (NodeModelMap::const_iterator i = patch_model()->nodes().begin();
i != patch_model()->nodes().end(); ++i) {
- NodeModel* const nm = (*i).second;
+ NodeModel* const nm = (*i).second.get();
string val = nm->get_metadata("module-x");
if (val != "")
@@ -326,7 +328,9 @@ PatchController::create_view()
}
NodeController* nc = ((NodeController*)nm->controller());
- assert(nc != NULL);
+ if (!nc)
+ nc = new NodeController(nm); // this should set nm->controller()
+
if (nc->module() == NULL);
nc->create_module(m_patch_view->canvas());
assert(nc->module() != NULL);
@@ -409,16 +413,19 @@ PatchController::add_subpatch(PatchController* patch)
void
-PatchController::add_node(NodeModel* nm)
+PatchController::add_node(CountedPtr<NodeModel> nm)
{
- assert(nm != NULL);
- assert(nm->parent() == NULL);
- assert(nm->path().parent() == m_model->path());
+ cerr << "ADD NODE\n";
+
+ assert(nm);
+ assert(nm->parent() == m_patch_model.get());
+ assert(nm->path().parent() == m_patch_model->path());
- if (patch_model()->get_node(nm->name()) != NULL) {
+ /*if (patch_model()->get_node(nm->name()) != NULL) {
+ cerr << "Ignoring existing\n";
// Node already exists, ignore
- delete nm;
- } else {
+ //delete nm;
+ } else {*/
// FIXME: Should PatchController really be responsible for creating these?
NodeController* nc = NULL;
@@ -431,8 +438,8 @@ PatchController::add_node(NodeModel* nm)
assert(nm->controller() == nc);
// Check if this is a bridge node
- PortModel* const pm = patch_model()->get_port(nm->path().name());
- if (pm != NULL) {
+ CountedPtr<PortModel> pm = patch_model()->get_port(nm->path().name());
+ if (pm) {
cerr << "Bridge node." << endl;
PortController* pc = ((PortController*)pm->controller());
assert(pc != NULL);
@@ -440,10 +447,9 @@ PatchController::add_node(NodeModel* nm)
}
//nc->add_to_store();
- patch_model()->add_node(nm);
+ //patch_model()->add_node(nm);
if (m_patch_view != NULL) {
-
int x, y;
get_new_module_location(x, y);
nm->x(x);
@@ -465,7 +471,7 @@ PatchController::add_node(NodeModel* nm)
m_patch_view->canvas()->zoom(old_zoom);
nc->module()->zoom(old_zoom);
}
- }
+ // }
}
}
@@ -496,17 +502,16 @@ PatchController::remove_node(const string& name)
* exist.
*/
void
-PatchController::add_port(PortModel* pm)
+PatchController::add_port(CountedPtr<PortModel> pm)
{
- assert(pm != NULL);
+ assert(pm);
assert(pm->parent() == NULL);
//cerr << "[PatchController] Adding port " << pm->path() << endl;
- if (patch_model()->get_port(pm->name()) != NULL) {
+ if (patch_model()->get_port(pm->name())) {
cerr << "[PatchController] Ignoring duplicate port "
<< pm->path() << endl;
- delete pm;
return;
}
@@ -561,7 +566,7 @@ PatchController::remove_port(const Path& path, bool resize_module)
}
patch_model()->remove_port(path);
- assert(patch_model()->get_port(path.name()) == NULL);
+ assert(patch_model()->get_port(path.name()));
// Disable "Controls" menuitem on module and patch window, if necessary
if (!has_control_inputs())
diff --git a/src/progs/gtk/PatchController.h b/src/progs/gtk/PatchController.h
index d9491571..553a35e1 100644
--- a/src/progs/gtk/PatchController.h
+++ b/src/progs/gtk/PatchController.h
@@ -71,10 +71,7 @@ public:
virtual void metadata_update(const string& key, const string& value);
- void add_node(NodeModel* nm);
- void remove_node(const string& name);
-
- virtual void add_port(PortModel* pm);
+ virtual void add_port(CountedPtr<PortModel> pm);
virtual void remove_port(const Path& path, bool resize_module);
void connection(ConnectionModel* const cm);
@@ -111,6 +108,9 @@ public:
void disable_controls_menuitem();
private:
+ void add_node(CountedPtr<NodeModel> nm);
+ void remove_node(const string& name);
+
void create_connection(const ConnectionModel* cm);
PatchWindow* m_window; ///< Window currently showing this patch
diff --git a/src/progs/gtk/PortController.cpp b/src/progs/gtk/PortController.cpp
index 1e840583..eaad6efe 100644
--- a/src/progs/gtk/PortController.cpp
+++ b/src/progs/gtk/PortController.cpp
@@ -24,12 +24,12 @@
namespace OmGtk {
-PortController::PortController(PortModel* model)
+PortController::PortController(CountedPtr<PortModel> model)
: GtkObjectController(model),
m_port(NULL),
m_control_panel(NULL)
{
- assert(model != NULL);
+ assert(model);
assert(model->parent() != NULL);
assert(model->controller() == NULL);
diff --git a/src/progs/gtk/PortController.h b/src/progs/gtk/PortController.h
index 6172025f..ee4dc41f 100644
--- a/src/progs/gtk/PortController.h
+++ b/src/progs/gtk/PortController.h
@@ -44,7 +44,7 @@ class OmModule;
class PortController : public GtkObjectController
{
public:
- PortController(PortModel* model);
+ PortController(CountedPtr<PortModel> model);
virtual ~PortController() {}
virtual void destroy();
diff --git a/src/progs/gtk/Store.cpp b/src/progs/gtk/Store.cpp
index c68bdc75..8f74e3c7 100644
--- a/src/progs/gtk/Store.cpp
+++ b/src/progs/gtk/Store.cpp
@@ -37,7 +37,7 @@ Store::Store(SigClientInterface& emitter)
void
-Store::add_object(ObjectModel* object)
+Store::add_object(CountedPtr<ObjectModel> object)
{
assert(object->path() != "");
assert(m_objects.find(object->path()) == m_objects.end());
@@ -48,32 +48,41 @@ Store::add_object(ObjectModel* object)
}
-void
-Store::remove_object(ObjectModel* object)
+CountedPtr<ObjectModel>
+Store::remove_object(const string& path)
{
- if (!object)
- return;
-
- map<string, ObjectModel*>::iterator i
- = m_objects.find(object->path());
+ map<string, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i != m_objects.end()) {
- assert((*i).second == object);
+ assert((*i).second->path() == path);
+ CountedPtr<ObjectModel> result = (*i).second;
m_objects.erase(i);
+ cout << "[Store] Removed " << path << endl;
+ return result;
} else {
- cerr << "[App] Unable to find object " << object->path()
- << " to remove." << endl;
+ cerr << "[Store] Unable to find object " << path << " to remove." << endl;
+ return NULL;
}
-
- cout << "[Store] Removed " << object->path() << endl;
+}
+
+
+CountedPtr<PluginModel>
+Store::plugin(const string& uri)
+{
+ assert(uri.length() > 0);
+ map<string, CountedPtr<PluginModel> >::iterator i = m_plugins.find(uri);
+ if (i == m_plugins.end())
+ return NULL;
+ else
+ return (*i).second;
}
CountedPtr<ObjectModel>
-Store::object(const string& path) const
+Store::object(const string& path)
{
assert(path.length() > 0);
- map<string, ObjectModel*>::const_iterator i = m_objects.find(path);
+ map<string, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i == m_objects.end())
return NULL;
else
@@ -82,41 +91,43 @@ Store::object(const string& path) const
CountedPtr<PatchModel>
-Store::patch(const string& path) const
+Store::patch(const string& path)
{
assert(path.length() > 0);
- map<string, ObjectModel*>::const_iterator i = m_objects.find(path);
+ map<string, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i == m_objects.end())
return NULL;
else
- return dynamic_cast<PatchModel*>((*i).second);
+ //return dynamic_cast<PatchModel*>((*i).second.get());
+ return (CountedPtr<PatchModel>)(*i).second; // FIXME
}
CountedPtr<NodeModel>
-Store::node(const string& path) const
+Store::node(const string& path)
{
assert(path.length() > 0);
- map<string, ObjectModel*>::const_iterator i = m_objects.find(path);
+ map<string, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i == m_objects.end())
return NULL;
else
- return dynamic_cast<NodeModel*>((*i).second);
+ return (*i).second;
}
CountedPtr<PortModel>
-Store::port(const string& path) const
+Store::port(const string& path)
{
assert(path.length() > 0);
- map<string, ObjectModel*>::const_iterator i = m_objects.find(path);
+ map<string, CountedPtr<ObjectModel> >::iterator i = m_objects.find(path);
if (i == m_objects.end()) {
return NULL;
} else {
// Normal port
- PortModel* const pc = dynamic_cast<PortModel*>((*i).second);
+ /*PortModel* const pc = dynamic_cast<PortModel*>((*i).second);
if (pc)
- return pc;
+ return pc;*/
+ return (*i).second;
// Patch port (corresponding Node is in store)
// FIXME
@@ -133,14 +144,13 @@ Store::port(const string& path) const
void
-Store::add_plugin(const PluginModel* pm)
+Store::add_plugin(CountedPtr<PluginModel> pm)
{
if (m_plugins.find(pm->uri()) != m_plugins.end()) {
- cerr << "DUPE! " << pm->uri() << endl;
- delete m_plugins[pm->uri()];
+ cerr << "DUPE PLUGIN: " << pm->uri() << endl;
+ } else {
+ m_plugins[pm->uri()] = pm;
}
-
- m_plugins[pm->uri()] = pm;
}
@@ -151,7 +161,8 @@ Store::add_plugin(const PluginModel* pm)
void
Store::destruction_event(const string& path)
{
- remove_object(object(path).get());
+ remove_object(path);
+ // FIXME: emit signals
}
void
@@ -166,19 +177,41 @@ Store::new_plugin_event(const string& type, const string& uri, const string& nam
void
Store::new_patch_event(const string& path, uint32_t poly)
{
- PatchModel* const p = new PatchModel(path, poly);
- add_object(p);
+ // FIXME: What to do with a conflict?
+
+ if (m_objects.find(path) == m_objects.end()) {
+ PatchModel* const p = new PatchModel(path, poly);
+ add_object(p);
+ }
}
+
void
Store::new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports)
{
+ // FIXME: What to do with a conflict?
// FIXME: resolve plugin here
- NodeModel* const n = new NodeModel(node_path);
- n->polyphonic(is_polyphonic);
- // FIXME: num_ports unused
- add_object(n);
+
+ if (m_objects.find(node_path) == m_objects.end()) {
+
+ CountedPtr<PluginModel> plug = plugin(plugin_uri);
+ assert(plug);
+
+ CountedPtr<NodeModel> n(new NodeModel(plug, node_path));
+ n->polyphonic(is_polyphonic);
+ // FIXME: num_ports unused
+ add_object(n);
+
+ std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(n->path().parent());
+ if (pi != m_objects.end()) {
+ PatchModel* parent = dynamic_cast<PatchModel*>((*pi).second.get());
+ if (parent)
+ parent->add_node(n);
+ else
+ cerr << "ERROR: new node with no parent" << endl;
+ }
+ }
}
@@ -186,18 +219,43 @@ void
Store::new_port_event(const string& path, const string& type, bool is_output)
{
// FIXME: this sucks
-
- PortModel::Type ptype = PortModel::CONTROL;
- if (type == "AUDIO") ptype = PortModel::AUDIO;
- else if (type == "CONTROL") ptype = PortModel::CONTROL;
- else if (type== "MIDI") ptype = PortModel::MIDI;
- else cerr << "[OSCListener] WARNING: Unknown port type received (" << type << ")" << endl;
-
- PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
-
- PortModel* const p = new PortModel(path, ptype, pdir);
- add_object(p);
-
+ /*
+ if (m_objects.find(path) == m_objects.end()) {
+ PortModel::Type ptype = PortModel::CONTROL;
+ if (type == "AUDIO") ptype = PortModel::AUDIO;
+ else if (type == "CONTROL") ptype = PortModel::CONTROL;
+ else if (type== "MIDI") ptype = PortModel::MIDI;
+ else cerr << "[OSCListener] WARNING: Unknown port type received (" << type << ")" << endl;
+
+ PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
+
+ PortModel* const p = new PortModel(path, ptype, pdir);
+
+ add_object(p);
+ } else
+ */
+ if (m_objects.find(path) == m_objects.end()) {
+
+ PortModel::Type ptype = PortModel::CONTROL;
+ if (type == "AUDIO") ptype = PortModel::AUDIO;
+ else if (type == "CONTROL") ptype = PortModel::CONTROL;
+ else if (type== "MIDI") ptype = PortModel::MIDI;
+ else cerr << "[OSCListener] WARNING: Unknown port type received (" << type << ")" << endl;
+
+ PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
+
+ CountedPtr<PortModel> p(new PortModel(path, ptype, pdir));
+ add_object(p);
+
+ std::map<string, CountedPtr<ObjectModel> >::iterator pi = m_objects.find(p->path().parent());
+ if (pi != m_objects.end()) {
+ NodeModel* parent = dynamic_cast<NodeModel*>((*pi).second.get());
+ if (parent)
+ parent->add_port(p);
+ else
+ cerr << "ERROR: new port with no parent" << endl;
+ }
+ }
}
diff --git a/src/progs/gtk/Store.h b/src/progs/gtk/Store.h
index d3bcbf94..c3e465c0 100644
--- a/src/progs/gtk/Store.h
+++ b/src/progs/gtk/Store.h
@@ -17,6 +17,9 @@
#ifndef STORE_H
#define STORE_H
+// FIXME: for CountedPtr
+#define WITH_RTTI
+
#include <cassert>
#include <string>
#include <map>
@@ -43,15 +46,16 @@ namespace OmGtk {
*/
class Store {
public:
- CountedPtr<ObjectModel> object(const string& path) const;
- CountedPtr<PatchModel> patch(const string& path) const;
- CountedPtr<NodeModel> node(const string& path) const;
- CountedPtr<PortModel> port(const string& path) const;
+ CountedPtr<PluginModel> plugin(const string& uri);
+ CountedPtr<ObjectModel> object(const string& path);
+ CountedPtr<PatchModel> patch(const string& path);
+ CountedPtr<NodeModel> node(const string& path);
+ CountedPtr<PortModel> port(const string& path);
size_t num_objects() { return m_objects.size(); }
- void add_plugin(const PluginModel* pm);
- const map<string, const PluginModel*>& plugins() const { return m_plugins; }
+
+ const map<string, CountedPtr<PluginModel> >& plugins() const { return m_plugins; }
static void instantiate(SigClientInterface& emitter)
{ if (!_instance) _instance = new Store(emitter); }
@@ -63,8 +67,10 @@ private:
static Store* _instance;
- void add_object(ObjectModel* object);
- void remove_object(ObjectModel* object);
+ void add_object(CountedPtr<ObjectModel> object);
+ CountedPtr<ObjectModel> remove_object(const string& path);
+
+ void add_plugin(CountedPtr<PluginModel> plugin);
// Slots for SigClientInterface signals
void destruction_event(const string& path);
@@ -73,8 +79,8 @@ private:
void new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports);
void new_port_event(const string& path, const string& data_type, bool is_output);
- map<string, ObjectModel*> m_objects; ///< Keyed by Om path
- map<string, const PluginModel*> m_plugins; ///< Keyed by URI
+ map<string, CountedPtr<ObjectModel> > m_objects; ///< Keyed by Om path
+ map<string, CountedPtr<PluginModel> > m_plugins; ///< Keyed by URI
};
diff --git a/src/progs/patch_loader/Makefile.am b/src/progs/patch_loader/Makefile.am
index 1dddefbb..c14814ff 100644
--- a/src/progs/patch_loader/Makefile.am
+++ b/src/progs/patch_loader/Makefile.am
@@ -1,7 +1,7 @@
EXTRA_DIST = README
-om_patch_loader_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS)
-om_patch_loader_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS)
+om_patch_loader_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS) $(LSIGCPP_CFLAGS)
+om_patch_loader_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS)
bin_PROGRAMS = om_patch_loader