diff options
author | David Robillard <d@drobilla.net> | 2012-08-14 21:37:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-14 21:37:20 +0000 |
commit | 76b602f1f834cb2c255848c5ba887b3d7c47171a (patch) | |
tree | cbe6588c70f2df4384231d9cbdfd06fb0aa7e45f /src/server | |
parent | a8312be2d849b73ff0acc80a226095bcfee3556c (diff) | |
download | ingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.tar.gz ingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.tar.bz2 ingen-76b602f1f834cb2c255848c5ba887b3d7c47171a.zip |
Replace use of old Raul Table stuff with std::map.
Move most Store functionality into Ingen::Store and eliminate EngineStore.
Much cleaner delete and move implementations.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4696 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/Engine.cpp | 37 | ||||
-rw-r--r-- | src/server/Engine.hpp | 4 | ||||
-rw-r--r-- | src/server/EngineStore.cpp | 161 | ||||
-rw-r--r-- | src/server/EngineStore.hpp | 78 | ||||
-rw-r--r-- | src/server/events/Connect.cpp | 24 | ||||
-rw-r--r-- | src/server/events/CreateNode.cpp | 9 | ||||
-rw-r--r-- | src/server/events/CreatePatch.cpp | 10 | ||||
-rw-r--r-- | src/server/events/CreatePort.cpp | 13 | ||||
-rw-r--r-- | src/server/events/Delete.cpp | 18 | ||||
-rw-r--r-- | src/server/events/Delete.hpp | 6 | ||||
-rw-r--r-- | src/server/events/Delta.cpp | 8 | ||||
-rw-r--r-- | src/server/events/Disconnect.cpp | 15 | ||||
-rw-r--r-- | src/server/events/DisconnectAll.cpp | 9 | ||||
-rw-r--r-- | src/server/events/Get.cpp | 6 | ||||
-rw-r--r-- | src/server/events/Get.hpp | 2 | ||||
-rw-r--r-- | src/server/events/Move.cpp | 39 | ||||
-rw-r--r-- | src/server/events/Move.hpp | 12 | ||||
-rw-r--r-- | src/server/events/SetPortValue.cpp | 2 | ||||
-rw-r--r-- | src/server/wscript | 1 |
19 files changed, 101 insertions, 353 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 372090ef..c3c1221f 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -30,7 +30,6 @@ #include "ControlBindings.hpp" #include "Driver.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "Event.hpp" #include "EventWriter.hpp" #include "NodeFactory.hpp" @@ -49,12 +48,13 @@ namespace Server { Raul::ThreadVar<unsigned> ThreadManager::flags(0); bool ThreadManager::single_threaded(true); -Engine::Engine(Ingen::World* a_world) - : _world(a_world) +Engine::Engine(Ingen::World* world) + : _world(world) , _broadcaster(new Broadcaster()) + , _buffer_factory(new BufferFactory(*this, world->uris())) , _control_bindings(NULL) , _maid(new Raul::Maid(event_queue_size())) - , _node_factory(new NodeFactory(a_world)) + , _node_factory(new NodeFactory(world)) , _pre_processor(new PreProcessor()) , _post_processor(new PostProcessor(*this)) , _event_writer(new EventWriter(*this)) @@ -64,14 +64,8 @@ Engine::Engine(Ingen::World* a_world) , _quit_flag(false) , _direct_driver(true) { - if (a_world->store()) { - SharedPtr<EngineStore> estore = PtrCast<EngineStore>(a_world->store()); - _buffer_factory = estore->buffer_factory().get(); - } else { - _buffer_factory = new BufferFactory(*this, a_world->uris()); - a_world->set_store( - SharedPtr<Ingen::Store>( - new EngineStore(SharedPtr<BufferFactory>(_buffer_factory)))); + if (!world->store()) { + world->set_store(SharedPtr<Ingen::Store>(new Store())); } _control_bindings = new ControlBindings(*this); @@ -83,11 +77,16 @@ Engine::~Engine() { deactivate(); - SharedPtr<EngineStore> store = engine_store(); - if (store) - for (EngineStore::iterator i = store->begin(); i != store->end(); ++i) - if (!PtrCast<GraphObjectImpl>(i->second)->parent()) + const SharedPtr<Store> s = this->store(); + if (s) { + for (Store::iterator i = s->begin(); i != s->end(); ++i) { + if (!PtrCast<GraphObjectImpl>(i->second)->parent()) { i->second.reset(); + } + } + } + + _world->set_store(SharedPtr<Ingen::Store>()); delete _maid; delete _pre_processor; @@ -100,10 +99,10 @@ Engine::~Engine() munlockall(); } -SharedPtr<EngineStore> -Engine::engine_store() const +SharedPtr<Store> +Engine::store() const { - return PtrCast<EngineStore>(_world->store()); + return _world->store(); } size_t diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index a54367d3..81cdc5d5 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -29,6 +29,7 @@ namespace Raul { class Maid; } namespace Ingen { +class Store; class World; namespace Server { @@ -37,7 +38,6 @@ class Broadcaster; class BufferFactory; class ControlBindings; class Driver; -class EngineStore; class Event; class EventWriter; class NodeFactory; @@ -104,7 +104,7 @@ public: ProcessContext& process_context() { return _process_context; } - SharedPtr<EngineStore> engine_store() const; + SharedPtr<Store> store() const; size_t event_queue_size() const; diff --git a/src/server/EngineStore.cpp b/src/server/EngineStore.cpp deleted file mode 100644 index 35ae6d83..00000000 --- a/src/server/EngineStore.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <utility> -#include "raul/log.hpp" -#include "raul/PathTable.hpp" -#include "raul/TableImpl.hpp" -#include "EngineStore.hpp" -#include "PatchImpl.hpp" -#include "NodeImpl.hpp" -#include "PortImpl.hpp" -#include "ThreadManager.hpp" - -#define LOG(s) s << "[EngineStore] " - -using namespace std; - -namespace Ingen { -namespace Server { - -EngineStore::~EngineStore() -{ - clear(); -} - -/** Find the Patch at the given path. - */ -PatchImpl* -EngineStore::find_patch(const Raul::Path& path) -{ - GraphObjectImpl* const object = find_object(path); - return dynamic_cast<PatchImpl*>(object); -} - -/** Find the Node at the given path. - */ -NodeImpl* -EngineStore::find_node(const Raul::Path& path) -{ - GraphObjectImpl* const object = find_object(path); - return dynamic_cast<NodeImpl*>(object); -} - -/** Find the Port at the given path. - */ -PortImpl* -EngineStore::find_port(const Raul::Path& path) -{ - GraphObjectImpl* const object = find_object(path); - return dynamic_cast<PortImpl*>(object); -} - -/** Find the Object at the given path. - */ -GraphObjectImpl* -EngineStore::find_object(const Raul::Path& path) -{ - iterator i = find(path); - return ((i == end()) ? NULL : dynamic_cast<GraphObjectImpl*>(i->second.get())); -} - -/** Add an object to the store. Not realtime safe. - */ -void -EngineStore::add(GraphObject* obj) -{ - ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Store::add(obj); -} - -/** Add a family of objects to the store. Not realtime safe. - */ -void -EngineStore::add(const Objects& table) -{ - ThreadManager::assert_thread(THREAD_PRE_PROCESS); - cram(table); -} - -/** 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. - */ -SharedPtr<EngineStore::Objects> -EngineStore::remove(const Raul::Path& path) -{ - return remove(find(path)); -} - -/** 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. - */ -SharedPtr<EngineStore::Objects> -EngineStore::remove(Objects::iterator object) -{ - ThreadManager::assert_thread(THREAD_PRE_PROCESS); - - if (object != end()) { - iterator descendants_end = find_descendants_end(object); - SharedPtr<Objects> removed = yank(object, descendants_end); - - return removed; - - } else { - LOG(Raul::warn) << "Removing " << object->first << " failed." << endl; - return SharedPtr<EngineStore>(); - } -} - -/** Remove all children of an object from the store. - * - * Returned is a vector containing all descendants of the object removed - * in lexicographically sorted order by Path. - */ -SharedPtr<EngineStore::Objects> -EngineStore::remove_children(const Raul::Path& path) -{ - return remove_children(find(path)); -} - -/** Remove all children of an object from the store. - * - * Returned is a vector containing all descendants of the object removed - * in lexicographically sorted order by Path. - */ -SharedPtr<EngineStore::Objects> -EngineStore::remove_children(Objects::iterator object) -{ - if (object != end()) { - iterator descendants_end = find_descendants_end(object); - if (descendants_end != object) { - iterator first_child = object; - ++first_child; - return yank(first_child, descendants_end); - } - } else { - LOG(Raul::warn) << "Removing children of " << object->first << " failed." << endl; - return SharedPtr<EngineStore::Objects>(); - } - - return SharedPtr<EngineStore::Objects>(); -} - -} // namespace Server -} // namespace Ingen diff --git a/src/server/EngineStore.hpp b/src/server/EngineStore.hpp deleted file mode 100644 index 8b16335f..00000000 --- a/src/server/EngineStore.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard <http://drobilla.net/> - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or any later version. - - Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef INGEN_ENGINE_OBJECTSTORE_HPP -#define INGEN_ENGINE_OBJECTSTORE_HPP - -#include "raul/SharedPtr.hpp" - -#include "ingen/Store.hpp" - -namespace Ingen { - -class GraphObject; - -namespace Server { - -class BufferFactory; -class NodeImpl; -class PatchImpl; -class PortImpl; -class GraphObjectImpl; - -/** Storage for all GraphObjects (tree of GraphObject's sorted by path). - * - * 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 EngineStore : public Ingen::Store -{ -public: - explicit EngineStore(SharedPtr<BufferFactory> f) : _factory(f) {} - ~EngineStore(); - - SharedPtr<BufferFactory> buffer_factory() const { return _factory; } - - PatchImpl* find_patch(const Raul::Path& path); - NodeImpl* find_node(const Raul::Path& path); - PortImpl* find_port(const Raul::Path& path); - GraphObjectImpl* find_object(const Raul::Path& path); - - void add(GraphObject* o); - void add(const Objects& family); - - SharedPtr<Objects> remove(const Raul::Path& path); - SharedPtr<Objects> remove(Objects::iterator i); - SharedPtr<Objects> remove_children(const Raul::Path& path); - SharedPtr<Objects> remove_children(Objects::iterator i); - -private: - /* This holds a reference to the BufferFactory since the objects stored - here refer to it, so the BufferFactory may only be deleted after the - EngineStore is emptied and deleted. - */ - - SharedPtr<BufferFactory> _factory; -}; - -} // namespace Server -} // namespace Ingen - -#endif // OBJECTSTORE diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 17b66192..f3a736ad 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -16,6 +16,7 @@ #include <glibmm/thread.h> +#include "ingen/Store.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" @@ -23,7 +24,6 @@ #include "Connect.hpp" #include "EdgeImpl.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "InputPort.hpp" #include "OutputPort.hpp" #include "PatchImpl.hpp" @@ -52,24 +52,26 @@ Connect::Connect(Engine& engine, bool Connect::pre_process() { - Glib::RWLock::ReaderLock rlock(_engine.engine_store()->lock()); + Glib::RWLock::ReaderLock rlock(_engine.store()->lock()); - PortImpl* tail = _engine.engine_store()->find_port(_tail_path); - PortImpl* head = _engine.engine_store()->find_port(_head_path); + GraphObject* tail = _engine.store()->get(_tail_path); if (!tail) { - return Event::pre_process_done(PORT_NOT_FOUND, _tail_path); - } else if (!head) { - return Event::pre_process_done(PORT_NOT_FOUND, _head_path); + return Event::pre_process_done(NOT_FOUND, _tail_path); + } + + GraphObject* head = _engine.store()->get(_head_path); + if (!head) { + return Event::pre_process_done(NOT_FOUND, _head_path); } OutputPort* tail_output = dynamic_cast<OutputPort*>(tail); _head = dynamic_cast<InputPort*>(head); if (!tail_output || !_head) { - return Event::pre_process_done(DIRECTION_MISMATCH, _head_path); + return Event::pre_process_done(BAD_REQUEST, _head_path); } - NodeImpl* const tail_node = tail->parent_node(); - NodeImpl* const head_node = head->parent_node(); + NodeImpl* const tail_node = tail_output->parent_node(); + NodeImpl* const head_node = _head->parent_node(); if (!tail_node || !head_node) { return Event::pre_process_done(PARENT_NOT_FOUND, _head_path); } @@ -109,7 +111,7 @@ Connect::pre_process() rlock.release(); { - Glib::RWLock::ReaderLock wlock(_engine.engine_store()->lock()); + Glib::RWLock::ReaderLock wlock(_engine.store()->lock()); /* Need to be careful about patch port edges here and adding a node's parent as a dependant/provider, or adding a patch as its own diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index acdc9091..e88434b7 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -14,6 +14,7 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "ingen/Store.hpp" #include "ingen/URIs.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" @@ -21,7 +22,6 @@ #include "Broadcaster.hpp" #include "CreateNode.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "NodeFactory.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" @@ -65,11 +65,12 @@ CreateNode::pre_process() return Event::pre_process_done(BAD_REQUEST); } - if (_engine.engine_store()->find_object(_path)) { + if (_engine.store()->get(_path)) { return Event::pre_process_done(EXISTS, _path); } - if (!(_patch = _engine.engine_store()->find_patch(_path.parent()))) { + _patch = dynamic_cast<PatchImpl*>(_engine.store()->get(_path.parent())); + if (!_patch) { return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); } @@ -98,7 +99,7 @@ CreateNode::pre_process() // Add node to the store and the patch's pre-processor only node list _patch->add_node(new PatchImpl::Nodes::Node(_node)); - _engine.engine_store()->add(_node); + _engine.store()->add(_node); /* Compile patch with new node added for insertion in audio thread TODO: Since the node is not connected at this point, a full compilation diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp index 9821902d..368f8883 100644 --- a/src/server/events/CreatePatch.cpp +++ b/src/server/events/CreatePatch.cpp @@ -14,6 +14,7 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "ingen/Store.hpp" #include "ingen/URIs.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" @@ -22,7 +23,6 @@ #include "Broadcaster.hpp" #include "Driver.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "PatchImpl.hpp" namespace Ingen { @@ -47,11 +47,11 @@ CreatePatch::CreatePatch(Engine& engine, bool CreatePatch::pre_process() { - if (_path.is_root() || _engine.engine_store()->find_object(_path) != NULL) { + if (_path.is_root() || _engine.store()->get(_path)) { return Event::pre_process_done(EXISTS, _path); } - _parent = _engine.engine_store()->find_patch(_path.parent()); + _parent = dynamic_cast<PatchImpl*>(_engine.store()->get(_path.parent())); if (!_parent) { return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); } @@ -91,8 +91,8 @@ CreatePatch::pre_process() _patch->activate(*_engine.buffer_factory()); - // Insert into EngineStore - _engine.engine_store()->add(_patch); + // Insert into Store + _engine.store()->add(_patch); _update = _patch->properties(); diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index f45c200b..2782d654 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -16,6 +16,7 @@ #include <utility> +#include "ingen/Store.hpp" #include "ingen/URIMap.hpp" #include "ingen/URIs.hpp" #include "raul/Array.hpp" @@ -28,7 +29,6 @@ #include "Driver.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "PatchImpl.hpp" #include "PortImpl.hpp" @@ -93,14 +93,19 @@ CreatePort::pre_process() return Event::pre_process_done(BAD_URI, _path); } - if (_engine.engine_store()->find_object(_path)) { + if (_engine.store()->get(_path)) { return Event::pre_process_done(_status, _path); } - if (!(_patch = _engine.engine_store()->find_patch(_path.parent()))) { + GraphObject* parent = _engine.store()->get(_path.parent()); + if (!parent) { return Event::pre_process_done(PARENT_NOT_FOUND, _path.parent()); } + if (!(_patch = dynamic_cast<PatchImpl*>(parent))) { + return Event::pre_process_done(INVALID_PARENT_PATH, _path.parent()); + } + const URIs& uris = _engine.world()->uris(); const BufferFactory& buffer_factory = *_engine.buffer_factory(); @@ -133,7 +138,7 @@ CreatePort::pre_process() _patch_port->properties().insert(_properties.begin(), _properties.end()); - _engine.engine_store()->add(_patch_port); + _engine.store()->add(_patch_port); if (_is_output) { _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port)); } else { diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 3121d6ad..96668af1 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -14,6 +14,7 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ +#include "ingen/Store.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" @@ -24,7 +25,6 @@ #include "Driver.hpp" #include "Engine.hpp" #include "EnginePort.hpp" -#include "EngineStore.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" #include "PluginImpl.hpp" @@ -48,7 +48,7 @@ Delete::Delete(Engine& engine, , _ports_array(NULL) , _compiled_patch(NULL) , _disconnect_event(NULL) - , _lock(engine.engine_store()->lock(), Glib::NOT_LOCK) + , _lock(engine.store()->lock(), Glib::NOT_LOCK) { if (GraphObject::uri_is_path(uri)) { _path = GraphObject::uri_to_path(uri); @@ -71,17 +71,15 @@ Delete::pre_process() _removed_bindings = _engine.control_bindings()->remove(_path); - EngineStore::iterator iter = _engine.engine_store()->find(_path); - - if (iter != _engine.engine_store()->end()) { - _node = PtrCast<NodeImpl>(iter->second); - - if (!_node) + Store::iterator iter = _engine.store()->find(_path); + if (iter != _engine.store()->end()) { + if (!(_node = PtrCast<NodeImpl>(iter->second))) { _port = PtrCast<PortImpl>(iter->second); + } } - if (iter != _engine.engine_store()->end()) { - _removed_table = _engine.engine_store()->remove(iter); + if (iter != _engine.store()->end()) { + _engine.store()->remove(iter, _removed_objects); } if (_node && !_path.is_root()) { diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index 4e8f58cd..53671846 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -17,8 +17,9 @@ #ifndef INGEN_EVENTS_DELETE_HPP #define INGEN_EVENTS_DELETE_HPP +#include "ingen/Store.hpp" + #include "Event.hpp" -#include "EngineStore.hpp" #include "PatchImpl.hpp" #include "ControlBindings.hpp" @@ -81,8 +82,7 @@ private: DisconnectAll* _disconnect_event; SharedPtr<ControlBindings::Bindings> _removed_bindings; - - SharedPtr< Raul::Table<Raul::Path, SharedPtr<GraphObject> > > _removed_table; + Store::Objects _removed_objects; Glib::RWLock::WriterLock _lock; }; diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 18f35ab6..41ff8f8b 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -18,6 +18,7 @@ #include <glibmm/thread.h> +#include "ingen/Store.hpp" #include "ingen/URIs.hpp" #include "raul/Maid.hpp" @@ -28,7 +29,6 @@ #include "CreatePort.hpp" #include "Delta.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "PatchImpl.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" @@ -108,10 +108,10 @@ Delta::pre_process() const bool is_graph_object = GraphObject::uri_is_path(_subject); // Take a writer lock while we modify the store - Glib::RWLock::WriterLock lock(_engine.engine_store()->lock()); + Glib::RWLock::WriterLock lock(_engine.store()->lock()); _object = is_graph_object - ? _engine.engine_store()->find_object(GraphObject::uri_to_path(_subject)) + ? static_cast<Ingen::Resource*>(_engine.store()->get(GraphObject::uri_to_path(_subject))) : static_cast<Ingen::Resource*>(_engine.node_factory()->plugin(_subject)); if (!_object && (!is_graph_object || !_create)) { @@ -139,7 +139,7 @@ Delta::pre_process() if (_create_event) { _create_event->pre_process(); // Grab the object for applying properties, if the create-event succeeded - _object = _engine.engine_store()->find_object(path); + _object = _engine.store()->get(path); } else { return Event::pre_process_done(BAD_OBJECT_TYPE, _subject); } diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 7823a709..1726846a 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -18,6 +18,7 @@ #include <glibmm/thread.h> +#include "ingen/Store.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" #include "raul/log.hpp" @@ -27,7 +28,6 @@ #include "DuplexPort.hpp" #include "EdgeImpl.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "InputPort.hpp" #include "OutputPort.hpp" #include "PatchImpl.hpp" @@ -113,7 +113,7 @@ Disconnect::Impl::Impl(Engine& e, bool Disconnect::pre_process() { - Glib::RWLock::WriterLock lock(_engine.engine_store()->lock()); + Glib::RWLock::WriterLock lock(_engine.store()->lock()); if (_tail_path.parent().parent() != _head_path.parent().parent() && _tail_path.parent() != _head_path.parent().parent() @@ -121,15 +121,16 @@ Disconnect::pre_process() return Event::pre_process_done(PARENT_DIFFERS, _head_path); } - PortImpl* tail = _engine.engine_store()->find_port(_tail_path); - PortImpl* head = _engine.engine_store()->find_port(_head_path); - + PortImpl* tail = dynamic_cast<PortImpl*>(_engine.store()->get(_tail_path)); if (!tail) { return Event::pre_process_done(PORT_NOT_FOUND, _tail_path); - } else if (!head) { - return Event::pre_process_done(PORT_NOT_FOUND, _head_path); } + PortImpl* head = dynamic_cast<PortImpl*>(_engine.store()->get(_head_path)); + if (!head) { + return Event::pre_process_done(PORT_NOT_FOUND, _head_path); + } + NodeImpl* const src_node = tail->parent_node(); NodeImpl* const dst_node = head->parent_node(); diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 6632750f..417b6154 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -19,6 +19,7 @@ #include <boost/format.hpp> #include <glibmm/thread.h> +#include "ingen/Store.hpp" #include "raul/Array.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" @@ -26,7 +27,6 @@ #include "Broadcaster.hpp" #include "EdgeImpl.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "InputPort.hpp" #include "NodeImpl.hpp" #include "OutputPort.hpp" @@ -82,17 +82,18 @@ DisconnectAll::~DisconnectAll() bool DisconnectAll::pre_process() { - Glib::RWLock::WriterLock lock(_engine.engine_store()->lock(), Glib::NOT_LOCK); + Glib::RWLock::WriterLock lock(_engine.store()->lock(), Glib::NOT_LOCK); if (!_deleting) { lock.acquire(); - _parent = _engine.engine_store()->find_patch(_parent_path); + _parent = dynamic_cast<PatchImpl*>(_engine.store()->get(_parent_path)); if (!_parent) { return Event::pre_process_done(PARENT_NOT_FOUND, _parent_path); } - GraphObjectImpl* object = _engine.engine_store()->find_object(_path); + GraphObjectImpl* const object = dynamic_cast<GraphObjectImpl*>( + _engine.store()->get(_path)); if (!object) { return Event::pre_process_done(NOT_FOUND, _path); } diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 9ec581a1..b826aa5d 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -18,12 +18,12 @@ #include "ingen/GraphObject.hpp" #include "ingen/Interface.hpp" +#include "ingen/Store.hpp" #include "Broadcaster.hpp" #include "BufferFactory.hpp" #include "Driver.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "Get.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" @@ -46,7 +46,7 @@ Get::Get(Engine& engine, , _uri(uri) , _object(NULL) , _plugin(NULL) - , _lock(engine.engine_store()->lock(), Glib::NOT_LOCK) + , _lock(engine.store()->lock(), Glib::NOT_LOCK) { } @@ -61,7 +61,7 @@ Get::pre_process() } else if (_uri == "ingen:engine") { return Event::pre_process_done(SUCCESS); } else if (GraphObject::uri_is_path(_uri)) { - _object = _engine.engine_store()->find_object(GraphObject::uri_to_path(_uri)); + _object = _engine.store()->get(GraphObject::uri_to_path(_uri)); return Event::pre_process_done(_object ? SUCCESS : NOT_FOUND, _uri); } else { _plugin = _engine.node_factory()->plugin(_uri); diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp index fa88237d..12cedd4d 100644 --- a/src/server/events/Get.hpp +++ b/src/server/events/Get.hpp @@ -49,7 +49,7 @@ public: private: const Raul::URI _uri; - const GraphObjectImpl* _object; + const GraphObject* _object; const PluginImpl* _plugin; NodeFactory::Plugins _plugins; Glib::RWLock::ReaderLock _lock; diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index 17ad1a70..5044ce3e 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -16,13 +16,13 @@ #include <glibmm/thread.h> +#include "ingen/Store.hpp" #include "raul/Path.hpp" #include "Broadcaster.hpp" #include "Driver.hpp" #include "Engine.hpp" #include "EnginePort.hpp" -#include "EngineStore.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" #include "events/Move.hpp" @@ -41,7 +41,7 @@ Move::Move(Engine& engine, , _old_path(path) , _new_path(new_path) , _parent_patch(NULL) - , _store_iterator(engine.engine_store()->end()) + , _port(NULL) { } @@ -52,43 +52,23 @@ Move::~Move() bool Move::pre_process() { - Glib::RWLock::WriterLock lock(_engine.engine_store()->lock()); + Glib::RWLock::WriterLock lock(_engine.store()->lock()); if (!_old_path.parent().is_parent_of(_new_path)) { return Event::pre_process_done(PARENT_DIFFERS, _new_path); } - _store_iterator = _engine.engine_store()->find(_old_path); - if (_store_iterator == _engine.engine_store()->end()) { + const Store::iterator i = _engine.store()->find(_old_path); + if (i == _engine.store()->end()) { return Event::pre_process_done(NOT_FOUND, _old_path); } - if (_engine.engine_store()->find_object(_new_path)) { + if (_engine.store()->find(_new_path) != _engine.store()->end()) { return Event::pre_process_done(EXISTS, _new_path); } - SharedPtr< Raul::Table< Raul::Path, SharedPtr<GraphObject> > > removed - = _engine.engine_store()->remove(_store_iterator); - - assert(removed->size() > 0); - - for (Raul::Table< Raul::Path, SharedPtr<GraphObject> >::iterator i = removed->begin(); i != removed->end(); ++i) { - const Raul::Path& child_old_path = i->first; - assert(Raul::Path::descendant_comparator(_old_path, child_old_path)); - - Raul::Path child_new_path; - if (child_old_path == _old_path) { - child_new_path = _new_path; - } else { - child_new_path = Raul::Path( - _new_path.base() + child_old_path.substr(_old_path.length() + 1)); - } - - PtrCast<GraphObjectImpl>(i->second)->set_path(child_new_path); - i->first = child_new_path; - } - - _engine.engine_store()->add(*removed.get()); + _port = dynamic_cast<PortImpl*>(i->second.get()); + _engine.store()->rename(i, _new_path); return Event::pre_process_done(SUCCESS); } @@ -96,8 +76,7 @@ Move::pre_process() void Move::execute(ProcessContext& context) { - SharedPtr<PortImpl> port = PtrCast<PortImpl>(_store_iterator->second); - if (port && port->parent()->parent() == NULL) { + if (_port && !_port->parent()->parent()) { EnginePort* eport = _engine.driver()->engine_port(context, _new_path); if (eport) { eport->move(_new_path); diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp index 31bf1f07..0e46df1b 100644 --- a/src/server/events/Move.hpp +++ b/src/server/events/Move.hpp @@ -17,14 +17,16 @@ #ifndef INGEN_EVENTS_MOVE_HPP #define INGEN_EVENTS_MOVE_HPP +#include "ingen/Store.hpp" #include "raul/Path.hpp" + #include "Event.hpp" -#include "EngineStore.hpp" namespace Ingen { namespace Server { class PatchImpl; +class PortImpl; namespace Events { @@ -58,10 +60,10 @@ public: void post_process(); private: - Raul::Path _old_path; - Raul::Path _new_path; - PatchImpl* _parent_patch; - EngineStore::iterator _store_iterator; + const Raul::Path _old_path; + const Raul::Path _new_path; + PatchImpl* _parent_patch; + PortImpl* _port; }; } // namespace Events diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index 49e2e483..38b36a7c 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -15,6 +15,7 @@ */ #include "ingen/LV2Features.hpp" +#include "ingen/Store.hpp" #include "ingen/URIs.hpp" #include "ingen/World.hpp" #include "raul/log.hpp" @@ -24,7 +25,6 @@ #include "ControlBindings.hpp" #include "Driver.hpp" #include "Engine.hpp" -#include "EngineStore.hpp" #include "NodeImpl.hpp" #include "PortImpl.hpp" #include "ProcessContext.hpp" diff --git a/src/server/wscript b/src/server/wscript index 0ca0a90a..5c98d189 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -11,7 +11,6 @@ def build(bld): DuplexPort.cpp EdgeImpl.cpp Engine.cpp - EngineStore.cpp EventWriter.cpp GraphObjectImpl.cpp InputPort.cpp |