summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/ObjectStore.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-26 19:16:52 +0000
committerDavid Robillard <d@drobilla.net>2007-07-26 19:16:52 +0000
commitbee242f29045b82e50a4f112ac17f7e14344df78 (patch)
treee3c43801ab004b4b15581c63fff61dea33bcc104 /src/libs/engine/ObjectStore.hpp
parent90cb0280fdb356bc1474be31a15f8c6f24ed95ee (diff)
downloadingen-bee242f29045b82e50a4f112ac17f7e14344df78.tar.gz
ingen-bee242f29045b82e50a4f112ac17f7e14344df78.tar.bz2
ingen-bee242f29045b82e50a4f112ac17f7e14344df78.zip
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
Diffstat (limited to 'src/libs/engine/ObjectStore.hpp')
-rw-r--r--src/libs/engine/ObjectStore.hpp34
1 files changed, 22 insertions, 12 deletions
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;
};