feat(resource-manager): added working singleton resource manager

all external data should now be handled through the resource manager. This will take care of location on disk as well as ownership
This commit is contained in:
2025-03-20 14:26:44 -04:00
parent 1cc21a368b
commit 08075f5108
7 changed files with 303 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
#ifndef RESOURCE_MANAGER_H
#define RESOURCE_MANAGER_H
#include <vector>
#include <string>
#include <stdexcept>
#include <unordered_map>
#include "resourceManagerTypes.h"
#include "config.h"
#include "probe.h"
#include "quill/LogMacros.h"
class ResourceManager {
private:
ResourceManager();
ResourceManager(const ResourceManager&) = delete;
ResourceManager& operator=(const ResourceManager&) = delete;
Config& m_config = Config::getInstance();
Probe::LogManager& m_logManager = Probe::LogManager::getInstance();
quill::Logger* m_logger = m_logManager.getLogger("log");
Config m_resourceConfig;
std::string m_dataDir;
std::unordered_map<std::string, Resource> m_resources;
bool load(const std::string& name);
public:
static ResourceManager& getInstance() {
static ResourceManager instance;
return instance;
}
std::vector<std::string> getAvaliableResources();
const Resource& getResource(const std::string &name) const;
bool loadResource(std::string& name);
std::unordered_map<std::string, bool> loadAllResources();
};
#endif // RESOURCE_MANAGER_H