/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/ThirdParty/RmlUi/Source/Core/ControlledLifetimeResource.h
62 строки
1 KB
C-Core
Updated RmlUi to 6.2 and added some improvements (#1813)
10 фев 2026, 01:19
Не верифицирован
10 фев 2026, 01:19
58e2d41
Код
Авторство
О чём код?
#pragma once #include "../../Include/RmlUi/Core/Debug.h" #include "../../Include/RmlUi/Core/Traits.h" namespace Rml { template <typename T> class ControlledLifetimeResource : NonCopyMoveable { public: ControlledLifetimeResource() = default; ~ControlledLifetimeResource() noexcept { #if defined(RMLUI_PLATFORM_WIN32) && !defined(RMLUI_STATIC_LIB) RMLUI_ASSERTMSG(!pointer || intentionally_leaked, "Resource was not properly shut down."); #endif } explicit operator bool() const noexcept { return pointer != nullptr; } void Initialize() { RMLUI_ASSERTMSG(!pointer, "Resource already initialized."); pointer = new T(); } void InitializeIfEmpty() { if (!pointer) Initialize(); else SetIntentionallyLeaked(false); } void Leak() { SetIntentionallyLeaked(true); } void Shutdown() { RMLUI_ASSERTMSG(pointer, "Shutting down resource that was not initialized, or has been shut down already."); RMLUI_ASSERTMSG(!intentionally_leaked, "Shutting down resource that was marked as leaked."); delete pointer; pointer = nullptr; } T* operator->() { RMLUI_ASSERTMSG(pointer, "Resource used before it was initialized, or after it was shut down."); return pointer; } private: #ifdef RMLUI_DEBUG void SetIntentionallyLeaked(bool leaked) { intentionally_leaked = leaked; } bool intentionally_leaked = false; #else void SetIntentionallyLeaked(bool /*leaked*/) {} #endif T* pointer = nullptr; }; } // namespace Rml