#ifndef RESOURCEBASE_H #define RESOURCEBASE_H class Texture; class Mesh; class Material; class Shader; class Entity; #include #include #include class ResourceBase { public: static void setTexture(const std::string &textureName, Texture* myTexture); static void setMesh(const std::string &meshName, Mesh* myMesh); static void setMaterial(const std::string &materialName, Material* myMaterial); static void setShader(const std::string &shaderName, Shader* myShader); static void setEntity(const std::string &entityName, Entity* myEntity); static Texture* getTexture(const std::string &textureName); static Mesh* getMesh(const std::string &meshName); static Material* getMaterial(const std::string &materialName); static Shader* getShader(const std::string &shaderName); static Entity* getEntity(const std::string &entityName); private: template class DataBase { public: std::vector names; std::unordered_map data; void add(const std::string &name, T* t) { data[name] = t; names.push_back(name); } T* get(const std::string &name) { return data[name]; } }; static DataBase textures; static DataBase meshes; static DataBase materials; static DataBase shaders; static DataBase entities; }; #endif // RESOURCEBASE_H