Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
ResourceManager.hpp
1 // Copyright (C) 2017 Jérôme Leclercq
2 // This file is part of the "Nazara Engine - Core module"
3 // For conditions of distribution and use, see copyright notice in Config.hpp
4 
5 #pragma once
6 
7 #ifndef NAZARA_RESOURCEMANAGER_HPP
8 #define NAZARA_RESOURCEMANAGER_HPP
9 
10 #include <Nazara/Core/ObjectRef.hpp>
11 #include <Nazara/Core/ResourceParameters.hpp>
12 #include <Nazara/Core/String.hpp>
13 #include <unordered_map>
14 
15 namespace Nz
16 {
17  template<typename Type, typename Parameters>
19  {
20  friend Type;
21 
22  public:
23  ResourceManager() = delete;
24  ~ResourceManager() = delete;
25 
26  static void Clear();
27 
28  static ObjectRef<Type> Get(const String& filePath);
29  static const Parameters& GetDefaultParameters();
30 
31  static void Purge();
32  static void Register(const String& filePath, ObjectRef<Type> resource);
33  static void SetDefaultParameters(const Parameters& params);
34  static void Unregister(const String& filePath);
35 
36  private:
37  static bool Initialize();
38  static void Uninitialize();
39 
40  using ManagerMap = std::unordered_map<String, ObjectRef<Type>>;
41  using ManagerParams = Parameters;
42  };
43 }
44 
45 #include <Nazara/Core/ResourceManager.inl>
46 
47 #endif // NAZARA_RESOURCEMANAGER_HPP
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
static void Unregister(const String &filePath)
Unregisters the resource under the filePath.
Definition: ResourceManager.inl:122
static ObjectRef< Type > Get(const String &filePath)
Gets a reference to the object loaded from file.
Definition: ResourceManager.inl:34
Core class that represents a string.
Definition: String.hpp:22
static void SetDefaultParameters(const Parameters &params)
Sets the defaults parameters for the load.
Definition: ResourceManager.inl:111
Core class that represents a reference to an object.
Definition: ObjectRef.hpp:18
static void Clear()
Clears the content of the manager.
Definition: ResourceManager.inl:22
Core class that represents a resource manager.
Definition: ResourceManager.hpp:18
static const Parameters & GetDefaultParameters()
Gets the defaults parameters for the load.
Definition: ResourceManager.inl:66
static void Register(const String &filePath, ObjectRef< Type > resource)
Registers the resource under the filePath.
Definition: ResourceManager.inl:98
static void Purge()
Purges the resource manager from every asset whose it is the only owner.
Definition: ResourceManager.inl:75