Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/objectdb_profiler/editor/snapshot_data.h
21101 views
1
/**************************************************************************/
2
/* snapshot_data.h */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#pragma once
32
33
#include "editor/debugger/editor_debugger_inspector.h"
34
35
class GameStateSnapshot;
36
37
class SnapshotDataObject : public Object {
38
GDCLASS(SnapshotDataObject, Object);
39
40
HashSet<ObjectID> _unique_references(const HashMap<String, ObjectID> &p_refs);
41
String _get_script_name(Ref<Script> p_script);
42
43
public:
44
GameStateSnapshot *snapshot = nullptr;
45
Dictionary extra_debug_data;
46
HashMap<String, ObjectID> outbound_references;
47
HashMap<String, ObjectID> inbound_references;
48
49
HashSet<ObjectID> get_unique_outbound_refernces();
50
HashSet<ObjectID> get_unique_inbound_references();
51
52
uint64_t remote_object_id = 0;
53
String type_name;
54
LocalVector<PropertyInfo> prop_list;
55
HashMap<StringName, Variant> prop_values;
56
bool _get(const StringName &p_name, Variant &r_ret) const;
57
void _get_property_list(List<PropertyInfo> *p_list) const;
58
59
struct ResourceCache {
60
HashMap<String, Ref<Resource>> cache;
61
int misses = 0;
62
int hits = 0;
63
};
64
65
SnapshotDataObject(SceneDebuggerObject &p_obj, GameStateSnapshot *p_snapshot, ResourceCache &resource_cache);
66
67
String get_name();
68
String get_node_path();
69
bool is_refcounted();
70
bool is_node();
71
bool is_class(const String &p_base_class);
72
73
protected:
74
// Snapshots are inherently read-only. Can't edit the past.
75
bool _is_read_only() { return true; }
76
static void _bind_methods();
77
};
78
79
class GameStateSnapshot : public RefCounted {
80
GDCLASS(GameStateSnapshot, RefCounted);
81
82
void _get_outbound_references(Variant &p_var, HashMap<String, ObjectID> &r_ret_val, const String &p_current_path = "");
83
void _get_rc_cycles(SnapshotDataObject *p_obj, SnapshotDataObject *p_source_obj, HashSet<SnapshotDataObject *> p_traversed_objs, LocalVector<String> &r_ret_val, const String &p_current_path = "");
84
85
public:
86
String name;
87
HashMap<ObjectID, SnapshotDataObject *> objects;
88
Dictionary snapshot_context;
89
90
static Ref<GameStateSnapshot> create_ref(const String &p_snapshot_name, const Vector<uint8_t> &p_snapshot_buffer);
91
~GameStateSnapshot();
92
93
void recompute_references();
94
};
95
96