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