From 471c9e43493ab1d3a83ed6a8ca53bd818a2ed275 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Jun 2006 23:17:46 +0000 Subject: More thorough assertion checking in CountedPtr; Adding plugins to subpatches working. git-svn-id: http://svn.drobilla.net/lad/grauph@46 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/Store.cpp | 44 ++++++++++++++++++++++---------------------- src/libs/client/Store.h | 4 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/libs/client') diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index ef70dc28..34b86e2e 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -101,7 +101,6 @@ Store::patch(const string& path) if (i == m_objects.end()) return NULL; else - //return dynamic_cast((*i).second.get()); return (CountedPtr)(*i).second; // FIXME } @@ -207,18 +206,16 @@ Store::new_patch_event(const string& path, uint32_t poly) // FIXME: What to do with a conflict? if (m_objects.find(path) == m_objects.end()) { - PatchModel* const p = new PatchModel(path, poly); + CountedPtr p(new PatchModel(path, poly)); add_object(p); - std::map >::iterator pi = m_objects.find(p->path().parent()); - if (pi != m_objects.end()) { - CountedPtr parent = (*pi).second; - if (parent) { - p->set_parent(parent); - parent->add_node(p); - } else { - cerr << "ERROR: new patch with no parent" << endl; - } + CountedPtr parent = object(p->path().parent()); + if (parent) { + p->set_parent(parent); + parent->add_node(p); + assert(p->parent() == parent); + } else { + cerr << "ERROR: new patch with no parent" << endl; } } } @@ -239,15 +236,16 @@ Store::new_node_event(const string& plugin_type, const string& plugin_uri, const // FIXME: num_ports unused add_object(n); - std::map >::iterator pi = m_objects.find(n->path().parent()); - if (pi != m_objects.end()) { - CountedPtr parent = (*pi).second; - if (parent) { - n->set_parent(parent); - parent->add_node(n); - } else { - cerr << "ERROR: new node with no parent" << endl; - } + //std::map >::iterator pi = m_objects.find(n->path().parent()); + //if (pi != m_objects.end()) { + CountedPtr parent = object(n->path().parent()); + if (parent) { + n->set_parent(parent); + assert(n->parent() == parent); + parent->add_node(n); + assert(n->parent() == parent); + } else { + cerr << "ERROR: new node with no parent" << endl; } } } @@ -289,10 +287,12 @@ Store::new_port_event(const string& path, const string& type, bool is_output) if (pi != m_objects.end()) { CountedPtr parent = (*pi).second; p->set_parent(parent); - if (parent) + if (parent) { parent->add_port(p); - else + assert(p->parent() == parent); + } else { cerr << "ERROR: new port with no parent" << endl; + } } } } diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h index 27850bcf..0b84d418 100644 --- a/src/libs/client/Store.h +++ b/src/libs/client/Store.h @@ -21,6 +21,7 @@ #include #include #include "util/CountedPtr.h" +#include using std::string; using std::map; namespace LibOmClient { @@ -36,7 +37,7 @@ class PortModel; * * \ingroup OmGtk */ -class Store { +class Store : public sigc::trackable { // FIXME: is trackable necessary? public: CountedPtr plugin(const string& uri); CountedPtr object(const string& path); @@ -46,7 +47,6 @@ public: size_t num_objects() { return m_objects.size(); } - const map >& plugins() const { return m_plugins; } static void instantiate(SigClientInterface& emitter) -- cgit v1.2.1