diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-05-27 03:52:19 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-05-27 03:52:19 +0200 |
commit | 906fde8f8c9bb9e8de3171823e84eb4e19dc7d78 (patch) | |
tree | 91bdaff9be4cbd64e55c38794efe0bcfcb19d2b0 /LibCore/CObject.h | |
parent | 3654c33c56df2d24bbe8de62de039b176047a13c (diff) | |
download | serenity-906fde8f8c9bb9e8de3171823e84eb4e19dc7d78.zip |
LibCore: Add CObject::for_each_child(callback).
Diffstat (limited to 'LibCore/CObject.h')
-rw-r--r-- | LibCore/CObject.h | 9 |
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; } |