galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Loader.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_RESOURCE_LOADER_HPP_
9#define GALAXY_RESOURCE_LOADER_HPP_
10
11#include "galaxy/error/Log.hpp"
12
13namespace galaxy
14{
15 namespace resource
16 {
22 template<typename Resource>
23 requires meta::not_memory<Resource> && meta::is_class<Resource>
24 struct Loader
25 {
33 inline std::unique_ptr<Resource> operator()(const std::string& file)
34 {
35 auto resource = std::make_unique<Resource>();
36 if (!resource->load(file))
37 {
38 GALAXY_LOG(GALAXY_FATAL, "Failed to load resource '{0}'.", file);
39 return nullptr;
40 }
41
42 return resource;
43 }
44 };
45 } // namespace resource
46} // namespace galaxy
47
48#endif
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:29
#define GALAXY_FATAL
Definition Log.hpp:26
Timer.hpp galaxy.
Definition Async.hpp:17
Loads resources for a resource cache.
Definition Loader.hpp:25
std::unique_ptr< Resource > operator()(const std::string &file)
Overloaded operator() used to load a resource.
Definition Loader.hpp:33