summaryrefslogtreecommitdiff
path: root/DevTools/Inspector/RemoteObjectGraphModel.h
blob: 7aa239b19e48133f4b30b3783c8f92d6bd4bdd81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include <AK/JsonArray.h>
#include <AK/NonnullOwnPtrVector.h>
#include <LibCore/CLocalSocket.h>
#include <LibGUI/GModel.h>

class RemoteObjectGraphModel final : public GModel {
public:
    static NonnullRefPtr<RemoteObjectGraphModel> create_with_pid(pid_t pid)
    {
        return adopt(*new RemoteObjectGraphModel(pid));
    }

    virtual ~RemoteObjectGraphModel() override;

    virtual int row_count(const GModelIndex& = GModelIndex()) const override;
    virtual int column_count(const GModelIndex& = GModelIndex()) const override;
    virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
    virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override;
    virtual void update() override;

private:
    struct RemoteObject {
        RemoteObject* parent { nullptr };
        Vector<OwnPtr<RemoteObject>> children;

        String address;
        String parent_address;
        String class_name;
        String name;
    };

    explicit RemoteObjectGraphModel(pid_t);

    pid_t m_pid { -1 };
    CLocalSocket m_socket;
    JsonArray m_json;
    NonnullOwnPtrVector<RemoteObject> m_remote_roots;
    GIcon m_object_icon;
};