Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 * Copyright (c) 2022, the SerenityOS developers.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#include <AK/WeakPtr.h>
9#include <LibCore/Event.h>
10#include <LibCore/Object.h>
11
12namespace Core {
13
14ChildEvent::ChildEvent(Type type, Object& child, Object* insertion_before_child)
15 : Core::Event(type)
16 , m_child(child.make_weak_ptr())
17 , m_insertion_before_child(AK::make_weak_ptr_if_nonnull(insertion_before_child))
18{
19}
20
21Object* ChildEvent::child()
22{
23 if (auto ref = m_child.strong_ref())
24 return ref.ptr();
25 return nullptr;
26}
27
28Object const* ChildEvent::child() const
29{
30 if (auto ref = m_child.strong_ref())
31 return ref.ptr();
32 return nullptr;
33}
34
35Object* ChildEvent::insertion_before_child()
36{
37 if (auto ref = m_insertion_before_child.strong_ref())
38 return ref.ptr();
39 return nullptr;
40}
41
42Object const* ChildEvent::insertion_before_child() const
43{
44 if (auto ref = m_insertion_before_child.strong_ref())
45 return ref.ptr();
46 return nullptr;
47}
48
49}