aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2009-11-26 15:46:02 -0300
committerLauro Neto <lauro.neto@openbossa.org>2009-11-27 16:58:01 -0300
commit104eb1dd5d662e75f39badbcb689d8137cf2f5b9 (patch)
treeb7974e7bacbf6daa6d4ffadc17e96ef3a5094395 /tests
parenteb5cadcdddf834d5df0b36d19d9411e4cf931cce (diff)
Add removeChild and killChild to ObjectType test
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/objecttype.cpp32
-rw-r--r--tests/libsample/objecttype.h2
2 files changed, 27 insertions, 7 deletions
diff --git a/tests/libsample/objecttype.cpp b/tests/libsample/objecttype.cpp
index e6a42d6d8..711a72f5b 100644
--- a/tests/libsample/objecttype.cpp
+++ b/tests/libsample/objecttype.cpp
@@ -53,24 +53,42 @@ ObjectType::~ObjectType()
}
void
+ObjectType::removeChild(const ObjectType *child)
+{
+ for(ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); child_iter++) {
+ if (this == *child_iter)
+ m_children.erase(child_iter);
+ }
+}
+
+void
ObjectType::setParent(ObjectType* parent)
{
if (m_parent == parent)
return;
- if (m_parent) {
- for(ObjectTypeList::iterator child_iter = m_parent->m_children.begin();
- child_iter != m_parent->m_children.end(); child_iter++) {
- if (this == *child_iter)
- m_parent->m_children.erase(child_iter);
- }
- }
+ if (m_parent)
+ m_parent->removeChild(this);
m_parent = parent;
if (m_parent)
m_parent->m_children.push_back(this);
}
+void ObjectType::killChild(const Str &name)
+{
+ for (ObjectTypeList::iterator child_iter = m_children.begin();
+ child_iter != m_children.end(); child_iter++) {
+
+ if ((*child_iter)->objectName() == name) {
+ this->removeChild(*child_iter);
+ delete *child_iter;
+ break;
+ }
+ }
+}
+
void
ObjectType::setObjectName(const Str& name)
{
diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h
index 8a97c669a..74b6e40e6 100644
--- a/tests/libsample/objecttype.h
+++ b/tests/libsample/objecttype.h
@@ -68,6 +68,8 @@ public:
void setParent(ObjectType* parent);
ObjectType* parent() const { return m_parent; }
const ObjectTypeList& children() const { return m_children; }
+ void killChild(const Str& name);
+ void removeChild(const ObjectType *child);
Str objectName() const;
void setObjectName(const Str& name);