9#include <Common/assertion.h>
10#include <Common/logging.h>
30 PH_DEFAULT_LOG(Warning,
31 "default resource creation failed, {} could be abstract or defined to be uninstantiable",
40template<CSdlResource T>
46template<CSdlResource T>
50 "No SDL class definition found. Did you call PH_DEFINE_SDL_CLASS() in the body of type T?");
52 const SdlClass* clazz = T::getSdlClass();
64 std::shared_ptr<T> typedResource = std::dynamic_pointer_cast<T>(std::move(resource));
67 PH_DEFAULT_LOG(Warning,
68 "default resource creation failed, {} may not have SDL class defined",
74template<CSdlResource T>
75template<
typename... DeducedArgs>
78 static_assert(std::is_constructible_v<T, DeducedArgs...>,
79 "SDL class type T is not constructible using the specified arguments.");
81 T instance(std::forward<DeducedArgs>(args)...);
84 const SdlClass* clazz = T::getSdlClass();
92 "SDL struct definition of T does not support initializing to default values");
94 const auto* ztruct = T::getSdlStruct();
97 ztruct->initDefaultStruct(instance);
102 "No SDL class/struct definition found. Did you call "
103 "PH_DEFINE_SDL_CLASS()/PH_DEFINE_SDL_STRUCT() in the body of type T?");
109template<CSdlResource T>
118 PH_ASSERT(std::dynamic_pointer_cast<T>(loadedResource));
124 return std::static_pointer_cast<T>(loadedResource);
128 PH_STATIC_ASSERT_DEPENDENT_FALSE(T,
129 "Cannot load resource without SDL class definition. Did you call PH_DEFINE_SDL_CLASS() "
130 "in the body of type T?");
134template<CSdlResource T>
General path representation. Does not check whether the target actually exists (e....
Definition Path.h:21
std::string genPrettyName() const
Definition SdlClass.cpp:27
virtual std::shared_ptr< ISdlResource > createResource() const =0
virtual void initDefaultResource(ISdlResource &resource) const =0
Initialize a resource to default values. Default values are defined by the resource class's SDL defin...
Whether T is a well-defined SDL class.
Definition sdl_traits.h:29
Whether T is a well-defined SDL struct.
Definition sdl_traits.h:36
Definition sdl_traits.h:61
std::shared_ptr< ISdlResource > load_single_resource(const SdlClass *resourceClass, const Path &file)
Definition TSdl.cpp:20
void save_single_resource(const std::shared_ptr< ISdlResource > &resource, const Path &file)
Definition TSdl.cpp:65
constexpr ESdlTypeCategory category_of()
Statically gets the SDL category of T.
Definition sdl_helpers.ipp:409
The root for all renderer implementations.
Definition EEngineProject.h:6
ESdlTypeCategory
Definition ESdlTypeCategory.h:15
Low-level helpers for SDL. Helpers are in an additional sdl namespace.