From 76746163e04555eb129fc2590ee8b0312fad872c Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Mon, 3 Nov 2025 20:12:12 +0800 Subject: Merge platform/Exception.h Check.h to Base.h. --- include/cru/platform/Check.h | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 include/cru/platform/Check.h (limited to 'include/cru/platform/Check.h') diff --git a/include/cru/platform/Check.h b/include/cru/platform/Check.h deleted file mode 100644 index 5b6cd2be..00000000 --- a/include/cru/platform/Check.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "Base.h" -#include "Exception.h" - -#include -#include - -namespace cru::platform { -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->GetPlatformId(), 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->GetPlatformId(), target_platform, - "Try to convert resource to target platform failed."); - } - return result; -} -} // namespace cru::platform -- cgit v1.2.3