From 76b602f1f834cb2c255848c5ba887b3d7c47171a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 14 Aug 2012 21:37:20 +0000 Subject: 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 --- src/server/events/Connect.cpp | 24 ++++++++++++----------- src/server/events/CreateNode.cpp | 9 +++++---- src/server/events/CreatePatch.cpp | 10 +++++----- src/server/events/CreatePort.cpp | 13 +++++++++---- src/server/events/Delete.cpp | 18 ++++++++--------- src/server/events/Delete.hpp | 6 +++--- src/server/events/Delta.cpp | 8 ++++---- src/server/events/Disconnect.cpp | 15 +++++++------- src/server/events/DisconnectAll.cpp | 9 +++++---- src/server/events/Get.cpp | 6 +++--- src/server/events/Get.hpp | 2 +- src/server/events/Move.cpp | 39 +++++++++---------------------------- src/server/events/Move.hpp | 12 +++++++----- src/server/events/SetPortValue.cpp | 2 +- 14 files changed, 81 insertions(+), 92 deletions(-) (limited to 'src/server/events') 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 +#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(tail); _head = dynamic_cast(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 . */ +#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(_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 . */ +#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(_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 +#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(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::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 . */ +#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(iter->second); - - if (!_node) + Store::iterator iter = _engine.store()->find(_path); + if (iter != _engine.store()->end()) { + if (!(_node = PtrCast(iter->second))) { _port = PtrCast(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 _removed_bindings; - - SharedPtr< Raul::Table > > _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 +#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(_engine.store()->get(GraphObject::uri_to_path(_subject))) : static_cast(_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 +#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(_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(_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 #include +#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(_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( + _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 +#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 > > removed - = _engine.engine_store()->remove(_store_iterator); - - assert(removed->size() > 0); - - for (Raul::Table< Raul::Path, SharedPtr >::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(i->second)->set_path(child_new_path); - i->first = child_new_path; - } - - _engine.engine_store()->add(*removed.get()); + _port = dynamic_cast(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 port = PtrCast(_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" -- cgit v1.2.1