summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ingen/Store.hpp7
-rw-r--r--src/Store.cpp37
-rw-r--r--src/gui/LoadPluginWindow.cpp3
-rw-r--r--src/gui/PatchCanvas.cpp5
-rw-r--r--src/serialisation/Serialiser.cpp18
5 files changed, 25 insertions, 45 deletions
diff --git a/ingen/Store.hpp b/ingen/Store.hpp
index ded18608..f35c8368 100644
--- a/ingen/Store.hpp
+++ b/ingen/Store.hpp
@@ -39,11 +39,10 @@ public:
typedef Raul::Table< Raul::Path, SharedPtr<GraphObject> > Objects;
- const_iterator children_begin(SharedPtr<const GraphObject> o) const;
- const_iterator children_end(SharedPtr<const GraphObject> o) const;
+ typedef std::pair<const_iterator, const_iterator> const_range;
- SharedPtr<GraphObject> find_child(SharedPtr<const GraphObject> parent,
- const Raul::Symbol& symbol) const;
+ const_range
+ children_range(SharedPtr<const GraphObject> o) const;
unsigned child_name_offset(const Raul::Path& parent,
const Raul::Symbol& symbol,
diff --git a/src/Store.cpp b/src/Store.cpp
index c0cb71b8..ae7770ac 100644
--- a/src/Store.cpp
+++ b/src/Store.cpp
@@ -42,35 +42,16 @@ Store::add(GraphObject* o)
}
}
-Store::const_iterator
-Store::children_begin(SharedPtr<const GraphObject> o) const
+Store::const_range
+Store::children_range(SharedPtr<const GraphObject> o) const
{
- const_iterator parent = find(o->path());
- assert(parent != end());
- ++parent;
- return parent;
-}
-
-Store::const_iterator
-Store::children_end(SharedPtr<const GraphObject> o) const
-{
- const_iterator parent = find(o->path());
- assert(parent != end());
- return find_descendants_end(parent);
-}
-
-SharedPtr<GraphObject>
-Store::find_child(SharedPtr<const GraphObject> parent,
- const Raul::Symbol& symbol) const
-{
- const_iterator pi = find(parent->path());
- assert(pi != end());
- const_iterator children_end = find_descendants_end(pi);
- const_iterator child = find(pi, children_end, parent->path().child(symbol));
- if (child != end())
- return child->second;
- else
- return SharedPtr<GraphObject>();
+ const const_iterator parent = find(o->path());
+ if (parent != end()) {
+ const_iterator first_child = parent;
+ ++first_child;
+ return std::make_pair(first_child, find_descendants_end(parent));
+ }
+ return make_pair(end(), end());
}
unsigned
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index b7e118bd..f87eba25 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -135,7 +135,8 @@ LoadPluginWindow::name_changed()
const string sym = _node_name_entry->get_text();
if (!Symbol::is_valid(sym)) {
_add_button->property_sensitive() = false;
- } else if (_app->store()->find_child(_patch, Symbol(sym))) {
+ } else if (_app->store()->find(_patch->path().child(Symbol(sym)))
+ != _app->store()->end()) {
_add_button->property_sensitive() = false;
} else {
_add_button->property_sensitive() = true;
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 936fb259..6061eeb2 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -290,9 +290,10 @@ PatchCanvas::build_plugin_menu()
void
PatchCanvas::build()
{
+ const Store::const_range kids = _app.store()->children_range(_patch);
+
// Create modules for nodes
- for (Store::const_iterator i = _app.store()->children_begin(_patch);
- i != _app.store()->children_end(_patch); ++i) {
+ for (Store::const_iterator i = kids.first; i != kids.second; ++i) {
SharedPtr<NodeModel> node = PtrCast<NodeModel>(i->second);
if (node && node->parent() == _patch)
add_node(node);
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index a6af8923..d71e7b15 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -98,13 +98,12 @@ struct Serialiser::Impl {
std::string finish();
- Raul::Path _root_path;
- SharedPtr<Store> _store;
- Mode _mode;
- std::string _base_uri;
- World& _world;
- Sord::Model* _model;
- Sratom* _sratom;
+ Raul::Path _root_path;
+ Mode _mode;
+ std::string _base_uri;
+ World& _world;
+ Sord::Model* _model;
+ Sratom* _sratom;
};
Serialiser::Serialiser(World& world)
@@ -353,9 +352,8 @@ Serialiser::Impl::serialise_patch(SharedPtr<const GraphObject> patch,
const GraphObject::Properties props = patch->properties(Resource::INTERNAL);
serialise_properties(patch_id, props);
- for (Store::const_iterator n = _world.store()->children_begin(patch);
- n != _world.store()->children_end(patch); ++n) {
-
+ const Store::const_range kids = _world.store()->children_range(patch);
+ for (Store::const_iterator n = kids.first; n != kids.second; ++n) {
if (n->first.parent() != patch->path())
continue;