SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
ImageManager.h
1#ifndef ImageManager_H
2#define ImageManager_H
3
4#include "AzulCore.h"
5#include <map>
6
7using MapKey = std::string const;
8
16class ImageManager
17{
18private:
19 friend class ImageManagerAttorney;
20
21 static ImageManager* ptrInstance;
22
23 ImageManager();
24 ImageManager(const ImageManager&) = delete;
25 ImageManager& operator=(const ImageManager&) = delete;
26 ~ImageManager() = default;
27
28 static ImageManager& Instance()
29 {
30 if (ptrInstance == nullptr)
31 ptrInstance = new ImageManager();
32 return *ptrInstance;
33 };
34
38 static void Delete() { Instance().privDelete(); };
39 void privDelete();
40
44 std::map<MapKey, Image*> storageMap;
45
46 Image* privGet(MapKey key);
47 void privLoad(MapKey key, Texture* tex);
48 void privLoad(MapKey key, Texture* tex, Rect* r);
49
50public:
54 static const MapKey defaultImageKey;
55
62 static Image* Get(MapKey key) { return Instance().privGet(key); };
63
70 static void Load(MapKey key, Texture* tex) { Instance().privLoad(key, tex); };
71
79 static void Load(MapKey key, Texture* tex, Rect* r) { Instance().privLoad(key, tex, r); };
80
81};
82
83#endif
static const MapKey defaultImageKey
Default key for the default image.
Definition ImageManager.h:54
static Image * Get(MapKey key)
Retrieves an Image object by its key.
Definition ImageManager.h:62
static void Load(MapKey key, Texture *tex)
Loads an Image object from a Texture.
Definition ImageManager.h:70
std::map< MapKey, Image * > storageMap
Map storing Image objects associated with their keys.
Definition ImageManager.h:44
static void Delete()
Deletes all managed Image objects and the singleton instance.
Definition ImageManager.h:38
static void Load(MapKey key, Texture *tex, Rect *r)
Loads an Image object from a Texture and a Rect.
Definition ImageManager.h:79