summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-16 03:23:15 +0000
committerDavid Robillard <d@drobilla.net>2008-08-16 03:23:15 +0000
commita8b36b5637acb3fa8eb29ef0f45bd11653f412fa (patch)
tree3a0f0dbef302269f8e509d9f5c2d4c713e00face /src/libs/engine
parent49e8582cb6720d43389e7d2534be11a4fb0b8959 (diff)
downloadingen-a8b36b5637acb3fa8eb29ef0f45bd11653f412fa.tar.gz
ingen-a8b36b5637acb3fa8eb29ef0f45bd11653f412fa.tar.bz2
ingen-a8b36b5637acb3fa8eb29ef0f45bd11653f412fa.zip
Factor out common store functionality.
Make store is-a Table and ditch store->objects() thing everywhere. Use a separate store in the client (fix ingen -eg). git-svn-id: http://svn.drobilla.net/lad/ingen@1397 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/Engine.cpp4
-rw-r--r--src/libs/engine/EngineStore.cpp74
-rw-r--r--src/libs/engine/EngineStore.hpp26
-rw-r--r--src/libs/engine/HTTPEngineReceiver.cpp8
-rw-r--r--src/libs/engine/events/ClearPatchEvent.cpp2
-rw-r--r--src/libs/engine/events/DestroyEvent.cpp6
-rw-r--r--src/libs/engine/events/DestroyEvent.hpp2
-rw-r--r--src/libs/engine/events/RenameEvent.cpp4
-rw-r--r--src/libs/engine/events/RenameEvent.hpp2
9 files changed, 46 insertions, 82 deletions
diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp
index 382f44b9..13fcafa0 100644
--- a/src/libs/engine/Engine.cpp
+++ b/src/libs/engine/Engine.cpp
@@ -75,8 +75,8 @@ Engine::~Engine()
{
deactivate();
- for (EngineStore::Objects::iterator i = object_store()->objects().begin();
- i != object_store()->objects().end(); ++i) {
+ for (EngineStore::iterator i = object_store()->begin();
+ i != object_store()->end(); ++i) {
if ( ! PtrCast<GraphObjectImpl>(i->second)->parent() )
i->second.reset();
}
diff --git a/src/libs/engine/EngineStore.cpp b/src/libs/engine/EngineStore.cpp
index 90268e9b..5f5e41e5 100644
--- a/src/libs/engine/EngineStore.cpp
+++ b/src/libs/engine/EngineStore.cpp
@@ -67,27 +67,8 @@ EngineStore::find_port(const Path& path)
GraphObjectImpl*
EngineStore::find_object(const Path& path)
{
- Objects::iterator i = _objects.find(path);
- return ((i == _objects.end()) ? NULL : dynamic_cast<GraphObjectImpl*>(i->second.get()));
-}
-
-
-EngineStore::Objects::const_iterator
-EngineStore::children_begin(SharedPtr<Shared::GraphObject> o) const
-{
- Objects::const_iterator parent = _objects.find(o->path());
- assert(parent != _objects.end());
- ++parent;
- return parent;
-}
-
-
-EngineStore::Objects::const_iterator
-EngineStore::children_end(SharedPtr<Shared::GraphObject> o) const
-{
- Objects::const_iterator parent = _objects.find(o->path());
- assert(parent != _objects.end());
- return _objects.find_descendants_end(parent);
+ iterator i = find(path);
+ return ((i == end()) ? NULL : dynamic_cast<GraphObjectImpl*>(i->second.get()));
}
@@ -101,12 +82,12 @@ EngineStore::add(GraphObject* obj)
assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- if (_objects.find(o->path()) != _objects.end()) {
+ if (find(o->path()) != end()) {
cerr << "[EngineStore] ERROR: Attempt to add duplicate object " << o->path() << endl;
return;
}
- _objects.insert(make_pair(o->path(), o));
+ insert(make_pair(o->path(), o));
NodeImpl* node = dynamic_cast<NodeImpl*>(o);
if (node) {
@@ -120,15 +101,15 @@ EngineStore::add(GraphObject* obj)
/** Add a family of objects to the store. Not realtime safe.
*/
void
-EngineStore::add(const Table<Path, SharedPtr<Shared::GraphObject> >& table)
+EngineStore::add(const Objects& table)
{
assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
//cerr << "[EngineStore] Adding " << o[0].second->path() << endl;
- _objects.cram(table);
+ cram(table);
/*cerr << "[EngineStore] Adding Table:" << endl;
- for (Objects::const_iterator i = table.begin(); i != table.end(); ++i) {
+ for (const_iterator i = table.begin(); i != table.end(); ++i) {
cerr << i->first << " = " << i->second->path() << endl;
}*/
}
@@ -139,10 +120,10 @@ EngineStore::add(const Table<Path, SharedPtr<Shared::GraphObject> >& table)
* Returned is a vector containing all descendants of the object removed
* including the object itself, in lexicographically sorted order by Path.
*/
-SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
+SharedPtr<EngineStore::Objects>
EngineStore::remove(const Path& path)
{
- return remove(_objects.find(path));
+ return remove(find(path));
}
@@ -151,17 +132,16 @@ EngineStore::remove(const Path& path)
* Returned is a vector containing all descendants of the object removed
* including the object itself, in lexicographically sorted order by Path.
*/
-SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
-EngineStore::remove(Objects::iterator object)
+SharedPtr<EngineStore::Objects>
+EngineStore::remove(iterator object)
{
assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS);
- if (object != _objects.end()) {
- Objects::iterator descendants_end = _objects.find_descendants_end(object);
+ if (object != end()) {
+ iterator descendants_end = find_descendants_end(object);
//cout << "[EngineStore] Removing " << object->first << " {" << endl;
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed
- = _objects.yank(object, descendants_end);
- /*for (Objects::iterator i = removed->begin(); i != removed->end(); ++i) {
+ SharedPtr<Objects> removed = yank(object, descendants_end);
+ /*for (iterator i = removed->begin(); i != removed->end(); ++i) {
cout << "\t" << i->first << endl;
}
cout << "}" << endl;*/
@@ -170,7 +150,7 @@ EngineStore::remove(Objects::iterator object)
} else {
cerr << "[EngineStore] WARNING: Removing " << object->first << " failed." << endl;
- return SharedPtr<Objects>();
+ return SharedPtr<EngineStore>();
}
}
@@ -180,10 +160,10 @@ EngineStore::remove(Objects::iterator object)
* Returned is a vector containing all descendants of the object removed
* in lexicographically sorted order by Path.
*/
-SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
+SharedPtr<EngineStore::Objects>
EngineStore::remove_children(const Path& path)
{
- return remove_children(_objects.find(path));
+ return remove_children(find(path));
}
@@ -192,24 +172,22 @@ EngineStore::remove_children(const Path& path)
* Returned is a vector containing all descendants of the object removed
* in lexicographically sorted order by Path.
*/
-SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
-EngineStore::remove_children(Objects::iterator object)
+SharedPtr<EngineStore::Objects>
+EngineStore::remove_children(iterator object)
{
- if (object != _objects.end()) {
- Objects::iterator descendants_end = _objects.find_descendants_end(object);
-
+ if (object != end()) {
+ iterator descendants_end = find_descendants_end(object);
if (descendants_end != object) {
- Objects::iterator first_child = object;
+ iterator first_child = object;
++first_child;
- return _objects.yank(first_child, descendants_end);
+ return yank(first_child, descendants_end);
}
-
} else {
cerr << "[EngineStore] WARNING: Removing children of " << object->first << " failed." << endl;
- return SharedPtr<Objects>();
+ return SharedPtr<EngineStore::Objects>();
}
- return SharedPtr<Objects>();
+ return SharedPtr<EngineStore::Objects>();
}
diff --git a/src/libs/engine/EngineStore.hpp b/src/libs/engine/EngineStore.hpp
index e128dde8..ad656aeb 100644
--- a/src/libs/engine/EngineStore.hpp
+++ b/src/libs/engine/EngineStore.hpp
@@ -48,32 +48,18 @@ class GraphObjectImpl;
class EngineStore : public Shared::Store
{
public:
- typedef Raul::PathTable< SharedPtr<Shared::GraphObject> > Objects;
-
PatchImpl* find_patch(const Path& path);
NodeImpl* find_node(const Path& path);
PortImpl* find_port(const Path& path);
GraphObjectImpl* find_object(const Path& path);
- Objects::iterator find(const Path& path) { return _objects.find(path); }
-
- Objects::const_iterator children_begin(SharedPtr<Shared::GraphObject> o) const;
- Objects::const_iterator children_end(SharedPtr<Shared::GraphObject> o) const;
-
void add(Shared::GraphObject* o);
- void add(const Table<Path, SharedPtr<Shared::GraphObject> >& family);
- //void add(TreeNode<GraphObjectImpl*>* o);
-
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove(const Path& path);
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove(Objects::iterator i);
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove_children(const Path& path);
- SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > remove_children(Objects::iterator i);
-
- const Objects& objects() const { return _objects; }
- Objects& objects() { return _objects; }
-
-private:
- Objects _objects;
+ void add(const Objects& family);
+
+ SharedPtr<Objects> remove(const Path& path);
+ SharedPtr<Objects> remove(Objects::iterator i);
+ SharedPtr<Objects> remove_children(const Path& path);
+ SharedPtr<Objects> remove_children(Objects::iterator i);
};
diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp
index ee16cf44..128b9e13 100644
--- a/src/libs/engine/HTTPEngineReceiver.cpp
+++ b/src/libs/engine/HTTPEngineReceiver.cpp
@@ -115,17 +115,17 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
return;
}
- Store::Objects::const_iterator start = store->find(path);
- if (start == store->objects().end()) {
+ Store::const_iterator start = store->find(path);
+ if (start == store->end()) {
soup_message_set_status (msg, SOUP_STATUS_NOT_FOUND);
return;
}
#if 0
- EngineStore::Objects::iterator end = store->objects().find_descendants_end(start);
+ EngineStore::iterator end = store->find_descendants_end(start);
string response;
- for (EngineStore::Objects::iterator i = start; i != end; ++i)
+ for (EngineStore::iterator i = start; i != end; ++i)
response.append(i->first).append("\n");
#endif
diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp
index 60b882f9..30b69915 100644
--- a/src/libs/engine/events/ClearPatchEvent.cpp
+++ b/src/libs/engine/events/ClearPatchEvent.cpp
@@ -49,7 +49,7 @@ ClearPatchEvent::pre_process()
{
EngineStore::Objects::iterator patch_iterator = _engine.object_store()->find(_patch_path);
- if (patch_iterator != _engine.object_store()->objects().end()) {
+ if (patch_iterator != _engine.object_store()->end()) {
_patch = PtrCast<PatchImpl>(patch_iterator->second);
if (_patch) {
_process = _patch->enabled();
diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp
index bdcb1ad2..6d1fc3fb 100644
--- a/src/libs/engine/events/DestroyEvent.cpp
+++ b/src/libs/engine/events/DestroyEvent.cpp
@@ -37,7 +37,7 @@ namespace Ingen {
DestroyEvent::DestroyEvent(Engine& engine, SharedPtr<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())
+ , _store_iterator(engine.object_store()->end())
, _driver_port(NULL)
, _patch_node_listnode(NULL)
, _patch_port_listnode(NULL)
@@ -60,14 +60,14 @@ DestroyEvent::pre_process()
{
_store_iterator = _engine.object_store()->find(_path);
- if (_store_iterator != _engine.object_store()->objects().end()) {
+ if (_store_iterator != _engine.object_store()->end()) {
_node = PtrCast<NodeImpl>(_store_iterator->second);
if (!_node)
_port = PtrCast<PortImpl>(_store_iterator->second);
}
- if (_store_iterator != _engine.object_store()->objects().end()) {
+ if (_store_iterator != _engine.object_store()->end()) {
_removed_table = _engine.object_store()->remove(_store_iterator);
}
diff --git a/src/libs/engine/events/DestroyEvent.hpp b/src/libs/engine/events/DestroyEvent.hpp
index c2cf9ed5..b24934f8 100644
--- a/src/libs/engine/events/DestroyEvent.hpp
+++ b/src/libs/engine/events/DestroyEvent.hpp
@@ -58,7 +58,7 @@ public:
private:
Path _path;
- EngineStore::Objects::iterator _store_iterator;
+ EngineStore::iterator _store_iterator;
SharedPtr<NodeImpl> _node; ///< Non-NULL iff a node
SharedPtr<PortImpl> _port; ///< Non-NULL iff a port
DriverPort* _driver_port;
diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp
index cd2189e8..73426a59 100644
--- a/src/libs/engine/events/RenameEvent.cpp
+++ b/src/libs/engine/events/RenameEvent.cpp
@@ -37,7 +37,7 @@ RenameEvent::RenameEvent(Engine& engine, SharedPtr<Responder> responder, SampleC
_name(name),
_new_path("/"),
_parent_patch(NULL),
- _store_iterator(engine.object_store()->objects().end()),
+ _store_iterator(engine.object_store()->end()),
_error(NO_ERROR)
{
/*
@@ -65,7 +65,7 @@ RenameEvent::pre_process()
_new_path = _old_path.parent().base() + _name;
_store_iterator = _engine.object_store()->find(_old_path);
- if (_store_iterator == _engine.object_store()->objects().end()) {
+ if (_store_iterator == _engine.object_store()->end()) {
_error = OBJECT_NOT_FOUND;
QueuedEvent::pre_process();
return;
diff --git a/src/libs/engine/events/RenameEvent.hpp b/src/libs/engine/events/RenameEvent.hpp
index 114b59fa..e230c589 100644
--- a/src/libs/engine/events/RenameEvent.hpp
+++ b/src/libs/engine/events/RenameEvent.hpp
@@ -54,7 +54,7 @@ private:
string _name;
Path _new_path;
PatchImpl* _parent_patch;
- EngineStore::Objects::iterator _store_iterator;
+ EngineStore::iterator _store_iterator;
ErrorType _error;
};