aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform/Check.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-03 20:12:12 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-03 20:12:12 +0800
commit76746163e04555eb129fc2590ee8b0312fad872c (patch)
tree673c606c245456b13510caadaa37b67b19b6973a /include/cru/platform/Check.h
parent06f16479ae1b727252404b763b60c924e3fe7903 (diff)
downloadcru-76746163e04555eb129fc2590ee8b0312fad872c.tar.gz
cru-76746163e04555eb129fc2590ee8b0312fad872c.tar.bz2
cru-76746163e04555eb129fc2590ee8b0312fad872c.zip
Merge platform/Exception.h Check.h to Base.h.
Diffstat (limited to 'include/cru/platform/Check.h')
-rw-r--r--include/cru/platform/Check.h36
1 files changed, 0 insertions, 36 deletions
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 <memory>
-#include <type_traits>
-
-namespace cru::platform {
-template <typename TTarget>
-TTarget* CheckPlatform(IPlatformResource* resource,
- std::string target_platform) {
- if (resource == nullptr) return nullptr;
- const auto result = dynamic_cast<TTarget*>(resource);
- if (result == nullptr) {
- throw PlatformNotMatchException(
- resource->GetPlatformId(), target_platform,
- "Try to convert resource to target platform failed.");
- }
- return result;
-}
-
-template <typename TTarget, typename TSource>
-std::shared_ptr<TTarget> CheckPlatform(const std::shared_ptr<TSource>& resource,
- std::string target_platform) {
- if (resource == nullptr) return nullptr;
- static_assert(std::is_base_of_v<IPlatformResource, TSource>,
- "TSource must be a subclass of IPlatformResource.");
- const auto result = std::dynamic_pointer_cast<TTarget>(resource);
- if (result == nullptr) {
- throw PlatformNotMatchException(
- resource->GetPlatformId(), target_platform,
- "Try to convert resource to target platform failed.");
- }
- return result;
-}
-} // namespace cru::platform