SparrowEngine/resourcemanager.h
2015-09-23 21:22:04 +02:00

24 lines
725 B
C++

#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H
#include <string>
#include <unordered_map>
#define RESOURCE_ADD(ptr, type, name) ResourceManager::add((void*)ptr, #type, name)
#define RESOURCE_GET(type, name) ((type*)(ResourceManager::get(#type, name)))
#define RESOURCE_CHECK(type,name) ResourceManager::check(#type, name)
class ResourceManager
{
private:
static std::unordered_map<std::string, std::unordered_map<std::string, void*>> data;
public:
static void add(void* resource, const std::string &type, const std::string name);
static void* get(const std::string &type, const std::string name);
static bool check(const std::string &type, const std::string name);
};
#endif // RESOURCEMANAGER_H