summaryrefslogtreecommitdiffstats
path: root/src/libs/client/ObjectModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client/ObjectModel.cpp')
-rw-r--r--src/libs/client/ObjectModel.cpp65
1 files changed, 28 insertions, 37 deletions
diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp
index 673a5c60..ca38b42f 100644
--- a/src/libs/client/ObjectModel.cpp
+++ b/src/libs/client/ObjectModel.cpp
@@ -25,8 +25,9 @@ namespace Ingen {
namespace Client {
-ObjectModel::ObjectModel(const Path& path, bool polyphonic)
- : _path(path)
+ObjectModel::ObjectModel(Store& store, const Path& path, bool polyphonic)
+ : _store(store)
+ , _path(path)
, _polyphonic(polyphonic)
{
}
@@ -35,51 +36,41 @@ ObjectModel::ObjectModel(const Path& path, bool polyphonic)
ObjectModel::~ObjectModel()
{
}
+
-SharedPtr<ObjectModel>
-ObjectModel::get_child(const string& name) const
+ObjectModel::const_iterator
+ObjectModel::children_begin() const
{
- assert(name.find("/") == string::npos);
- Children::const_iterator i = _children.find(name);
- return ((i != _children.end()) ? (*i).second : SharedPtr<ObjectModel>());
+ Store::Objects::const_iterator me = _store.objects().find(_path);
+ assert(me != _store.objects().end());
+ ++me;
+ return me;
}
-void
-ObjectModel::add_child(SharedPtr<ObjectModel> o)
+
+ObjectModel::const_iterator
+ObjectModel::children_end() const
{
- assert(o);
- assert(o->path().is_child_of(_path));
- assert(o->parent().get() == this);
-
-#ifndef NDEBUG
- // Be sure there's no duplicates
- Children::iterator existing = _children.find(o->path().name());
- assert(existing == _children.end());
-#endif
-
- _children.insert(make_pair(o->path().name(), o));
- signal_new_child.emit(o);
+ Store::Objects::const_iterator me = _store.objects().find(_path);
+ assert(me != _store.objects().end());
+ return _store.objects().find_descendants_end(me);
}
-bool
-ObjectModel::remove_child(SharedPtr<ObjectModel> o)
+
+SharedPtr<ObjectModel>
+ObjectModel::find_child(const string& name) const
{
- assert(o->path().is_child_of(_path));
- assert(o->parent().get() == this);
-
- Children::iterator i = _children.find(o->path().name());
- if (i != _children.end()) {
- assert(i->second == o);
- _children.erase(i);
- signal_removed_child.emit(o);
- return true;
- } else {
- cerr << "[ObjectModel::remove_child] " << _path
- << ": failed to find child " << o->path().name() << endl;
- return false;
- }
+ const_iterator me = _store.objects().find(_path);
+ assert(me != _store.objects().end());
+ const_iterator children_end = _store.objects().find_descendants_end(me);
+ const_iterator child = _store.objects().find(me, children_end, _path.base() + name);
+ if (child != _store.objects().end())
+ return child->second;
+ else
+ return SharedPtr<ObjectModel>();
}
+
/** Get a piece of metadata for this object.
*
* @return Metadata value with key @a key, empty string otherwise.