mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:35:09 +00:00
LibCore: Allow RPC clients to specify the currently inspected object
Add a SetInspectedObject call that tells us which Core::Object a remote client is currently looking it. Objects get notified when they gain their first inspector, and when they lose their last one.
This commit is contained in:
parent
37c71bad8a
commit
d16f8214d8
3 changed files with 43 additions and 2 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
|
@ -167,9 +168,9 @@ void Object::deferred_invoke(Function<void(Object&)> invokee)
|
|||
void Object::save_to(JsonObject& json)
|
||||
{
|
||||
json.set("class_name", class_name());
|
||||
json.set("address", String::format("%p", this));
|
||||
json.set("address", (uintptr_t)this);
|
||||
json.set("name", name());
|
||||
json.set("parent", String::format("%p", parent()));
|
||||
json.set("parent", (uintptr_t)parent());
|
||||
}
|
||||
|
||||
bool Object::is_ancestor_of(const Object& other) const
|
||||
|
@ -205,6 +206,20 @@ bool Object::is_visible_for_timer_purposes() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void Object::increment_inspector_count(Badge<RPCClient>)
|
||||
{
|
||||
++m_inspector_count;
|
||||
if (m_inspector_count == 1)
|
||||
did_begin_inspection();
|
||||
}
|
||||
|
||||
void Object::decrement_inspector_count(Badge<RPCClient>)
|
||||
{
|
||||
--m_inspector_count;
|
||||
if (!m_inspector_count)
|
||||
did_end_inspection();
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Object& object)
|
||||
{
|
||||
return stream << object.class_name() << '{' << &object << '}';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue