summaryrefslogtreecommitdiffstats
path: root/src/libs/client/ObjectModel.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-07-26 09:32:49 +0000
committerDavid Robillard <d@drobilla.net>2007-07-26 09:32:49 +0000
commitf7368e7850307de97b024238a4f520afe1150c8b (patch)
treebcc3cb7099c57cb4b3206f68c41e8b828175b18a /src/libs/client/ObjectModel.cpp
parent397667bfaffdb622dfcf5bbbf64c49fd6a729f7e (diff)
downloadingen-f7368e7850307de97b024238a4f520afe1150c8b.tar.gz
ingen-f7368e7850307de97b024238a4f520afe1150c8b.tar.bz2
ingen-f7368e7850307de97b024238a4f520afe1150c8b.zip
Add const find interface to Raul::Table, fix bugs.
Use Raul::Table on Ingen client side instead of std::map for objects, plugins. Work on renaming (still broken). git-svn-id: http://svn.drobilla.net/lad/ingen@634 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/ObjectModel.cpp')
-rw-r--r--src/libs/client/ObjectModel.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libs/client/ObjectModel.cpp b/src/libs/client/ObjectModel.cpp
index 699d1ce7..f1393232 100644
--- a/src/libs/client/ObjectModel.cpp
+++ b/src/libs/client/ObjectModel.cpp
@@ -16,6 +16,10 @@
*/
#include "ObjectModel.hpp"
+#include <raul/TableImpl.hpp>
+#include <iostream>
+
+using namespace std;
namespace Ingen {
namespace Client {
@@ -31,6 +35,50 @@ ObjectModel::~ObjectModel()
{
}
+SharedPtr<ObjectModel>
+ObjectModel::get_child(const string& name) const
+{
+ assert(name.find("/") == string::npos);
+ Children::const_iterator i = _children.find(name);
+ return ((i != _children.end()) ? (*i).second : SharedPtr<ObjectModel>());
+}
+
+void
+ObjectModel::add_child(SharedPtr<ObjectModel> o)
+{
+ 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));
+ new_child_sig.emit(o);
+}
+
+bool
+ObjectModel::remove_child(SharedPtr<ObjectModel> o)
+{
+ 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);
+ removed_child_sig.emit(o);
+ return true;
+ } else {
+ cerr << "[ObjectModel::remove_child] " << _path
+ << ": failed to find child " << o->path().name() << endl;
+ return false;
+ }
+}
+
/** Get a piece of metadata for this object.
*
* @return Metadata value with key @a key, empty string otherwise.