summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/util/CountedPtr.h19
-rw-r--r--src/libs/client/Makefile.am2
-rw-r--r--src/libs/client/ModelClientInterface.cpp7
-rw-r--r--src/libs/client/NodeModel.cpp26
-rw-r--r--src/libs/client/NodeModel.h22
-rw-r--r--src/libs/client/PatchLibrarian.cpp24
-rw-r--r--src/libs/client/PatchModel.cpp20
-rw-r--r--src/libs/client/PatchModel.h7
-rw-r--r--src/libs/client/PortModel.h3
-rw-r--r--src/libs/client/ThreadedSigClientInterface.cpp3
-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
29 files changed, 291 insertions, 181 deletions
diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h
index f2079c7c..5c2a48f0 100644
--- a/src/common/util/CountedPtr.h
+++ b/src/common/util/CountedPtr.h
@@ -52,6 +52,14 @@ public:
_counter = new Counter(p);
}
+ /** Make a NULL CountedPtr.
+ * It would be best if this didn't exist, but it makes these storable
+ * in STL containers :/
+ */
+ CountedPtr()
+ : _counter(NULL)
+ {}
+
~CountedPtr()
{
release();
@@ -61,9 +69,10 @@ public:
CountedPtr(const CountedPtr& copy)
: _counter(NULL)
{
- assert(copy);
assert(this != &copy);
- retain(copy._counter);
+
+ if (copy)
+ retain(copy._counter);
}
/** Copy a CountedPtr to a valid base class.
@@ -76,7 +85,11 @@ public:
// Fail if this is not a valid cast
if (y) {
- T* const unused_variable = static_cast<Y* const>(y._counter->ptr);
+#ifdef WITH_RTTI
+ T* const unused_variable = dynamic_cast<T* const>(y._counter->ptr);
+#else
+ T* const unused_variable = static_cast<T* const>(y._counter->ptr);
+#endif
assert(unused_variable == y._counter->ptr); // shuts up gcc
}
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index ada22522..4378d789 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -3,7 +3,7 @@ AM_CXXFLAGS = -I$(top_srcdir)/src/common -fno-exceptions -fno-rtti
if BUILD_CLIENT_LIB
noinst_LTLIBRARIES = libomclient.la
-libomclient_la_CXXFLAGS = -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LIBGLADEMM_CFLAGS) $(GNOMECANVASMM_CFLAGS) $(JACK_CFLAGS) $(LXML2_CFLAGS)
+libomclient_la_CXXFLAGS = -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LSIGCPP_CFLAGS)
libomclient_la_SOURCES = \
ClientInterface.h \
diff --git a/src/libs/client/ModelClientInterface.cpp b/src/libs/client/ModelClientInterface.cpp
index 46754161..33f2cb2f 100644
--- a/src/libs/client/ModelClientInterface.cpp
+++ b/src/libs/client/ModelClientInterface.cpp
@@ -77,8 +77,8 @@ void
ModelClientInterface::new_patch(const string& path, uint32_t poly)
{
PatchModel* pm = new PatchModel(path, poly);
- PluginModel* pi = new PluginModel(PluginModel::Patch);
- pm->plugin(pi);
+ //PluginModel* pi = new PluginModel(PluginModel::Patch);
+ //pm->plugin(pi);
new_patch_model(pm);
}
@@ -95,8 +95,7 @@ ModelClientInterface::new_node(const string& plugin_type,
PluginModel* plugin = new PluginModel(plugin_type, plugin_uri);
- NodeModel* nm = new NodeModel(node_path);
- nm->plugin(plugin);
+ NodeModel* nm = new NodeModel(plugin, node_path);
new_node_model(nm);
}
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index efdae494..3e060401 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -21,6 +21,15 @@
namespace LibOmClient {
+NodeModel::NodeModel(CountedPtr<PluginModel> plugin, const Path& path)
+: ObjectModel(path),
+ m_polyphonic(false),
+ m_plugin(plugin),
+ m_x(0.0f),
+ m_y(0.0f)
+{
+}
+
NodeModel::NodeModel(const Path& path)
: ObjectModel(path),
m_polyphonic(false),
@@ -30,10 +39,11 @@ NodeModel::NodeModel(const Path& path)
{
}
+
NodeModel::~NodeModel()
{
- for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i)
- delete(*i);
+ /*for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i)
+ delete(*i);*/
}
@@ -52,8 +62,8 @@ NodeModel::remove_port(const string& port_path)
void
NodeModel::clear()
{
- for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i)
- delete (*i);
+ /*for (PortModelList::iterator i = m_ports.begin(); i != m_ports.end(); ++i)
+ delete (*i);*/
m_ports.clear();
@@ -77,20 +87,22 @@ NodeModel::set_path(const Path& p)
void
-NodeModel::add_port(PortModel* pm)
+NodeModel::add_port(CountedPtr<PortModel> pm)
{
assert(pm->name() != "");
assert(pm->path().length() > m_path.length());
assert(pm->path().substr(0, m_path.length()) == m_path);
assert(pm->parent() == NULL);
- assert(get_port(pm->name()) == NULL);
+ assert(!get_port(pm->name()));
m_ports.push_back(pm);
pm->set_parent(this);
+
+ new_port_sig.emit(pm);
}
-PortModel*
+CountedPtr<PortModel>
NodeModel::get_port(const string& port_name)
{
assert(port_name.find("/") == string::npos);
diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h
index af4171ed..05df5ed5 100644
--- a/src/libs/client/NodeModel.h
+++ b/src/libs/client/NodeModel.h
@@ -21,9 +21,12 @@
#include <map>
#include <iostream>
#include <string>
+#include <sigc++/sigc++.h>
#include "ObjectModel.h"
#include "PortModel.h"
#include "util/Path.h"
+#include "util/CountedPtr.h"
+#include "PluginModel.h"
using std::string; using std::map; using std::find;
using std::cout; using std::cerr; using std::endl;
@@ -41,11 +44,11 @@ class PluginModel;
class NodeModel : public ObjectModel
{
public:
- NodeModel(const Path& node_path);
+ NodeModel(CountedPtr<PluginModel> plugin, const Path& path);
virtual ~NodeModel();
- PortModel* get_port(const string& port_name);
- void add_port(PortModel* pm);
+ CountedPtr<PortModel> get_port(const string& port_name);
+ void add_port(CountedPtr<PortModel> pm);
void remove_port(const string& port_path);
virtual void clear();
@@ -54,8 +57,8 @@ public:
void add_program(int bank, int program, const string& name);
void remove_program(int bank, int program);
- const PluginModel* plugin() const { return m_plugin; }
- void plugin(const PluginModel* const pi) { m_plugin = pi; }
+ CountedPtr<PluginModel> plugin() const { return m_plugin; }
+ //void plugin(CountedPtr<PluginModel> p) { m_plugin = p; }
virtual void set_path(const Path& p);
@@ -70,10 +73,15 @@ public:
PatchModel* parent_patch() const { return (PatchModel*)m_parent; }
+ // Signals
+ sigc::signal<void, CountedPtr<PortModel> > new_port_sig;
+
protected:
+ NodeModel(const Path& path);
+
bool m_polyphonic;
PortModelList m_ports; ///< List of ports (instead of map to preserve order)
- const PluginModel* m_plugin; ///< The plugin this node is an instance of
+ CountedPtr<PluginModel> m_plugin; ///< The plugin this node is an instance of
float m_x; ///< Just metadata, here as an optimization for OmGtk
float m_y; ///< Just metadata, here as an optimization for OmGtk
map<int, map<int, string> > m_banks; ///< DSSI banks
@@ -85,7 +93,7 @@ private:
};
-typedef map<string, NodeModel*> NodeModelMap;
+typedef map<string, CountedPtr<NodeModel> > NodeModelMap;
} // namespace LibOmClient
diff --git a/src/libs/client/PatchLibrarian.cpp b/src/libs/client/PatchLibrarian.cpp
index 65323435..5c8619f5 100644
--- a/src/libs/client/PatchLibrarian.cpp
+++ b/src/libs/client/PatchLibrarian.cpp
@@ -167,10 +167,10 @@ PatchLibrarian::save_patch(PatchModel* patch_model, const string& filename, bool
// Save nodes and subpatches
for (NodeModelMap::const_iterator i = patch_model->nodes().begin(); i != patch_model->nodes().end(); ++i) {
- nm = i->second;
+ nm = i->second.get();
if (nm->plugin()->type() == PluginModel::Patch) { // Subpatch
- spm = (PatchModel*)i->second;
+ spm = (PatchModel*)i->second.get();
xml_node = xmlNewChild(xml_root_node, NULL, (xmlChar*)"subpatch", NULL);
xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"name", (xmlChar*)spm->name().c_str());
@@ -216,7 +216,7 @@ PatchLibrarian::save_patch(PatchModel* patch_model, const string& filename, bool
xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"name", (xmlChar*)nm->name().c_str());
- if (nm->plugin() == NULL) break;
+ if (!nm->plugin()) break;
xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"polyphonic",
(xmlChar*)((nm->polyphonic()) ? "true" : "false"));
@@ -255,10 +255,9 @@ PatchLibrarian::save_patch(PatchModel* patch_model, const string& filename, bool
}
}
- PortModel* pm = NULL;
// Write port metadata, if necessary
- for (list<PortModel*>::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) {
- pm = (*i);
+ for (PortModelList::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) {
+ const PortModel* const pm = (*i).get();
if (pm->is_input() && pm->user_min() != pm->min_val() || pm->user_max() != pm->max_val()) {
xml_child_node = xmlNewChild(xml_node, NULL, (xmlChar*)"port", NULL);
xml_grandchild_node = xmlNewChild(xml_child_node, NULL, (xmlChar*)"name",
@@ -299,9 +298,9 @@ PatchLibrarian::save_patch(PatchModel* patch_model, const string& filename, bool
// Save node port controls
for (NodeModelMap::const_iterator n = patch_model->nodes().begin(); n != patch_model->nodes().end(); ++n) {
- nm = n->second;
+ nm = n->second.get();
for (PortModelList::const_iterator p = nm->ports().begin(); p != nm->ports().end(); ++p) {
- pm = *p;
+ pm = (*p).get();
if (pm->is_input() && pm->is_control()) {
float val = pm->value();
xml_node = xmlNewChild(xml_preset_node, NULL, (xmlChar*)"control", NULL);
@@ -319,7 +318,7 @@ PatchLibrarian::save_patch(PatchModel* patch_model, const string& filename, bool
// Save patch port controls
for (PortModelList::const_iterator p = patch_model->ports().begin();
p != patch_model->ports().end(); ++p) {
- pm = *p;
+ pm = (*p).get();
if (pm->is_input() && pm->is_control()) {
float val = pm->value();
xml_node = xmlNewChild(xml_preset_node, NULL, (xmlChar*)"control", NULL);
@@ -480,8 +479,7 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing)
if (nm != NULL) {
m_osc_model_engine_interface->create_node_from_model(nm);
m_osc_model_engine_interface->set_all_metadata(nm);
- for (list<PortModel*>::const_iterator j = nm->ports().begin();
- j != nm->ports().end(); ++j) {
+ for (PortModelList::const_iterator j = nm->ports().begin(); j != nm->ports().end(); ++j) {
// FIXME: ew
snprintf(temp_buf, temp_buf_length, "%f", (*j)->user_min());
m_osc_model_engine_interface->set_metadata((*j)->path(), "user-min", temp_buf);
@@ -550,8 +548,8 @@ PatchLibrarian::load_patch(PatchModel* pm, bool wait, bool existing)
NodeModel*
PatchLibrarian::parse_node(const PatchModel* parent, xmlDocPtr doc, const xmlNodePtr node)
{
- NodeModel* nm = new NodeModel("/UNINITIALIZED"); // FIXME: ew
PluginModel* plugin = new PluginModel();
+ NodeModel* nm = new NodeModel(plugin, "/UNINITIALIZED"); // FIXME: ew
xmlChar* key;
xmlNodePtr cur = node->xmlChildrenNode;
@@ -667,7 +665,7 @@ PatchLibrarian::parse_node(const PatchModel* parent, xmlDocPtr doc, const xmlNod
delete nm;
return NULL;
} else {
- nm->plugin(plugin);
+ //nm->plugin(plugin);
return nm;
}
}
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 829c9ca5..4257dd30 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -54,19 +54,21 @@ PatchModel::get_node(const string& name)
{
assert(name.find("/") == string::npos);
NodeModelMap::iterator i = m_nodes.find(name);
- return ((i != m_nodes.end()) ? (*i).second : NULL);
+ return ((i != m_nodes.end()) ? (*i).second.get() : NULL);
}
void
-PatchModel::add_node(NodeModel* nm)
+PatchModel::add_node(CountedPtr<NodeModel> nm)
{
- assert(nm != NULL);
+ assert(nm);
assert(nm->name().find("/") == string::npos);
assert(nm->parent() == NULL);
- m_nodes[nm->name()] = nm;
+ m_nodes[nm->name()] = CountedPtr<NodeModel>(nm);
nm->set_parent(this);
+
+ new_node_sig.emit(nm);
}
@@ -76,7 +78,7 @@ PatchModel::remove_node(const string& name)
assert(name.find("/") == string::npos);
NodeModelMap::iterator i = m_nodes.find(name);
if (i != m_nodes.end()) {
- delete i->second;
+ //delete i->second;
m_nodes.erase(i);
return;
}
@@ -93,7 +95,7 @@ PatchModel::clear()
for (NodeModelMap::iterator i = m_nodes.begin(); i != m_nodes.end(); ++i) {
(*i).second->clear();
- delete (*i).second;
+ //delete (*i).second;
}
m_nodes.clear();
@@ -122,7 +124,7 @@ PatchModel::rename_node(const Path& old_path, const Path& new_path)
NodeModel* nm = NULL;
if (i != m_nodes.end()) {
- nm = (*i).second;
+ nm = (*i).second.get();
for (list<ConnectionModel*>::iterator j = m_connections.begin(); j != m_connections.end(); ++j) {
if ((*j)->src_port_path().parent() == old_path)
(*j)->src_port_path(new_path.base_path() + (*j)->src_port_path().name());
@@ -172,9 +174,9 @@ PatchModel::add_connection(ConnectionModel* cm)
}
NodeModel* src_node = get_node(cm->src_port_path().parent().name());
- PortModel* src_port = (src_node == NULL) ? NULL : src_node->get_port(cm->src_port_path().name());
+ PortModel* src_port = (src_node == NULL) ? NULL : src_node->get_port(cm->src_port_path().name()).get();
NodeModel* dst_node = get_node(cm->dst_port_path().parent().name());
- PortModel* dst_port = (dst_node == NULL) ? NULL : dst_node->get_port(cm->dst_port_path().name());
+ PortModel* dst_port = (dst_node == NULL) ? NULL : dst_node->get_port(cm->dst_port_path().name()).get();
assert(src_port != NULL);
assert(dst_port != NULL);
diff --git a/src/libs/client/PatchModel.h b/src/libs/client/PatchModel.h
index 12871933..15677c50 100644
--- a/src/libs/client/PatchModel.h
+++ b/src/libs/client/PatchModel.h
@@ -21,7 +21,9 @@
#include <list>
#include <string>
#include <map>
+#include <sigc++/sigc++.h>
#include "NodeModel.h"
+#include "util/CountedPtr.h"
using std::list; using std::string; using std::map;
@@ -49,7 +51,7 @@ public:
virtual void set_path(const Path& path);
NodeModel* get_node(const string& node_name);
- void add_node(NodeModel* nm);
+ void add_node(CountedPtr<NodeModel> nm);
void remove_node(const string& name);
void rename_node(const Path& old_path, const Path& new_path);
@@ -68,6 +70,9 @@ public:
void enabled(bool b) { m_enabled = b; }
bool polyphonic() const;
+ // Signals
+ sigc::signal<void, CountedPtr<NodeModel> > new_node_sig;
+
private:
// Prevent copies (undefined)
PatchModel(const PatchModel& copy);
diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h
index 6d0895cf..9847bb1e 100644
--- a/src/libs/client/PortModel.h
+++ b/src/libs/client/PortModel.h
@@ -21,6 +21,7 @@
#include <string>
#include <list>
#include "ObjectModel.h"
+#include "util/CountedPtr.h"
using std::string; using std::list;
namespace LibOmClient {
@@ -110,7 +111,7 @@ private:
bool m_connected;
};
-typedef list<PortModel*> PortModelList;
+typedef list<CountedPtr<PortModel> > PortModelList;
} // namespace LibOmClient
diff --git a/src/libs/client/ThreadedSigClientInterface.cpp b/src/libs/client/ThreadedSigClientInterface.cpp
index 860d91f6..4af7d805 100644
--- a/src/libs/client/ThreadedSigClientInterface.cpp
+++ b/src/libs/client/ThreadedSigClientInterface.cpp
@@ -26,8 +26,6 @@ namespace LibOmClient {
void
ThreadedSigClientInterface::push_sig(Closure ev)
{
- cerr << "-- pushing event\n";
-
bool success = false;
bool first = true;
@@ -58,7 +56,6 @@ ThreadedSigClientInterface::emit_signals()
// thread indefinitely while processing continually arriving events
size_t num_processed = 0;
while (!_sigs.is_empty() && num_processed++ < _sigs.capacity()/2) {
- cerr << "-- emitting event\n";
Closure& ev = _sigs.pop();
ev();
ev.disconnect();
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