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:
47
src/resource/public/resourceManager.h
Normal file
47
src/resource/public/resourceManager.h
Normal 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
|
||||
Reference in New Issue
Block a user