ShishGL  1.0
A simple modular cross-platform graphics library
ResourceManager.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_RESOURCE_MANAGER_HPP
3 #define SHISHGL_RESOURCE_MANAGER_HPP
4 /*============================================================================*/
5 #include <cstdint>
6 #include <string_view>
7 #include <unordered_map>
8 /*============================================================================*/
9 namespace Sh {
10 
12  public:
13 
14  struct Resource {
15  std::string_view filename;
16  size_t size;
17  uint8_t* data;
18  };
19 
20  ResourceManager() = delete;
21 
22  static void load(const std::string_view& filename);
23 
24  static const Resource& get(const std::string_view& filename);
25 
26  static void forget(const std::string_view& filename);
27 
28  static void clear();
29 
30  private:
31 
32  using ResourceMap = std::unordered_map<std::string_view, Resource>;
33 
34  static ResourceMap& Resources();
35  };
36 
37 }
38 /*============================================================================*/
39 #endif //SHISHGL_RESOURCE_MANAGER_HPP
40 /*============================================================================*/
Sh::ResourceManager::clear
static void clear()
Definition: ResourceManager.cpp:79
Sh::ResourceManager::get
static const Resource & get(const std::string_view &filename)
Definition: ResourceManager.cpp:61
Sh::ResourceManager::load
static void load(const std::string_view &filename)
Definition: ResourceManager.cpp:21
Sh
Definition: CoreApplication.hpp:10
Sh::ResourceManager::ResourceManager
ResourceManager()=delete
Sh::ResourceManager::Resource::data
uint8_t * data
Definition: ResourceManager.hpp:17
Sh::ResourceManager::forget
static void forget(const std::string_view &filename)
Definition: ResourceManager.cpp:72
Sh::ResourceManager::Resource
Definition: ResourceManager.hpp:14
Sh::ResourceManager
Definition: ResourceManager.hpp:11
Sh::ResourceManager::Resource::size
size_t size
Definition: ResourceManager.hpp:16
Sh::ResourceManager::Resource::filename
std::string_view filename
Definition: ResourceManager.hpp:15