summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-11 23:33:00 +0000
committerDavid Robillard <d@drobilla.net>2006-06-11 23:33:00 +0000
commit0b1c17f08f8eab4ada52ee98ba7353ec0260d3eb (patch)
tree09af4447ba74f392d12f2153b432cb60be1c08ab /src/libs/client
parent228279d6717e69ffd2d2a886244179635ac27c2b (diff)
downloadingen-0b1c17f08f8eab4ada52ee98ba7353ec0260d3eb.tar.gz
ingen-0b1c17f08f8eab4ada52ee98ba7353ec0260d3eb.tar.bz2
ingen-0b1c17f08f8eab4ada52ee98ba7353ec0260d3eb.zip
New nodes in gtk client working through Store signal interface
git-svn-id: http://svn.drobilla.net/lad/grauph@26 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-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
9 files changed, 68 insertions, 46 deletions
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();