summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/Store.cpp21
-rw-r--r--src/libs/engine/Engine.cpp9
-rw-r--r--src/libs/engine/GraphObject.cpp4
-rw-r--r--src/libs/engine/GraphObject.hpp4
-rw-r--r--src/libs/engine/NodeBase.cpp3
-rw-r--r--src/libs/engine/NodeBase.hpp3
-rw-r--r--src/libs/engine/ObjectStore.cpp95
-rw-r--r--src/libs/engine/ObjectStore.hpp34
-rw-r--r--src/libs/engine/Patch.cpp4
-rw-r--r--src/libs/engine/Patch.hpp4
-rw-r--r--src/libs/engine/events/AddNodeEvent.cpp5
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp5
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp3
-rw-r--r--src/libs/engine/events/CreatePatchEvent.cpp5
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp26
-rw-r--r--src/libs/engine/events/DestroyEvent.hpp28
-rw-r--r--src/libs/engine/events/RenameEvent.cpp45
-rw-r--r--src/libs/engine/events/RenameEvent.hpp15
-rw-r--r--src/libs/engine/events/RequestMetadataEvent.cpp2
-rw-r--r--src/libs/engine/events/RequestObjectEvent.cpp2
-rw-r--r--src/libs/engine/events/SetMetadataEvent.cpp2
21 files changed, 200 insertions, 119 deletions
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 674fc24e..360b1053 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -15,6 +15,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <raul/PathTable.hpp>
#include "Store.hpp"
#include "ObjectModel.hpp"
#include "PatchModel.hpp"
@@ -25,7 +26,7 @@
#include "SigClientInterface.hpp"
using namespace std;
-using Raul::Path;
+using namespace Raul;
namespace Ingen {
namespace Client {
@@ -358,11 +359,11 @@ Store::rename_event(const Path& old_path, const Path& new_path)
Objects::iterator descendants_end = _objects.find_descendants_end(parent);
- vector<pair<Path, SharedPtr<ObjectModel> > > objs = _objects.yank(parent, descendants_end);
+ Table<Path,SharedPtr<ObjectModel> > removed = _objects.yank(parent, descendants_end);
- assert(objs.size() > 0);
+ assert(removed.size() > 0);
- for (vector<pair<Path, SharedPtr<ObjectModel> > >::iterator i = objs.begin(); i != objs.end(); ++i) {
+ for (Table<Path,SharedPtr<ObjectModel> >::iterator i = removed.begin(); i != removed.end(); ++i) {
const Path& child_old_path = i->first;
assert(Path::descendant_comparator(old_path, child_old_path));
@@ -377,15 +378,15 @@ Store::rename_event(const Path& old_path, const Path& new_path)
i->first = child_new_path;
}
- _objects.cram(objs);
+ _objects.cram(removed);
- cerr << "[Store] Table:" << endl;
- //for (size_t i=0; i < objs.size(); ++i) {
- // cerr << objs[i].first << "\t\t: " << objs[i].second << endl;
+ //cerr << "[Store] Table:" << endl;
+ //for (size_t i=0; i < removed.size(); ++i) {
+ // cerr << removed[i].first << "\t\t: " << removed[i].second << endl;
//}
- for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) {
+ /*for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) {
cerr << i->first << "\t\t: " << i->second << endl;
- }
+ }*/
}
void
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index 7b4c4f48..cbc4d507 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -72,10 +72,10 @@ Engine::~Engine()
{
deactivate();
- for (Tree<GraphObject*>::iterator i = _object_store->objects().begin();
+ for (ObjectStore::Objects::const_iterator i = _object_store->objects().begin();
i != _object_store->objects().end(); ++i) {
- if ((*i)->parent() == NULL)
- delete (*i);
+ if ( ! i->second->parent())
+ delete i->second;
}
delete _object_store;
@@ -212,7 +212,8 @@ Engine::activate()
Patch* root_patch = new Patch("", 1, NULL,
_audio_driver->sample_rate(), _audio_driver->buffer_size(), 1);
root_patch->activate();
- root_patch->add_to_store(_object_store);
+ //root_patch->add_to_store(_object_store);
+ _object_store->add(root_patch);
root_patch->process_order(root_patch->build_process_order());
root_patch->enable();
diff --git a/src/libs/engine/GraphObject.cpp b/src/libs/engine/GraphObject.cpp
index 48a513bc..5f44ad2d 100644
--- a/src/libs/engine/GraphObject.cpp
+++ b/src/libs/engine/GraphObject.cpp
@@ -30,7 +30,7 @@ GraphObject::parent_patch() const
// FIXME: these functions are stupid/ugly
-
+#if 0
void
GraphObject::add_to_store(ObjectStore* store)
{
@@ -55,6 +55,6 @@ GraphObject::remove_from_store()
_store = NULL;
}
-
+#endif
} // namespace Ingen
diff --git a/src/libs/engine/GraphObject.hpp b/src/libs/engine/GraphObject.hpp
index d5ffb4b8..ad49bcc5 100644
--- a/src/libs/engine/GraphObject.hpp
+++ b/src/libs/engine/GraphObject.hpp
@@ -85,13 +85,13 @@ public:
const MetadataMap& metadata() const { return _metadata; }
-
+#if 0
/** Patch and Node override this to recursively add their children. */
virtual void add_to_store(ObjectStore* store);
/** Patch and Node override this to recursively remove their children. */
virtual void remove_from_store();
-
+#endif
/** The Patch this object is a child of. */
virtual Patch* parent_patch() const;
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index 203dc823..24faee4b 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -78,7 +78,7 @@ NodeBase::deactivate()
_activated = false;
}
-
+#if 0
void
NodeBase::add_to_store(ObjectStore* store)
{
@@ -110,6 +110,7 @@ NodeBase::remove_from_store()
assert(_store == NULL);
}
+#endif
void
diff --git a/src/libs/engine/NodeBase.hpp b/src/libs/engine/NodeBase.hpp
index 46c004df..4d20e4fb 100644
--- a/src/libs/engine/NodeBase.hpp
+++ b/src/libs/engine/NodeBase.hpp
@@ -60,9 +60,10 @@ public:
virtual void set_port_buffer(size_t voice, size_t port_num, Buffer* buf) {}
virtual void set_buffer_size(size_t size);
-
+#if 0
void add_to_store(ObjectStore* store);
void remove_from_store();
+#endif
SampleRate sample_rate() const { return _srate; }
size_t buffer_size() const { return _buffer_size; }
diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp
index 293adbef..f263db74 100644
--- a/src/libs/engine/ObjectStore.cpp
+++ b/src/libs/engine/ObjectStore.cpp
@@ -15,13 +15,19 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <utility>
+#include <vector>
#include <raul/List.hpp>
-#include <raul/Path.hpp>
+#include <raul/PathTable.hpp>
+#include <raul/TableImpl.hpp>
#include "ObjectStore.hpp"
#include "Patch.hpp"
#include "Node.hpp"
#include "Port.hpp"
-#include "Tree.hpp"
+#include "ThreadManager.hpp"
+
+using namespace std;
+using namespace Raul;
namespace Ingen {
@@ -31,7 +37,7 @@ namespace Ingen {
Patch*
ObjectStore::find_patch(const Path& path)
{
- GraphObject* const object = find(path);
+ GraphObject* const object = find_object(path);
return dynamic_cast<Patch*>(object);
}
@@ -41,7 +47,7 @@ ObjectStore::find_patch(const Path& path)
Node*
ObjectStore::find_node(const Path& path)
{
- GraphObject* const object = find(path);
+ GraphObject* const object = find_object(path);
return dynamic_cast<Node*>(object);
}
@@ -51,7 +57,7 @@ ObjectStore::find_node(const Path& path)
Port*
ObjectStore::find_port(const Path& path)
{
- GraphObject* const object = find(path);
+ GraphObject* const object = find_object(path);
return dynamic_cast<Port*>(object);
}
@@ -59,9 +65,10 @@ ObjectStore::find_port(const Path& path)
/** Find the Object at the given path.
*/
GraphObject*
-ObjectStore::find(const Path& path)
+ObjectStore::find_object(const Path& path)
{
- return _objects.find(path);
+ Objects::iterator i = _objects.find(path);
+ return ((i == _objects.end()) ? NULL : i->second);
}
@@ -70,11 +77,37 @@ ObjectStore::find(const Path& path)
void
ObjectStore::add(GraphObject* o)
{
+ assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
+
cerr << "[ObjectStore] Adding " << o->path() << endl;
- _objects.insert(new TreeNode<GraphObject*>(o->path(), o));
+ _objects.insert(make_pair(o->path(), o));
+
+ Node* node = dynamic_cast<Node*>(o);
+ if (node) {
+ for (size_t i=0; i < node->num_ports(); ++i) {
+ add(node->ports().at(i));
+ }
+ }
}
+/** Add a family of objects to the store. Not realtime safe.
+ */
+void
+ObjectStore::add(const Table<Path,GraphObject*>& table)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
+
+ //cerr << "[ObjectStore] Adding " << o[0].second->path() << endl;
+ _objects.cram(table);
+
+ cerr << "[ObjectStore] Adding Table:" << endl;
+ for (Table<Path,GraphObject*>::const_iterator i = table.begin(); i != table.end(); ++i) {
+ cerr << i->first << " = " << i->second->path() << endl;
+ }
+}
+
+#if 0
/** Add an object to the store. Not realtime safe.
*/
void
@@ -83,25 +116,45 @@ ObjectStore::add(TreeNode<GraphObject*>* tn)
cerr << "[ObjectStore] Adding " << tn->key() << endl;
_objects.insert(tn);
}
+#endif
-
-/** Remove a patch from the store.
+/** Remove an object from the store.
*
- * It it the caller's responsibility to delete the returned Raul::ListNode.
- *
- * @returns TreeNode containing object removed on success, NULL if not found.
+ * Returned is a vector containing all descendants of the object removed
+ * including the object itself, in lexicographically sorted order by Path.
*/
-TreeNode<GraphObject*>*
-ObjectStore::remove(const string& path)
+Table<Path,GraphObject*>
+ObjectStore::remove(const Path& path)
{
- TreeNode<GraphObject*>* const removed = _objects.remove(path);
+ return remove(_objects.find(path));
+}
- if (removed == NULL)
- cerr << "[ObjectStore] WARNING: Removing " << path << " failed." << endl;
- else
- cerr << "[ObjectStore] Removed " << path << endl;
+
+/** Remove an object from the store.
+ *
+ * Returned is a vector containing all descendants of the object removed
+ * including the object itself, in lexicographically sorted order by Path.
+ */
+Table<Path,GraphObject*>
+ObjectStore::remove(Objects::iterator object)
+{
+ assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- return removed;
+ if (object != _objects.end()) {
+ Objects::iterator descendants_end = _objects.find_descendants_end(object);
+ cout << "[ObjectStore] Removing " << object->first << " {" << endl;
+ Table<Path,GraphObject*> removed = _objects.yank(object, descendants_end);
+ for (Table<Path,GraphObject*>::iterator i = removed.begin(); i != removed.end(); ++i) {
+ cout << "\t" << i->first << endl;
+ }
+ cout << "}" << endl;
+
+ return removed;
+
+ } else {
+ cerr << "[ObjectStore] WARNING: Removing " << object->first << " failed." << endl;
+ return Table<Path,GraphObject*>();
+ }
}
diff --git a/src/libs/engine/ObjectStore.hpp b/src/libs/engine/ObjectStore.hpp
index 9d56cb77..c61d4130 100644
--- a/src/libs/engine/ObjectStore.hpp
+++ b/src/libs/engine/ObjectStore.hpp
@@ -19,11 +19,10 @@
#define OBJECTSTORE_H
#include <string>
-#include <raul/Path.hpp>
-#include "Tree.hpp"
+#include <raul/PathTable.hpp>
using std::string;
-using Raul::Path;
+using namespace Raul;
namespace Ingen {
@@ -38,23 +37,34 @@ class GraphObject;
* All looking up in pre_process() methods (and anything else that isn't in-band
* with the audio thread) should use this (to read and modify the GraphObject
* tree).
+ *
+ * Searching with find*() is fast (O(log(n)) binary search on contiguous
+ * memory) and realtime safe, but modification (add or remove) are neither.
*/
class ObjectStore
{
public:
- Patch* find_patch(const Path& path);
- Node* find_node(const Path& path);
- Port* find_port(const Path& path);
- GraphObject* find(const Path& path);
+ typedef Raul::PathTable<GraphObject*> Objects;
+
+ Patch* find_patch(const Path& path);
+ Node* find_node(const Path& path);
+ Port* find_port(const Path& path);
+ GraphObject* find_object(const Path& path);
- void add(GraphObject* o);
- void add(TreeNode<GraphObject*>* o);
- TreeNode<GraphObject*>* remove(const string& key);
+ Objects::iterator find(const Path& path) { return _objects.find(path); }
- const Tree<GraphObject*>& objects() { return _objects; }
+ void add(GraphObject* o);
+ void add(const Table<Path,GraphObject*>& family);
+ //void add(TreeNode<GraphObject*>* o);
+
+ Table<Path,GraphObject*> remove(const Path& path);
+ Table<Path,GraphObject*> remove(Objects::iterator i);
+
+ const Objects& objects() const { return _objects; }
+ Objects& objects() { return _objects; }
private:
- Tree<GraphObject*> _objects;
+ Objects _objects;
};
diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp
index 16d2365f..fb1b970e 100644
--- a/src/libs/engine/Patch.cpp
+++ b/src/libs/engine/Patch.cpp
@@ -148,7 +148,7 @@ Patch::set_buffer_size(size_t size)
(*j)->set_buffer_size(size);
}
-
+#if 0
void
Patch::add_to_store(ObjectStore* store)
{
@@ -171,7 +171,7 @@ Patch::remove_from_store()
for (Raul::List<Node*>::iterator j = _nodes.begin(); j != _nodes.end(); ++j)
(*j)->remove_from_store();
}
-
+#endif
// Patch specific stuff
diff --git a/src/libs/engine/Patch.hpp b/src/libs/engine/Patch.hpp
index 7422f551..f016f95d 100644
--- a/src/libs/engine/Patch.hpp
+++ b/src/libs/engine/Patch.hpp
@@ -58,10 +58,10 @@ public:
void process(SampleCount nframes, FrameTime start, FrameTime end);
void set_buffer_size(size_t size);
-
+#if 0
void add_to_store(ObjectStore* store);
void remove_from_store();
-
+#endif
void set_path(const Path& new_path);
// Patch specific stuff not inherited from Node
diff --git a/src/libs/engine/events/AddNodeEvent.cpp b/src/libs/engine/events/AddNodeEvent.cpp
index fd95e838..f1aa3aed 100644
--- a/src/libs/engine/events/AddNodeEvent.cpp
+++ b/src/libs/engine/events/AddNodeEvent.cpp
@@ -71,7 +71,7 @@ AddNodeEvent::AddNodeEvent(Engine& engine, SharedPtr<Shared::Responder> responde
void
AddNodeEvent::pre_process()
{
- if (_engine.object_store()->find(_path) != NULL) {
+ if (_engine.object_store()->find_object(_path) != NULL) {
_node_already_exists = true;
QueuedEvent::pre_process();
return;
@@ -95,7 +95,8 @@ AddNodeEvent::pre_process()
// This can be done here because the audio thread doesn't touch the
// node tree - just the process order array
_patch->add_node(new Raul::ListNode<Node*>(_node));
- _node->add_to_store(_engine.object_store());
+ //_node->add_to_store(_engine.object_store());
+ _engine.object_store()->add(_node);
// FIXME: not really necessary to build process order since it's not connected,
// just append to the list
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index c4e7a26c..6288a03f 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -75,7 +75,7 @@ AddPortEvent::AddPortEvent(Engine& engine,
void
AddPortEvent::pre_process()
{
- if (_engine.object_store()->find(_path) != NULL) {
+ if (_engine.object_store()->find_object(_path) != NULL) {
QueuedEvent::pre_process();
return;
}
@@ -109,7 +109,8 @@ AddPortEvent::pre_process()
_ports_array->at(_patch->num_ports()-1) = _patch_port;
- _patch_port->add_to_store(_engine.object_store());
+ //_patch_port->add_to_store(_engine.object_store());
+ _engine.object_store()->add(_patch_port);
if (!_patch->parent()) {
if (_type == "ingen:audio")
diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp
index 8ac8c23d..0269aaa7 100644
--- a/src/libs/engine/events/ClearPatchEvent.cpp
+++ b/src/libs/engine/events/ClearPatchEvent.cpp
@@ -43,6 +43,8 @@ ClearPatchEvent::ClearPatchEvent(Engine& engine, SharedPtr<Shared::Responder> re
void
ClearPatchEvent::pre_process()
{
+ cerr << "FIXME: CLEAR PATCH\n";
+#if 0
_patch = _engine.object_store()->find_patch(_patch_path);
if (_patch != NULL) {
@@ -52,6 +54,7 @@ ClearPatchEvent::pre_process()
for (Raul::List<Node*>::const_iterator i = _patch->nodes().begin(); i != _patch->nodes().end(); ++i)
(*i)->remove_from_store();
}
+#endif
QueuedEvent::pre_process();
}
diff --git a/src/libs/engine/events/CreatePatchEvent.cpp b/src/libs/engine/events/CreatePatchEvent.cpp
index 866420d7..24339320 100644
--- a/src/libs/engine/events/CreatePatchEvent.cpp
+++ b/src/libs/engine/events/CreatePatchEvent.cpp
@@ -46,7 +46,7 @@ CreatePatchEvent::CreatePatchEvent(Engine& engine, SharedPtr<Shared::Responder>
void
CreatePatchEvent::pre_process()
{
- if (_path == "/" || _engine.object_store()->find(_path) != NULL) {
+ if (_path == "/" || _engine.object_store()->find_object(_path) != NULL) {
_error = OBJECT_EXISTS;
QueuedEvent::pre_process();
return;
@@ -81,7 +81,8 @@ CreatePatchEvent::pre_process()
_patch->activate();
// Insert into ObjectStore
- _patch->add_to_store(_engine.object_store());
+ //_patch->add_to_store(_engine.object_store());
+ _engine.object_store()->add(_patch);
QueuedEvent::pre_process();
}
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index dde2e86b..91b12af0 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -40,13 +40,13 @@ namespace Ingen {
DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool block)
: QueuedEvent(engine, responder, time, source, source),
_path(path),
+ _store_iterator(engine.object_store()->objects().end()),
_object(NULL),
_node(NULL),
_port(NULL),
_driver_port(NULL),
_patch_node_listnode(NULL),
_patch_port_listnode(NULL),
- _store_treenode(NULL),
_ports_array(NULL),
_process_order(NULL),
_disconnect_node_event(NULL),
@@ -55,10 +55,11 @@ DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responde
assert(_source);
}
-
+#if 0
DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responder, FrameTime time, QueuedEventSource* source, Node* node, bool block)
: QueuedEvent(engine, responder, block, source),
_path(node->path()),
+ _store_iterator(engine.object_store()->objects().end())
_object(node),
_node(node),
_port(NULL),
@@ -72,7 +73,7 @@ DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responde
_disconnect_port_event(NULL)
{
}
-
+#endif
DestroyEvent::~DestroyEvent()
{
@@ -84,16 +85,20 @@ DestroyEvent::~DestroyEvent()
void
DestroyEvent::pre_process()
{
- if (_object == NULL) {
- _object = _engine.object_store()->find(_path);
+ //if (_object == NULL) {
+ _store_iterator = _engine.object_store()->find(_path);
+ //_object = _engine.object_store()->find_object(_path);
- if (_object) {
+ if (_store_iterator != _engine.object_store()->objects().end()) {
_node = dynamic_cast<Node*>(_object);
if (!_node)
_port = dynamic_cast<Port*>(_object);
}
- }
+ //}
+
+ if (_store_iterator != _engine.object_store()->objects().end())
+ _engine.object_store()->remove(_store_iterator);
if (_node != NULL && _path != "/") {
assert(_node->parent_patch());
@@ -101,11 +106,12 @@ DestroyEvent::pre_process()
if (_patch_node_listnode) {
assert(_patch_node_listnode->elem() == _node);
- _node->remove_from_store();
-
_disconnect_node_event = new DisconnectNodeEvent(_engine, _node);
_disconnect_node_event->pre_process();
+ //_node->remove_from_store();
+ _engine.object_store()->remove(_store_iterator);
+
if (_node->parent_patch()->enabled()) {
// FIXME: is this called multiple times?
_process_order = _node->parent_patch()->build_process_order();
@@ -128,7 +134,7 @@ DestroyEvent::pre_process()
if (_patch_port_listnode) {
assert(_patch_port_listnode->elem() == _port);
- _port->remove_from_store();
+ //_port->remove_from_store();
_disconnect_port_event = new DisconnectPortEvent(_engine, _port);
_disconnect_port_event->pre_process();
diff --git a/src/libs/engine/events/DestroyEvent.hpp b/src/libs/engine/events/DestroyEvent.hpp
index 6495258e..0a855951 100644
--- a/src/libs/engine/events/DestroyEvent.hpp
+++ b/src/libs/engine/events/DestroyEvent.hpp
@@ -21,7 +21,7 @@
#include <string>
#include <raul/Path.hpp>
#include "QueuedEvent.hpp"
-
+#include "ObjectStore.hpp"
using std::string;
@@ -51,7 +51,7 @@ class DestroyEvent : public QueuedEvent
{
public:
DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responder, FrameTime timestamp, QueuedEventSource* source, const string& path, bool block = true);
- DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responder, FrameTime timestamp, QueuedEventSource* source, Node* node, bool block = true);
+ //DestroyEvent(Engine& engine, SharedPtr<Shared::Responder> responder, FrameTime timestamp, QueuedEventSource* source, Node* node, bool block = true);
~DestroyEvent();
void pre_process();
@@ -59,18 +59,18 @@ public:
void post_process();
private:
- Path _path;
- GraphObject* _object;
- Node* _node; ///< Same as _object if it is a Node, otherwise NULL
- Port* _port; ///< Same as _object if it is a Port, otherwise NULL
- DriverPort* _driver_port;
- Raul::ListNode<Node*>* _patch_node_listnode;
- Raul::ListNode<Port*>* _patch_port_listnode;
- TreeNode<GraphObject*>* _store_treenode;
- Raul::Array<Port*>* _ports_array; ///< New (external) ports array for Patch
- Raul::Array<Node*>* _process_order; ///< Patch's new process order
- DisconnectNodeEvent* _disconnect_node_event;
- DisconnectPortEvent* _disconnect_port_event;
+ Path _path;
+ ObjectStore::Objects::iterator _store_iterator;
+ GraphObject* _object;
+ Node* _node; ///< Same as _object if it is a Node, otherwise NULL
+ Port* _port; ///< Same as _object if it is a Port, otherwise NULL
+ DriverPort* _driver_port;
+ Raul::ListNode<Node*>* _patch_node_listnode;
+ Raul::ListNode<Port*>* _patch_port_listnode;
+ Raul::Array<Port*>* _ports_array; ///< New (external) ports array for Patch
+ Raul::Array<Node*>* _process_order; ///< Patch's new process order
+ DisconnectNodeEvent* _disconnect_node_event;
+ DisconnectPortEvent* _disconnect_port_event;
};
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index 0a2b0239..a7dc4874 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -25,6 +25,8 @@
#include <raul/Path.hpp>
#include "ObjectStore.hpp"
+using namespace std;
+
namespace Ingen {
@@ -34,7 +36,7 @@ RenameEvent::RenameEvent(Engine& engine, SharedPtr<Shared::Responder> responder,
_name(name),
_new_path(_old_path.parent().base() + name),
_parent_patch(NULL),
- _store_treenode(NULL),
+ _store_iterator(engine.object_store()->objects().end()),
_error(NO_ERROR)
{
/*
@@ -59,34 +61,33 @@ RenameEvent::pre_process()
return;
}
- if (_engine.object_store()->find(_new_path)) {
- _error = OBJECT_EXISTS;
- QueuedEvent::pre_process();
- return;
- }
-
- TreeNode<GraphObject*>* obj = _engine.object_store()->remove(_old_path);
-
- if (obj == NULL) {
+ _store_iterator = _engine.object_store()->find(_old_path);
+ if (_store_iterator == _engine.object_store()->objects().end()) {
_error = OBJECT_NOT_FOUND;
QueuedEvent::pre_process();
return;
}
- // Renaming only works for Nodes and Patches (which are Nodes)
- /*if (obj->as_node() == NULL) {
- _error = OBJECT_NOT_RENAMABLE;
- QueuedEvent::pre_process();
- return;
- }*/
+ Table<Path,GraphObject*> removed = _engine.object_store()->remove(_store_iterator);
+ assert(removed.size() > 0);
- if (obj != NULL) {
- obj->node()->set_path(_new_path);
- obj->key(_new_path);
- _engine.object_store()->add(obj);
- assert(obj->node()->path() == _new_path);
+ for (Table<Path,GraphObject*>::iterator i = removed.begin(); i != removed.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 << "Renamed " << child_old_path << " -> " << child_new_path << endl;
+ i->second->set_path(child_new_path);
+ i->first = child_new_path;
}
-
+
+ _engine.object_store()->add(removed);
+
QueuedEvent::pre_process();
}
diff --git a/src/libs/engine/events/RenameEvent.hpp b/src/libs/engine/events/RenameEvent.hpp
index f50efcc7..52a3050e 100644
--- a/src/libs/engine/events/RenameEvent.hpp
+++ b/src/libs/engine/events/RenameEvent.hpp
@@ -19,8 +19,9 @@
#define RENAMEEVENT_H
#include <string>
-#include "QueuedEvent.hpp"
#include <raul/Path.hpp>
+#include "QueuedEvent.hpp"
+#include "ObjectStore.hpp"
using std::string;
@@ -54,12 +55,12 @@ public:
private:
enum ErrorType { NO_ERROR, OBJECT_NOT_FOUND, OBJECT_EXISTS, OBJECT_NOT_RENAMABLE, INVALID_NAME };
- Path _old_path;
- string _name;
- Path _new_path;
- Patch* _parent_patch;
- TreeNode<GraphObject*>* _store_treenode;
- ErrorType _error;
+ Path _old_path;
+ string _name;
+ Path _new_path;
+ Patch* _parent_patch;
+ ObjectStore::Objects::iterator _store_iterator;
+ ErrorType _error;
};
diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp
index b9696c4a..9540d738 100644
--- a/src/libs/engine/events/RequestMetadataEvent.cpp
+++ b/src/libs/engine/events/RequestMetadataEvent.cpp
@@ -44,7 +44,7 @@ RequestMetadataEvent::pre_process()
_client = _engine.broadcaster()->client(_responder->client_uri());
if (_client) {
- _object = _engine.object_store()->find(_path);
+ _object = _engine.object_store()->find_object(_path);
if (_object == NULL) {
QueuedEvent::pre_process();
return;
diff --git a/src/libs/engine/events/RequestObjectEvent.cpp b/src/libs/engine/events/RequestObjectEvent.cpp
index 8efe37b7..745b10c1 100644
--- a/src/libs/engine/events/RequestObjectEvent.cpp
+++ b/src/libs/engine/events/RequestObjectEvent.cpp
@@ -44,7 +44,7 @@ void
RequestObjectEvent::pre_process()
{
_client = _engine.broadcaster()->client(_responder->client_uri());
- _object = _engine.object_store()->find(_path);
+ _object = _engine.object_store()->find_object(_path);
QueuedEvent::pre_process();
}
diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp
index caa1b449..4a93bed6 100644
--- a/src/libs/engine/events/SetMetadataEvent.cpp
+++ b/src/libs/engine/events/SetMetadataEvent.cpp
@@ -41,7 +41,7 @@ SetMetadataEvent::SetMetadataEvent(Engine& engine, SharedPtr<Shared::Responder>
void
SetMetadataEvent::pre_process()
{
- _object = _engine.object_store()->find(_path);
+ _object = _engine.object_store()->find_object(_path);
if (_object == NULL) {
QueuedEvent::pre_process();
return;