summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ObjectModel.hpp2
-rw-r--r--src/libs/client/PatchModel.cpp2
-rw-r--r--src/libs/client/Serializer.hpp4
-rw-r--r--src/libs/client/Store.cpp55
-rw-r--r--src/libs/client/Store.hpp8
5 files changed, 50 insertions, 21 deletions
diff --git a/src/libs/client/ObjectModel.hpp b/src/libs/client/ObjectModel.hpp
index fe0f223c..429f5359 100644
--- a/src/libs/client/ObjectModel.hpp
+++ b/src/libs/client/ObjectModel.hpp
@@ -81,7 +81,7 @@ protected:
ObjectModel(const Path& path);
- virtual void set_path(const Path& p) { _path = p; }
+ virtual void set_path(const Path& p) { _path = p; renamed_sig.emit(); }
virtual void set_parent(SharedPtr<ObjectModel> p) { assert(p); _parent = p; }
virtual void add_child(SharedPtr<ObjectModel> c);
virtual bool remove_child(SharedPtr<ObjectModel> c);
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 615ae562..f67c7706 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -30,7 +30,7 @@ namespace Client {
void
PatchModel::set_path(const Path& new_path)
{
- throw;
+ ObjectModel::set_path(new_path);
#if 0
// FIXME: haack
if (new_path == "") {
diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp
index 837d7333..23f93df6 100644
--- a/src/libs/client/Serializer.hpp
+++ b/src/libs/client/Serializer.hpp
@@ -28,7 +28,7 @@
#include <raul/Atom.hpp>
#include <raul/RDFWorld.hpp>
#include <raul/RDFModel.hpp>
-#include <raul/Table.hpp>
+#include <raul/PathTable.hpp>
#include "ObjectModel.hpp"
namespace Ingen {
@@ -72,7 +72,7 @@ private:
Raul::RDF::Node path_to_node_id(const Path& path);
- typedef Raul::Table<Path, Raul::RDF::Node> NodeMap;
+ typedef Raul::PathTable<Raul::RDF::Node> NodeMap;
Mode _mode;
NodeMap _node_map;
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index a2c9bf6f..674fc24e 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -24,11 +24,13 @@
#include "PatchModel.hpp"
#include "SigClientInterface.hpp"
+using namespace std;
+using Raul::Path;
+
namespace Ingen {
namespace Client {
-
Store::Store(SharedPtr<EngineInterface> engine, SharedPtr<SigClientInterface> emitter)
: _engine(engine)
, _emitter(emitter)
@@ -146,7 +148,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child)
{
cerr << "WARNING: Orphan object " << child->path() << " received." << endl;
- Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator children
+ Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator children
= _orphans.find(child->path().parent());
_engine->request_object(child->path().parent());
@@ -164,7 +166,7 @@ Store::add_orphan(SharedPtr<ObjectModel> child)
void
Store::add_metadata_orphan(const Path& subject_path, const string& predicate, const Atom& value)
{
- Raul::Table<Path, list<std::pair<string, Atom> > >::iterator orphans
+ Raul::PathTable<list<std::pair<string, Atom> > >::iterator orphans
= _metadata_orphans.find(subject_path);
_engine->request_object(subject_path);
@@ -182,7 +184,7 @@ Store::add_metadata_orphan(const Path& subject_path, const string& predicate, co
void
Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject)
{
- Raul::Table<Path, list<std::pair<string, Atom> > >::iterator v
+ Raul::PathTable<list<std::pair<string, Atom> > >::iterator v
= _metadata_orphans.find(subject->path());
if (v != _metadata_orphans.end()) {
@@ -202,7 +204,7 @@ Store::resolve_metadata_orphans(SharedPtr<ObjectModel> subject)
void
Store::resolve_orphans(SharedPtr<ObjectModel> parent)
{
- Raul::Table<Path, list<SharedPtr<ObjectModel> > >::iterator c
+ Raul::PathTable<list<SharedPtr<ObjectModel> > >::iterator c
= _orphans.find(parent->path());
if (c != _orphans.end()) {
@@ -257,7 +259,7 @@ Store::add_object(SharedPtr<ObjectModel> object)
}
- //cout << "[Store] Added " << object->path() << endl;
+ cout << "[Store] Added " << object->path() << endl;
}
@@ -348,14 +350,41 @@ 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 {
+ Objects::iterator parent = _objects.find(old_path);
+ if (parent == _objects.end()) {
cerr << "[Store] Failed to find object " << old_path << " to rename." << endl;
+ return;
+ }
+
+ Objects::iterator descendants_end = _objects.find_descendants_end(parent);
+
+ vector<pair<Path, SharedPtr<ObjectModel> > > objs = _objects.yank(parent, descendants_end);
+
+ assert(objs.size() > 0);
+
+ for (vector<pair<Path, SharedPtr<ObjectModel> > >::iterator i = objs.begin(); i != objs.end(); ++i) {
+ const Path& child_old_path = i->first;
+ assert(Path::descendant_comparator(old_path, child_old_path));
+
+ Path child_new_path;
+ if (child_old_path == old_path)
+ child_new_path = new_path;
+ else
+ child_new_path = new_path.base() + child_old_path.substr(old_path.length()+1);
+
+ cerr << "[Store] Renamed " << child_old_path << " -> " << child_new_path << endl;
+ i->second->set_path(child_new_path);
+ i->first = child_new_path;
+ }
+
+ _objects.cram(objs);
+
+ cerr << "[Store] Table:" << endl;
+ //for (size_t i=0; i < objs.size(); ++i) {
+ // cerr << objs[i].first << "\t\t: " << objs[i].second << endl;
+ //}
+ for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) {
+ cerr << i->first << "\t\t: " << i->second << endl;
}
}
diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp
index 627d6f8a..25398eaa 100644
--- a/src/libs/client/Store.hpp
+++ b/src/libs/client/Store.hpp
@@ -25,7 +25,7 @@
#include <sigc++/sigc++.h>
#include <raul/Path.hpp>
#include <raul/Atom.hpp>
-#include <raul/Table.hpp>
+#include <raul/PathTable.hpp>
#include <raul/TableImpl.hpp>
#include "interface/EngineInterface.hpp"
using std::string; using std::list;
@@ -63,7 +63,7 @@ public:
typedef Raul::Table<string, SharedPtr<PluginModel> > Plugins;
const Plugins& plugins() const { return _plugins; }
- typedef Raul::Table<Path, SharedPtr<ObjectModel> > Objects;
+ typedef Raul::PathTable<SharedPtr<ObjectModel> > Objects;
const Objects& objects() const { return _objects; }
sigc::signal<void, SharedPtr<ObjectModel> > new_object_sig;
@@ -113,14 +113,14 @@ private:
/** 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) */
- Raul::Table<Path, list<SharedPtr<ObjectModel> > > _orphans;
+ Raul::PathTable<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.. */
Raul::Table<string, list<SharedPtr<NodeModel> > > _plugin_orphans;
/** Not orphans OF metadata like the above, but orphans which are metadata */
- Raul::Table<Path, list<std::pair<string, Atom> > > _metadata_orphans;
+ Raul::PathTable<list<std::pair<string, Atom> > > _metadata_orphans;
/** Ditto */
list<SharedPtr<ConnectionModel> > _connection_orphans;