summaryrefslogtreecommitdiff
path: root/LibCore/CObject.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-27 03:52:19 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-27 03:52:19 +0200
commit906fde8f8c9bb9e8de3171823e84eb4e19dc7d78 (patch)
tree91bdaff9be4cbd64e55c38794efe0bcfcb19d2b0 /LibCore/CObject.h
parent3654c33c56df2d24bbe8de62de039b176047a13c (diff)
downloadserenity-906fde8f8c9bb9e8de3171823e84eb4e19dc7d78.zip
LibCore: Add CObject::for_each_child(callback).
Diffstat (limited to 'LibCore/CObject.h')
-rw-r--r--LibCore/CObject.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/LibCore/CObject.h b/LibCore/CObject.h
index e0656b2019..4f12811812 100644
--- a/LibCore/CObject.h
+++ b/LibCore/CObject.h
@@ -20,6 +20,15 @@ public:
Vector<CObject*>& children() { return m_children; }
const Vector<CObject*>& children() const { return m_children; }
+ template<typename Callback>
+ void for_each_child(Callback callback)
+ {
+ for (auto* child : m_children) {
+ if (callback(*child) == IterationDecision::Abort)
+ return;
+ }
+ }
+
CObject* parent() { return m_parent; }
const CObject* parent() const { return m_parent; }