RemoteObjectGraphModel.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <AK/JsonArray.h>
  3. #include <AK/NonnullOwnPtrVector.h>
  4. #include <LibCore/CLocalSocket.h>
  5. #include <LibGUI/GModel.h>
  6. class RemoteObjectGraphModel final : public GModel {
  7. public:
  8. static NonnullRefPtr<RemoteObjectGraphModel> create_with_pid(pid_t pid)
  9. {
  10. return adopt(*new RemoteObjectGraphModel(pid));
  11. }
  12. virtual ~RemoteObjectGraphModel() override;
  13. virtual int row_count(const GModelIndex& = GModelIndex()) const override;
  14. virtual int column_count(const GModelIndex& = GModelIndex()) const override;
  15. virtual GVariant data(const GModelIndex&, Role = Role::Display) const override;
  16. virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override;
  17. virtual void update() override;
  18. private:
  19. struct RemoteObject {
  20. RemoteObject* parent { nullptr };
  21. Vector<OwnPtr<RemoteObject>> children;
  22. String address;
  23. String parent_address;
  24. String class_name;
  25. String name;
  26. };
  27. explicit RemoteObjectGraphModel(pid_t);
  28. pid_t m_pid { -1 };
  29. CLocalSocket m_socket;
  30. JsonArray m_json;
  31. NonnullOwnPtrVector<RemoteObject> m_remote_roots;
  32. GIcon m_object_icon;
  33. };