From bee242f29045b82e50a4f112ac17f7e14344df78 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 26 Jul 2007 19:16:52 +0000 Subject: Use PathTable for engine side objects. Re-implement renaming and destroying more cleanly (not to mention workingly). git-svn-id: http://svn.drobilla.net/lad/ingen@638 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/ObjectStore.hpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/libs/engine/ObjectStore.hpp') 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 -#include -#include "Tree.hpp" +#include 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 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* o); - TreeNode* remove(const string& key); + Objects::iterator find(const Path& path) { return _objects.find(path); } - const Tree& objects() { return _objects; } + void add(GraphObject* o); + void add(const Table& family); + //void add(TreeNode* o); + + Table remove(const Path& path); + Table remove(Objects::iterator i); + + const Objects& objects() const { return _objects; } + Objects& objects() { return _objects; } private: - Tree _objects; + Objects _objects; }; -- cgit v1.2.1