Lugdunum  0.1.0
ResourceManager.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <mutex>
5 #include <unordered_map>
6 #include <vector>
7 
11 
12 namespace lug {
13 namespace Graphics {
14 
15 class Renderer;
16 
24 public:
29  ResourceManager(Renderer& renderer);
30 
31  ResourceManager(const ResourceManager&) = delete;
32  ResourceManager(ResourceManager&&) = delete;
33 
34  ResourceManager& operator=(const ResourceManager&) = delete;
35  ResourceManager& operator=(ResourceManager&&) = delete;
36 
37  ~ResourceManager() = default;
38 
46  template <typename T = Resource>
48 
56  template <typename T = Resource>
57  Resource::SharedPtr<T> add(std::unique_ptr<Resource> resource);
58 
67  Resource::SharedPtr<Resource> loadFile(const std::string& filename);
68 
69 private:
71  std::vector<std::unique_ptr<Resource>> _resources;
72 
78  std::unordered_map<std::string, std::unique_ptr<Loader>> _loaders;
79 
80  std::mutex _mutex;
81 };
82 
84 
85 } // Graphics
86 } // lug
std::unordered_map< std::string, std::unique_ptr< Loader > > _loaders
std::vector< std::unique_ptr< Resource > > _resources
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
Dummy class for a shared pointer.
Definition: Resource.hpp:66
Handle of the resource. It contains informations such as the type and the index in the ResourceManage...
Definition: Resource.hpp:41
Class for resource manager. The ResourceManager allows the user to load resources and store them...