Loading...
Searching...
No Matches
ResourceManager.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 10/3/25.
3//
4
5#ifndef RESOURCEMANAGER_H
6#define RESOURCEMANAGER_H
7
8#include <algorithm>
9#include <unordered_map>
12#include <string>
13#include <stdexcept>
14
15namespace ml
16{
34 template<typename Manifest,
35 typename Resource,
36 bool (*loadFunction)(Resource&, const std::string&) = &fileLoader>
42 {
43 public:
54 template<typename Asset>
55 static const Resource& get(const Asset& asset);
56
67 template<typename Asset>
68 static void unload(Asset asset);
69
70 private:
78 template<typename Asset>
79 static std::unordered_map<Asset, Resource, EnumClassHash>& cache();
80 };
81
82} // namespace ml
83
84#include "../../../src/Resources/ResourceManager.tpp"
85#endif // RESOURCEMANAGER_H
Base class for all Malena manifests.
Definition Manifest.h:81
Generic manifest-driven resource cache.
static void unload(Asset asset)
Remove a resource from the cache.
static const Resource & get(const Asset &asset)
Retrieve the cached resource for an asset enum value.
Definition Component.h:18
bool fileLoader(Resource &r, const std::string &path)