From fe6e1686ce484cb0dd9a69f130e82f647c30016f Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Wed, 10 Sep 2025 01:30:59 +0800 Subject: xcb window reparent. --- include/cru/platform/Check.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include/cru/platform/Check.h') diff --git a/include/cru/platform/Check.h b/include/cru/platform/Check.h index 270150e8..202ee86e 100644 --- a/include/cru/platform/Check.h +++ b/include/cru/platform/Check.h @@ -35,4 +35,32 @@ std::shared_ptr CheckPlatform(const std::shared_ptr& resource, } return result; } + +template +TTarget* CheckPlatform(IPlatformResource* resource, + std::string target_platform) { + if (resource == nullptr) return nullptr; + const auto result = dynamic_cast(resource); + if (result == nullptr) { + throw PlatformNotMatchException( + resource->GetPlatformIdUtf8(), target_platform, + "Try to convert resource to target platform failed."); + } + return result; +} + +template +std::shared_ptr CheckPlatform(const std::shared_ptr& resource, + std::string target_platform) { + if (resource == nullptr) return nullptr; + static_assert(std::is_base_of_v, + "TSource must be a subclass of IPlatformResource."); + const auto result = std::dynamic_pointer_cast(resource); + if (result == nullptr) { + throw PlatformNotMatchException( + resource->GetPlatformIdUtf8(), target_platform, + "Try to convert resource to target platform failed."); + } + return result; +} } // namespace cru::platform -- cgit v1.2.3