diff options
author | David Robillard <d@drobilla.net> | 2008-08-16 03:23:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-16 03:23:15 +0000 |
commit | a8b36b5637acb3fa8eb29ef0f45bd11653f412fa (patch) | |
tree | 3a0f0dbef302269f8e509d9f5c2d4c713e00face /src/libs | |
parent | 49e8582cb6720d43389e7d2534be11a4fb0b8959 (diff) | |
download | ingen-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')
-rw-r--r-- | src/libs/client/ClientStore.cpp | 86 | ||||
-rw-r--r-- | src/libs/client/ClientStore.hpp | 15 | ||||
-rw-r--r-- | src/libs/client/PatchModel.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/Engine.cpp | 4 | ||||
-rw-r--r-- | src/libs/engine/EngineStore.cpp | 74 | ||||
-rw-r--r-- | src/libs/engine/EngineStore.hpp | 26 | ||||
-rw-r--r-- | src/libs/engine/HTTPEngineReceiver.cpp | 8 | ||||
-rw-r--r-- | src/libs/engine/events/ClearPatchEvent.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/events/DestroyEvent.cpp | 6 | ||||
-rw-r--r-- | src/libs/engine/events/DestroyEvent.hpp | 2 | ||||
-rw-r--r-- | src/libs/engine/events/RenameEvent.cpp | 4 | ||||
-rw-r--r-- | src/libs/engine/events/RenameEvent.hpp | 2 | ||||
-rw-r--r-- | src/libs/gui/App.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/ConnectWindow.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/NewSubpatchWindow.cpp | 2 | ||||
-rw-r--r-- | src/libs/shared/Makefile.am | 8 | ||||
-rw-r--r-- | src/libs/shared/Store.hpp | 17 |
17 files changed, 89 insertions, 173 deletions
diff --git a/src/libs/client/ClientStore.cpp b/src/libs/client/ClientStore.cpp index 13250abc..96f0dfa8 100644 --- a/src/libs/client/ClientStore.cpp +++ b/src/libs/client/ClientStore.cpp @@ -58,7 +58,7 @@ ClientStore::ClientStore(SharedPtr<EngineInterface> engine, SharedPtr<SigClientI void ClientStore::clear() { - _objects.clear(); + clear(); _plugins.clear(); } @@ -223,8 +223,8 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) { // If we already have "this" object, merge the existing one into the new // one (with precedence to the new values). - Objects::iterator existing = _objects.find(object->path()); - if (existing != _objects.end()) { + iterator existing = find(object->path()); + if (existing != end()) { PtrCast<ObjectModel>(existing->second)->set(object); } else { @@ -236,7 +236,7 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) parent->add_child(object); assert(parent && (object->parent() == parent)); - _objects[object->path()] = object; + (*this)[object->path()] = object; signal_new_object.emit(object); resolve_variable_orphans(parent); @@ -250,14 +250,14 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) add_orphan(object); } } else { - _objects[object->path()] = object; + (*this)[object->path()] = object; signal_new_object.emit(object); } } /*cout << "[Store] Added " << object->path() << " {" << endl; - for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) { + for (iterator i = begin(); i != end(); ++i) { cout << "\t" << i->first << endl; } cout << "}" << endl;*/ @@ -267,19 +267,18 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) SharedPtr<ObjectModel> ClientStore::remove_object(const Path& path) { - Objects::iterator i = _objects.find(path); + iterator i = find(path); - if (i != _objects.end()) { + if (i != end()) { assert((*i).second->path() == path); SharedPtr<ObjectModel> result = PtrCast<ObjectModel>((*i).second); assert(result); - //_objects.erase(i); - Objects::iterator descendants_end = _objects.find_descendants_end(i); - SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed - = _objects.yank(i, descendants_end); + //erase(i); + iterator descendants_end = find_descendants_end(i); + SharedPtr<Store::Objects> removed = yank(i, descendants_end); /*cout << "[Store] Removing " << i->first << " {" << endl; - for (Objects::iterator i = removed.begin(); i != removed.end(); ++i) { + for (iterator i = removed.begin(); i != removed.end(); ++i) { cout << "\t" << i->first << endl; } cout << "}" << endl;*/ @@ -323,8 +322,8 @@ SharedPtr<ObjectModel> ClientStore::object(const Path& path) { assert(path.length() > 0); - Objects::iterator i = _objects.find(path); - if (i == _objects.end()) { + iterator i = find(path); + if (i == end()) { return SharedPtr<ObjectModel>(); } else { SharedPtr<ObjectModel> model = PtrCast<ObjectModel>(i->second); @@ -343,39 +342,6 @@ ClientStore::add_plugin(SharedPtr<PluginModel> pm) signal_new_plugin(pm); //cerr << "Plugin: " << pm->uri() << ", # plugins: " << _plugins.size() << endl; } - - -ClientStore::Objects::const_iterator -ClientStore::children_begin(SharedPtr<Shared::GraphObject> o) const -{ - Objects::const_iterator parent = _objects.find(o->path()); - assert(parent != _objects.end()); - ++parent; - return parent; -} - - -ClientStore::Objects::const_iterator -ClientStore::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); -} - - -SharedPtr<Shared::GraphObject> -ClientStore::find_child(SharedPtr<Shared::GraphObject> parent, const string& child_name) const -{ - Objects::const_iterator pi = _objects.find(parent->path()); - assert(pi != _objects.end()); - Objects::const_iterator children_end = _objects.find_descendants_end(pi); - Objects::const_iterator child = _objects.find(pi, children_end, parent->path().base() + child_name); - if (child != _objects.end()) - return PtrCast<ObjectModel>(child->second); - else - return SharedPtr<ObjectModel>(); -} /* ****** Signal Handlers ******** */ @@ -395,16 +361,16 @@ ClientStore::destruction_event(const Path& path) void ClientStore::rename_event(const Path& old_path, const Path& new_path) { - Objects::iterator parent = _objects.find(old_path); - if (parent == _objects.end()) { + iterator parent = find(old_path); + if (parent == end()) { cerr << "[Store] Failed to find object " << old_path << " to rename." << endl; return; } - Objects::iterator descendants_end = _objects.find_descendants_end(parent); + iterator descendants_end = find_descendants_end(parent); SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed - = _objects.yank(parent, descendants_end); + = yank(parent, descendants_end); assert(removed->size() > 0); @@ -423,13 +389,13 @@ ClientStore::rename_event(const Path& old_path, const Path& new_path) i->first = child_new_path; } - _objects.cram(*removed.get()); + cram(*removed.get()); //cerr << "[Store] Table:" << endl; //for (size_t i=0; i < removed.size(); ++i) { // cerr << removed[i].first << "\t\t: " << removed[i].second << endl; //} - /*for (Objects::iterator i = _objects.begin(); i != _objects.end(); ++i) { + /*for (iterator i = begin(); i != end(); ++i) { cerr << i->first << "\t\t: " << i->second << endl; }*/ } @@ -518,18 +484,18 @@ ClientStore::patch_polyphony_event(const Path& path, uint32_t poly) void ClientStore::patch_cleared_event(const Path& path) { - Objects::iterator i = _objects.find(path); - if (i != _objects.end()) { + iterator i = find(path); + if (i != end()) { assert((*i).second->path() == path); SharedPtr<PatchModel> patch = PtrCast<PatchModel>(i->second); - Objects::iterator first_descendant = i; + iterator first_descendant = i; ++first_descendant; - Objects::iterator descendants_end = _objects.find_descendants_end(i); + iterator descendants_end = find_descendants_end(i); SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed - = _objects.yank(first_descendant, descendants_end); + = yank(first_descendant, descendants_end); - for (Objects::iterator i = removed->begin(); i != removed->end(); ++i) { + for (iterator i = removed->begin(); i != removed->end(); ++i) { SharedPtr<ObjectModel> model = PtrCast<ObjectModel>(i->second); assert(model); model->signal_destroyed.emit(); diff --git a/src/libs/client/ClientStore.hpp b/src/libs/client/ClientStore.hpp index 24c23f14..4871c644 100644 --- a/src/libs/client/ClientStore.hpp +++ b/src/libs/client/ClientStore.hpp @@ -62,23 +62,9 @@ public: void clear(); - size_t num_object() { return _objects.size(); } - - Objects::iterator find(const Path& path) { return _objects.find(path); } - typedef Raul::Table<string, SharedPtr<PluginModel> > Plugins; const Plugins& plugins() const { return _plugins; } - typedef Raul::PathTable< SharedPtr<Shared::GraphObject> > Objects; - const Objects& objects() const { return _objects; } - Objects& objects() { return _objects; } - - Objects::const_iterator children_begin(SharedPtr<Shared::GraphObject> o) const; - Objects::const_iterator children_end(SharedPtr<Shared::GraphObject> o) const; - - SharedPtr<Shared::GraphObject> find_child(SharedPtr<Shared::GraphObject> parent, - const string& child_name) const; - sigc::signal<void, SharedPtr<ObjectModel> > signal_new_object; sigc::signal<void, SharedPtr<PluginModel> > signal_new_plugin; @@ -130,7 +116,6 @@ private: SharedPtr<EngineInterface> _engine; SharedPtr<SigClientInterface> _emitter; - Objects _objects; ///< Map, keyed by Ingen path Plugins _plugins; ///< Map, keyed by plugin URI /** Objects we've received, but depend on the existance of another unknown object. diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 360707d3..20a47406 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -202,7 +202,7 @@ PatchModel::child_name_offset(ClientStore& store, ss << base_name; if (offset > 0) ss << "_" << offset; - if (store.find(parent->path().base() + ss.str()) == store.objects().end()) + if (store.find(parent->path().base() + ss.str()) == store.end()) break; else if (offset == 0) offset = 2; 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; }; diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index 3823b407..a0a877d5 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -174,9 +174,7 @@ App::attach(SharedPtr<SigClientInterface> client) _world->engine->register_client(client.get()); _client = client; - assert(!_world->store); _store = SharedPtr<ClientStore>(new ClientStore(_world->engine, client)); - _world->store = _store; _loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(_world->engine)); _patch_tree_window->init(*_store); diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp index 9707e5aa..8348126b 100644 --- a/src/libs/gui/ConnectWindow.cpp +++ b/src/libs/gui/ConnectWindow.cpp @@ -417,7 +417,7 @@ ConnectWindow::gtk_callback() _progress_label->set_text(string("Requesting root patch...")); ++_connect_stage; } else if (_connect_stage == 3) { - if (App::instance().store()->objects().size() > 0) { + if (App::instance().store()->size() > 0) { SharedPtr<PatchModel> root = PtrCast<PatchModel>(App::instance().store()->object("/")); if (root) { set_connected_to(App::instance().engine()); diff --git a/src/libs/gui/NewSubpatchWindow.cpp b/src/libs/gui/NewSubpatchWindow.cpp index 02d3e9e0..e33c9f2e 100644 --- a/src/libs/gui/NewSubpatchWindow.cpp +++ b/src/libs/gui/NewSubpatchWindow.cpp @@ -73,7 +73,7 @@ NewSubpatchWindow::name_changed() _message_label->set_text("Name contains invalid characters."); _ok_button->property_sensitive() = false; } else if (App::instance().store()->find(_patch->path().base() + name) - != App::instance().store()->objects().end()) { + != App::instance().store()->end()) { _message_label->set_text("An object already exists with that name."); _ok_button->property_sensitive() = false; } else if (name.length() == 0) { diff --git a/src/libs/shared/Makefile.am b/src/libs/shared/Makefile.am index e6cbee60..6a073148 100644 --- a/src/libs/shared/Makefile.am +++ b/src/libs/shared/Makefile.am @@ -1,9 +1,11 @@ noinst_LTLIBRARIES = libingen_shared.la -libingen_shared_la_CXXFLAGS = @INGEN_CFLAGS@ @REDLANDMM_CFLAGS@ @SLV2_CFLAGS@ +libingen_shared_la_CXXFLAGS = @INGEN_CFLAGS@ @REDLANDMM_CFLAGS@ @SLV2_CFLAGS@ @RAUL_CFLAGS@ libingen_shared_la_SOURCES = \ - LV2Features.hpp \ LV2Features.cpp \ + LV2Features.hpp \ LV2URIMap.cpp \ - LV2URIMap.hpp + LV2URIMap.hpp \ + Store.cpp \ + Store.hpp diff --git a/src/libs/shared/Store.hpp b/src/libs/shared/Store.hpp index 428945b9..ec29e7c0 100644 --- a/src/libs/shared/Store.hpp +++ b/src/libs/shared/Store.hpp @@ -18,26 +18,27 @@ #ifndef COMMON_STORE_H #define COMMON_STORE_H +#include <string> #include <raul/PathTable.hpp> #include "interface/GraphObject.hpp" using Raul::PathTable; -using Raul::Path; namespace Ingen { namespace Shared { -class Store { +class Store : public Raul::PathTable< SharedPtr<Shared::GraphObject> > { public: - typedef Raul::PathTable< SharedPtr<Shared::GraphObject> > Objects; - virtual const Objects& objects() const = 0; - - virtual Objects::iterator find(const Path& path) = 0; virtual void add(GraphObject* o) = 0; + + typedef Raul::Table< Raul::Path, SharedPtr<Shared::GraphObject> > Objects; - virtual Objects::const_iterator children_begin(SharedPtr<Shared::GraphObject> o) const = 0; - virtual Objects::const_iterator children_end(SharedPtr<Shared::GraphObject> o) const = 0; + const_iterator children_begin(SharedPtr<Shared::GraphObject> o) const; + const_iterator children_end(SharedPtr<Shared::GraphObject> o) const; + + SharedPtr<Shared::GraphObject> find_child(SharedPtr<Shared::GraphObject> parent, + const std::string& child_name) const; }; |