summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/DeprecatedLoader.cpp2
-rw-r--r--src/libs/client/NodeModel.cpp8
-rw-r--r--src/libs/client/NodeModel.hpp23
-rw-r--r--src/libs/client/ObjectModel.cpp48
-rw-r--r--src/libs/client/ObjectModel.hpp26
-rw-r--r--src/libs/client/PatchModel.cpp132
-rw-r--r--src/libs/client/PatchModel.hpp13
-rw-r--r--src/libs/client/PortModel.hpp2
-rw-r--r--src/libs/client/Serializer.cpp7
-rw-r--r--src/libs/client/Serializer.hpp4
-rw-r--r--src/libs/client/Store.cpp39
-rw-r--r--src/libs/client/Store.hpp17
12 files changed, 184 insertions, 137 deletions
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp
index c5354c5a..a98b7794 100644
--- a/src/libs/client/DeprecatedLoader.cpp
+++ b/src/libs/client/DeprecatedLoader.cpp
@@ -149,7 +149,7 @@ DeprecatedLoader::add_metadata(MetadataMap& data, string old_key, string value)
if (endptr != c_val && *endptr == '\0')
data[key] = Atom(fval);
else
- data[key]= Atom(value);
+ data[key] = Atom(value);
free(c_val);
}
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 39c31c82..58ddb56b 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -93,6 +93,8 @@ void
NodeModel::add_child(SharedPtr<ObjectModel> c)
{
assert(c->parent().get() == this);
+
+ ObjectModel::add_child(c);
SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
assert(pm);
@@ -100,15 +102,19 @@ NodeModel::add_child(SharedPtr<ObjectModel> c)
}
-void
+bool
NodeModel::remove_child(SharedPtr<ObjectModel> c)
{
assert(c->path().is_child_of(_path));
assert(c->parent().get() == this);
+
+ bool ret = ObjectModel::remove_child(c);
SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
assert(pm);
remove_port(pm);
+
+ return ret;
}
diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp
index 68027526..ccf2f1fb 100644
--- a/src/libs/client/NodeModel.hpp
+++ b/src/libs/client/NodeModel.hpp
@@ -19,18 +19,18 @@
#define NODEMODEL_H
#include <cstdlib>
-#include <map>
#include <iostream>
#include <string>
#include <sigc++/sigc++.h>
+#include <raul/Table.hpp>
#include "ObjectModel.hpp"
#include "PortModel.hpp"
#include <raul/Path.hpp>
#include <raul/SharedPtr.hpp>
#include "PluginModel.hpp"
-using std::string; using std::map; using std::find;
-using std::cout; using std::cerr; using std::endl;
+using std::string;
+using Raul::Table;
namespace Ingen {
namespace Client {
@@ -50,7 +50,8 @@ public:
SharedPtr<PortModel> get_port(const string& port_name) const;
- const map<int, map<int, string> >& get_programs() const { return _banks; }
+ const Table<int,Table<int,string> >& get_programs() const { return _banks; }
+
const string& plugin_uri() const { return _plugin_uri; }
SharedPtr<PluginModel> plugin() const { return _plugin; }
int num_ports() const { return _ports.size(); }
@@ -69,7 +70,7 @@ protected:
NodeModel(const Path& path);
void add_child(SharedPtr<ObjectModel> c);
- void remove_child(SharedPtr<ObjectModel> c);
+ bool remove_child(SharedPtr<ObjectModel> c);
void add_port(SharedPtr<PortModel> pm);
void remove_port(SharedPtr<PortModel> pm);
void remove_port(const Path& port_path);
@@ -81,15 +82,15 @@ protected:
friend class PatchModel;
void set_path(const Path& p);
- bool _polyphonic;
- PortModelList _ports; ///< List of ports (not a map to preserve order)
- string _plugin_uri; ///< Plugin URI (if PluginModel is unknown)
- SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of
- map<int, map<int, string> > _banks; ///< DSSI banks
+ bool _polyphonic;
+ PortModelList _ports; ///< List of ports (not a Table to preserve order)
+ string _plugin_uri; ///< Plugin URI (if PluginModel is unknown)
+ SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of
+ Table<int, Table<int, string> > _banks; ///< DSSI banks
};
-typedef map<string, SharedPtr<NodeModel> > NodeModelMap;
+typedef Table<string, SharedPtr<NodeModel> > NodeModelMap;
} // namespace Client
diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp
index 699d1ce7..f1393232 100644
--- a/src/libs/client/ObjectModel.cpp
+++ b/src/libs/client/ObjectModel.cpp
@@ -16,6 +16,10 @@
*/
#include "ObjectModel.hpp"
+#include <raul/TableImpl.hpp>
+#include <iostream>
+
+using namespace std;
namespace Ingen {
namespace Client {
@@ -31,6 +35,50 @@ ObjectModel::~ObjectModel()
{
}
+SharedPtr<ObjectModel>
+ObjectModel::get_child(const string& name) const
+{
+ assert(name.find("/") == string::npos);
+ Children::const_iterator i = _children.find(name);
+ return ((i != _children.end()) ? (*i).second : SharedPtr<ObjectModel>());
+}
+
+void
+ObjectModel::add_child(SharedPtr<ObjectModel> o)
+{
+ assert(o);
+ assert(o->path().is_child_of(_path));
+ assert(o->parent().get() == this);
+
+#ifndef NDEBUG
+ // Be sure there's no duplicates
+ Children::iterator existing = _children.find(o->path().name());
+ assert(existing == _children.end());
+#endif
+
+ _children.insert(make_pair(o->path().name(), o));
+ new_child_sig.emit(o);
+}
+
+bool
+ObjectModel::remove_child(SharedPtr<ObjectModel> o)
+{
+ assert(o->path().is_child_of(_path));
+ assert(o->parent().get() == this);
+
+ Children::iterator i = _children.find(o->path().name());
+ if (i != _children.end()) {
+ assert(i->second == o);
+ _children.erase(i);
+ removed_child_sig.emit(o);
+ return true;
+ } else {
+ cerr << "[ObjectModel::remove_child] " << _path
+ << ": failed to find child " << o->path().name() << endl;
+ return false;
+ }
+}
+
/** Get a piece of metadata for this object.
*
* @return Metadata value with key @a key, empty string otherwise.
diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp
index 03abafba..fe0f223c 100644
--- a/src/libs/client/ObjectModel.hpp
+++ b/src/libs/client/ObjectModel.hpp
@@ -19,7 +19,6 @@
#define OBJECTMODEL_H
#include <cstdlib>
-#include <map>
#include <iostream>
#include <string>
#include <algorithm>
@@ -29,16 +28,16 @@
#include <raul/Atom.hpp>
#include <raul/Path.hpp>
#include <raul/SharedPtr.hpp>
+#include <raul/Table.hpp>
-using std::string; using std::map; using std::find;
-using std::cout; using std::cerr; using std::endl;
+using std::string; using std::find;
using Raul::Atom;
using Raul::Path;
namespace Ingen {
namespace Client {
-typedef map<string, Atom> MetadataMap;
+typedef Raul::Table<string, Atom> MetadataMap;
/** Base class for all GraphObject models (NodeModel, PatchModel, PortModel).
@@ -59,34 +58,43 @@ public:
const Atom& get_metadata(const string& key) const;
void set_metadata(const string& key, const Atom& value)
- { _metadata[key] = value; metadata_update_sig.emit(key, value); }
+ { _metadata.insert(make_pair(key, value)); metadata_update_sig.emit(key, value); }
+
+ typedef Raul::Table<string, SharedPtr<ObjectModel> > Children;
const MetadataMap& metadata() const { return _metadata; }
+ const Children& children() const { return _children; }
inline const Path& path() const { return _path; }
SharedPtr<ObjectModel> parent() const { return _parent; }
+ SharedPtr<ObjectModel> get_child(const string& name) const;
+
// Signals
sigc::signal<void, const string&, const Atom&> metadata_update_sig;
+ sigc::signal<void, SharedPtr<ObjectModel> > new_child_sig;
+ sigc::signal<void, SharedPtr<ObjectModel> > removed_child_sig;
sigc::signal<void> destroyed_sig;
+ sigc::signal<void> renamed_sig;
protected:
friend class Store;
ObjectModel(const Path& path);
- virtual void set_path(const Path& p) { _path = p; }
+ virtual void set_path(const Path& p) { _path = p; }
virtual void set_parent(SharedPtr<ObjectModel> p) { assert(p); _parent = p; }
- virtual void add_child(SharedPtr<ObjectModel> c) = 0;
- virtual void remove_child(SharedPtr<ObjectModel> c) = 0;
+ virtual void add_child(SharedPtr<ObjectModel> c);
+ virtual bool remove_child(SharedPtr<ObjectModel> c);
void add_metadata(const MetadataMap& data);
void set(SharedPtr<ObjectModel> model);
- Path _path;
+ Path _path;
SharedPtr<ObjectModel> _parent;
MetadataMap _metadata;
+ Children _children;
};
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 85cf3dc7..615ae562 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -30,6 +30,8 @@ namespace Client {
void
PatchModel::set_path(const Path& new_path)
{
+ throw;
+#if 0
// FIXME: haack
if (new_path == "") {
_path = "";
@@ -37,7 +39,7 @@ PatchModel::set_path(const Path& new_path)
}
NodeModel::set_path(new_path);
- for (NodeModelMap::iterator i = _nodes.begin(); i != _nodes.end(); ++i)
+ for (Children::iterator i = _children.begin(); i != _children.end(); ++i)
(*i).second->set_path(_path +"/"+ (*i).second->path().name());
#ifdef DEBUG
@@ -48,6 +50,7 @@ PatchModel::set_path(const Path& new_path)
assert((*j)->src_port_path().parent().parent() == new_path);
}
#endif
+#endif
}
@@ -55,100 +58,65 @@ void
PatchModel::add_child(SharedPtr<ObjectModel> c)
{
assert(c->parent().get() == this);
-
- SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
- if (pm) {
- add_port(pm);
- return;
- }
- SharedPtr<NodeModel> nm = PtrCast<NodeModel>(c);
- if (nm) {
- add_node(nm);
- return;
- }
-}
-
-
-void
-PatchModel::remove_child(SharedPtr<ObjectModel> c)
-{
- assert(c->path().is_child_of(_path));
- assert(c->parent().get() == this);
+ ObjectModel::add_child(c);
SharedPtr<PortModel> pm = PtrCast<PortModel>(c);
if (pm) {
- remove_port(pm);
+ add_port(pm);
return;
}
SharedPtr<NodeModel> nm = PtrCast<NodeModel>(c);
- if (nm) {
- remove_node(nm);
- return;
- }
+ if (nm)
+ new_node_sig.emit(nm);
}
-
SharedPtr<NodeModel>
PatchModel::get_node(const string& name) const
{
- assert(name.find("/") == string::npos);
- NodeModelMap::const_iterator i = _nodes.find(name);
- return ((i != _nodes.end()) ? (*i).second : SharedPtr<NodeModel>());
+ return PtrCast<NodeModel>(get_child(name));
}
-void
-PatchModel::add_node(SharedPtr<NodeModel> nm)
+bool
+PatchModel::remove_child(SharedPtr<ObjectModel> o)
{
- assert(nm);
- assert(nm->path().is_child_of(_path));
- assert(nm->parent().get() == this);
-
- NodeModelMap::iterator existing = _nodes.find(nm->path().name());
+ assert(o->path().is_child_of(_path));
+ assert(o->parent().get() == this);
- // Store should have handled this by merging the two
- assert(existing == _nodes.end());
+ SharedPtr<PortModel> pm = PtrCast<PortModel>(o);
+ if (pm)
+ remove_port(pm);
+
+ // Remove any connections which referred to this object,
+ // since they can't possibly exist anymore
+ for (ConnectionList::iterator j = _connections.begin(); j != _connections.end() ; ) {
- _nodes[nm->path().name()] = nm;
- new_node_sig.emit(nm);
-}
+ list<SharedPtr<ConnectionModel> >::iterator next = j;
+ ++next;
+ SharedPtr<ConnectionModel> cm = (*j);
-void
-PatchModel::remove_node(SharedPtr<NodeModel> nm)
-{
- assert(nm->path().is_child_of(_path));
- assert(nm->parent().get() == this);
-
- NodeModelMap::iterator i = _nodes.find(nm->path().name());
- if (i != _nodes.end()) {
- assert(i->second == nm);
-
- // Remove any connections which referred to this node,
- // since they can't possibly exist anymore
- for (list<SharedPtr<ConnectionModel> >::iterator j = _connections.begin();
- j != _connections.end() ; ) {
- list<SharedPtr<ConnectionModel> >::iterator next = j;
- ++next;
- SharedPtr<ConnectionModel> cm = (*j);
- if (cm->src_port_path().parent() == nm->path()
- || cm->dst_port_path().parent() == nm->path()) {
- removed_connection_sig.emit(cm);
- _connections.erase(j); // cuts our reference
- assert(!get_connection(cm->src_port_path(), cm->dst_port_path())); // no duplicates
- }
- j = next;
+ if (cm->src_port_path().parent() == o->path()
+ || cm->src_port_path() == o->path()
+ || cm->dst_port_path().parent() == o->path()
+ || cm->dst_port_path() == o->path()) {
+ removed_connection_sig.emit(cm);
+ _connections.erase(j); // cuts our reference
+ assert(!get_connection(cm->src_port_path(), cm->dst_port_path())); // no duplicates
}
-
- // Remove the Node itself
- _nodes.erase(i);
- removed_node_sig.emit(nm);
+ j = next;
+ }
+ if (ObjectModel::remove_child(o)) {
+ SharedPtr<NodeModel> nm = PtrCast<NodeModel>(o);
+ if (nm) {
+ removed_node_sig.emit(nm);
+ }
+ return true;
} else {
- cerr << "[PatchModel::remove_node] " << _path
- << ": failed to find node " << nm->path().name() << endl;
+ return false;
}
}
@@ -157,10 +125,10 @@ void
PatchModel::remove_node(const string& name)
{
assert(name.find("/") == string::npos);
- NodeModelMap::iterator i = _nodes.find(name);
- if (i != _nodes.end()) {
+ NodeModelMap::iterator i = _children.find(name);
+ if (i != _children.end()) {
//delete i->second;
- _nodes.erase(i);
+ _children.erase(i);
removed_node_sig.emit(name);
i->second->parent().reset();
return;
@@ -176,17 +144,17 @@ PatchModel::clear()
//for (list<SharedPtr<ConnectionModel> >::iterator j = _connections.begin(); j != _connections.end(); ++j)
// delete (*j);
- for (NodeModelMap::iterator i = _nodes.begin(); i != _nodes.end(); ++i) {
+ /*for (Children::iterator i = _children.begin(); i != _children.end(); ++i) {
(*i).second->clear();
//delete (*i).second;
- }
+ }*/
- _nodes.clear();
+ _children.clear();
_connections.clear();
NodeModel::clear();
- assert(_nodes.empty());
+ assert(_children.empty());
assert(_connections.empty());
assert(_ports.empty());
}
@@ -205,9 +173,9 @@ PatchModel::rename_node(const Path& old_path, const Path& new_path)
assert(old_path.parent() == path());
assert(new_path.parent() == path());
- NodeModelMap::iterator i = _nodes.find(old_path.name());
+ NodeModelMap::iterator i = _children.find(old_path.name());
- if (i != _nodes.end()) {
+ if (i != _children.end()) {
SharedPtr<NodeModel> nm = (*i).second;
for (list<SharedPtr<ConnectionModel> >::iterator j = _connections.begin(); j != _connections.end(); ++j) {
if ((*j)->src_port_path().parent() == old_path)
@@ -215,9 +183,9 @@ PatchModel::rename_node(const Path& old_path, const Path& new_path)
if ((*j)->dst_port_path().parent() == old_path)
(*j)->dst_port_path(new_path.base() + (*j)->dst_port_path().name());
}
- _nodes.erase(i);
+ _children.erase(i);
assert(nm->path() == new_path);
- _nodes[new_path.name()] = nm;
+ _children[new_path.name()] = nm;
return;
}
diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp
index 55040858..af1ef101 100644
--- a/src/libs/client/PatchModel.hpp
+++ b/src/libs/client/PatchModel.hpp
@@ -21,13 +21,12 @@
#include <cassert>
#include <list>
#include <string>
-#include <map>
#include <sigc++/sigc++.h>
#include "NodeModel.hpp"
#include <raul/SharedPtr.hpp>
#include "ConnectionModel.hpp"
-using std::list; using std::string; using std::map;
+using std::list; using std::string;
namespace Ingen {
namespace Client {
@@ -42,7 +41,6 @@ class Store;
class PatchModel : public NodeModel
{
public:
- const NodeModelMap& nodes() const { return _nodes; }
const ConnectionList& connections() const { return _connections; }
SharedPtr<ConnectionModel> get_connection(const string& src_port_path, const string& dst_port_path) const;
@@ -79,10 +77,10 @@ private:
void disable();
void clear();
void set_path(const Path& path);
- void add_node(SharedPtr<NodeModel> nm);
- void remove_node(SharedPtr<NodeModel> nm);
+ //void add_node(SharedPtr<NodeModel> nm);
+ //void remove_node(SharedPtr<NodeModel> nm);
void add_child(SharedPtr<ObjectModel> c);
- void remove_child(SharedPtr<ObjectModel> c);
+ bool remove_child(SharedPtr<ObjectModel> c);
void add_connection(SharedPtr<ConnectionModel> cm);
void remove_connection(const string& src_port_path, const string& dst_port_path);
@@ -90,14 +88,13 @@ private:
void rename_node(const Path& old_path, const Path& new_path);
void rename_node_port(const Path& old_path, const Path& new_path);
- NodeModelMap _nodes;
ConnectionList _connections;
string _filename;
bool _enabled;
size_t _poly;
};
-typedef map<string, SharedPtr<PatchModel> > PatchModelMap;
+typedef Table<string, SharedPtr<PatchModel> > PatchModelMap;
} // namespace Client
diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp
index 25573226..cf8b94f0 100644
--- a/src/libs/client/PortModel.hpp
+++ b/src/libs/client/PortModel.hpp
@@ -85,7 +85,7 @@ private:
}
void add_child(SharedPtr<ObjectModel> c) { throw; }
- void remove_child(SharedPtr<ObjectModel> c) { throw; }
+ bool remove_child(SharedPtr<ObjectModel> c) { throw; }
void connected_to(SharedPtr<PortModel> p) { ++_connections; connection_sig.emit(p); }
void disconnected_from(SharedPtr<PortModel> p) { --_connections; disconnection_sig.emit(p); }
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp
index f0920be5..bf7a745e 100644
--- a/src/libs/client/Serializer.cpp
+++ b/src/libs/client/Serializer.cpp
@@ -250,17 +250,18 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch, const Node& patch_id)
}
}
- for (NodeModelMap::const_iterator n = patch->nodes().begin(); n != patch->nodes().end(); ++n) {
+ for (ObjectModel::Children::const_iterator n = patch->children().begin(); n != patch->children().end(); ++n) {
SharedPtr<PatchModel> patch = PtrCast<PatchModel>(n->second);
+ SharedPtr<NodeModel> node = PtrCast<NodeModel>(n->second);
if (patch) {
const Node subpatch_id = Node(_model->world(), Node::RESOURCE,
patch_id.to_string() + "#" + patch->path().substr(1));
_model->add_statement(patch_id, "ingen:node", subpatch_id);
serialize_patch(patch, subpatch_id);
- } else {
+ } else if (node) {
const Node node_id = path_to_node_id(n->second->path());
_model->add_statement(patch_id, "ingen:node", node_id);
- serialize_node(n->second, node_id);
+ serialize_node(node, node_id);
}
}
diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp
index a42d99fa..837d7333 100644
--- a/src/libs/client/Serializer.hpp
+++ b/src/libs/client/Serializer.hpp
@@ -28,6 +28,7 @@
#include <raul/Atom.hpp>
#include <raul/RDFWorld.hpp>
#include <raul/RDFModel.hpp>
+#include <raul/Table.hpp>
#include "ObjectModel.hpp"
namespace Ingen {
@@ -71,7 +72,8 @@ private:
Raul::RDF::Node path_to_node_id(const Path& path);
- typedef std::map<Path, Raul::RDF::Node> NodeMap;
+ typedef Raul::Table<Path, Raul::RDF::Node> NodeMap;
+
Mode _mode;
NodeMap _node_map;
string _base_uri;
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 61c02698..a2c9bf6f 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -34,6 +34,7 @@ Store::Store(SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> em
, _emitter(emitter)
{
emitter->object_destroyed_sig.connect(sigc::mem_fun(this, &Store::destruction_event));
+ emitter->object_renamed_sig.connect(sigc::mem_fun(this, &Store::rename_event));
emitter->new_plugin_sig.connect(sigc::mem_fun(this, &Store::new_plugin_event));
emitter->new_patch_sig.connect(sigc::mem_fun(this, &Store::new_patch_event));
emitter->new_node_sig.connect(sigc::mem_fun(this, &Store::new_node_event));
@@ -63,7 +64,7 @@ Store::add_plugin_orphan(SharedPtr<NodeModel> node)
cerr << "WARNING: Node " << node->path() << " received, but plugin "
<< node->plugin_uri() << " unknown." << endl;
- map<string, list<SharedPtr<NodeModel> > >::iterator spawn
+ Raul::Table<string, list<SharedPtr<NodeModel> > >::iterator spawn
= _plugin_orphans.find(node->plugin_uri());
_engine->request_plugin(node->plugin_uri());
@@ -81,7 +82,7 @@ Store::add_plugin_orphan(SharedPtr<NodeModel> node)
void
Store::resolve_plugin_orphans(SharedPtr<PluginModel> plugin)
{
- map<string, list<SharedPtr<NodeModel> > >::iterator n
+ Raul::Table<string, list<SharedPtr<NodeModel> > >::iterator n
= _plugin_orphans.find(plugin->uri());
if (n != _plugin_orphans.end()) {
@@ -145,7 +146,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child)
{
cerr << "WARNING: Orphan object " << child->path() << " received." << endl;
- map<Path, list<SharedPtr<ObjectModel> > >::iterator children
+ Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator children
= _orphans.find(child->path().parent());
_engine->request_object(child->path().parent());
@@ -155,7 +156,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child)
} else {
list<SharedPtr<ObjectModel> > l;
l.push_back(child);
- _orphans[child->path().parent()] = l;
+ _orphans.insert(make_pair(child->path().parent(), l));
}
}
@@ -163,7 +164,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child)
void
Store::add_metadata_orphan(const Path& subject_path, const string& predicate, const Atom& value)
{
- map<Path, list<std::pair<string, Atom> > >::iterator orphans
+ Raul::Table<Path, list<std::pair<string, Atom> > >::iterator orphans
= _metadata_orphans.find(subject_path);
_engine->request_object(subject_path);
@@ -181,7 +182,7 @@ Store::add_metadata_orphan(const Path& subject_path, const string& predicate, co
void
Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject)
{
- map<Path, list<std::pair<string, Atom> > >::iterator v
+ Raul::Table<Path, list<std::pair<string, Atom> > >::iterator v
= _metadata_orphans.find(subject->path());
if (v != _metadata_orphans.end()) {
@@ -201,7 +202,7 @@ Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject)
void
Store::resolve_orphans(SharedPtr<ObjectModel> parent)
{
- map<Path, list<SharedPtr<ObjectModel> > >::iterator c
+ Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator c
= _orphans.find(parent->path());
if (c != _orphans.end()) {
@@ -263,7 +264,7 @@ Store::add_object(SharedPtr<ObjectModel> object)
SharedPtr<ObjectModel>
Store::remove_object(const Path& path)
{
- map<Path, SharedPtr<ObjectModel> >::iterator i = _objects.find(path);
+ Objects::iterator i = _objects.find(path);
if (i != _objects.end()) {
assert((*i).second->path() == path);
@@ -298,7 +299,7 @@ SharedPtr<PluginModel>
Store::plugin(const string& uri)
{
assert(uri.length() > 0);
- map<string, SharedPtr<PluginModel> >::iterator i = _plugins.find(uri);
+ Plugins::iterator i = _plugins.find(uri);
if (i == _plugins.end())
return SharedPtr<PluginModel>();
else
@@ -310,7 +311,7 @@ SharedPtr<ObjectModel>
Store::object(const Path& path)
{
assert(path.length() > 0);
- map<Path, SharedPtr<ObjectModel> >::iterator i = _objects.find(path);
+ Objects::iterator i = _objects.find(path);
if (i == _objects.end()) {
return SharedPtr<ObjectModel>();
} else {
@@ -345,6 +346,20 @@ Store::destruction_event(const Path& path)
}
void
+Store::rename_event(const Path& old_path, const Path& new_path)
+{
+ SharedPtr<ObjectModel> object = remove_object(old_path);
+ if (object) {
+ object->set_path(new_path);
+ add_object(object);
+ object->renamed_sig.emit();
+ cerr << "[Store] Renamed " << old_path << " -> " << new_path << endl;
+ } else {
+ cerr << "[Store] Failed to find object " << old_path << " to rename." << endl;
+ }
+}
+
+void
Store::new_plugin_event(const string& uri, const string& type_uri, const string& name)
{
SharedPtr<PluginModel> p(new PluginModel(uri, type_uri, name));
@@ -412,8 +427,8 @@ Store::patch_cleared_event(const Path& path)
{
SharedPtr<PatchModel> patch = PtrCast<PatchModel>(object(path));
if (patch) {
- NodeModelMap children = patch->nodes(); // take a copy
- for (NodeModelMap::iterator i = children.begin(); i != children.end(); ++i) {
+ ObjectModel::Children children = patch->children(); // take a copy
+ for (ObjectModel::Children::iterator i = children.begin(); i != children.end(); ++i) {
destruction_event(i->second->path());
}
}
diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp
index 38814200..627d6f8a 100644
--- a/src/libs/client/Store.hpp
+++ b/src/libs/client/Store.hpp
@@ -20,14 +20,15 @@
#include <cassert>
#include <string>
-#include <map>
#include <list>
#include <raul/SharedPtr.hpp>
#include <sigc++/sigc++.h>
#include <raul/Path.hpp>
#include <raul/Atom.hpp>
+#include <raul/Table.hpp>
+#include <raul/TableImpl.hpp>
#include "interface/EngineInterface.hpp"
-using std::string; using std::map; using std::list;
+using std::string; using std::list;
using Ingen::Shared::EngineInterface;
using Raul::Path;
using Raul::Atom;
@@ -59,10 +60,10 @@ public:
size_t num_object() { return _objects.size(); }
- typedef map<string, SharedPtr<PluginModel> > Plugins;
+ typedef Raul::Table<string, SharedPtr<PluginModel> > Plugins;
const Plugins& plugins() const { return _plugins; }
- typedef map<Path, SharedPtr<ObjectModel> > Objects;
+ typedef Raul::Table<Path, SharedPtr<ObjectModel> > Objects;
const Objects& objects() const { return _objects; }
sigc::signal<void, SharedPtr<ObjectModel> > new_object_sig;
@@ -91,6 +92,7 @@ private:
// Slots for SigClientInterface signals
void destruction_event(const Path& path);
+ void rename_event(const Path& old_path, const Path& new_path);
void new_plugin_event(const string& uri, const string& type_uri, const string& name);
void new_patch_event(const Path& path, uint32_t poly);
void new_node_event(const string& plugin_uri, const Path& node_path, bool is_polyphonic, uint32_t num_ports);
@@ -106,20 +108,19 @@ private:
SharedPtr<EngineInterface> _engine;
SharedPtr<SigClientInterface> _emitter;
-
Objects _objects; ///< Map, keyed by Ingen path
Plugins _plugins; ///< Map, keyed by plugin URI
/** Objects we've received, but depend on the existance of another unknown object.
* Keyed by the path of the depended-on object (for tolerance of orderless comms) */
- map<Path, list<SharedPtr<ObjectModel> > > _orphans;
+ Raul::Table<Path, list<SharedPtr<ObjectModel> > > _orphans;
/** Same idea, except with plugins instead of parents.
* It's unfortunate everything doesn't just have a URI and this was the same.. ahem.. */
- map<string, list<SharedPtr<NodeModel> > > _plugin_orphans;
+ Raul::Table<string, list<SharedPtr<NodeModel> > > _plugin_orphans;
/** Not orphans OF metadata like the above, but orphans which are metadata */
- map<Path, list<std::pair<string, Atom> > > _metadata_orphans;
+ Raul::Table<Path, list<std::pair<string, Atom> > > _metadata_orphans;
/** Ditto */
list<SharedPtr<ConnectionModel> > _connection_orphans;