But I am running into a strange problem with adding resources to the pool. Each pool is represented as an std::map, and after insertion, the map still remains empty. I am guessing this has something to do with the map being inside a static class. Is this why maps don't work as intended here?
Here's my ResourcePool class with the relevant code in it.
class ResourcePool { private: static ResourcePool m_ResourcePool; std::map <std::string, TextureResource> TexturePool; public: ResourcePool(); ~ResourcePool(); static ResourcePool* Instance() { return &m_ResourcePool; } std::map <std::string, TextureResource> Textures() { return TexturePool }; TextureResource* getTexture(std::string handle);};
And an example of adding resources being implemented in another class.
Scene::Scene() { // Pointer to static class Assets = ResourcePool::Instance();}TextureResource* Scene::add(std::string handle, TextureResource Texture) { Assets->Textures().insert(std::make_pair(handle, Texture)); // For debug purposes. The map still remains empty unsigned size = Assets->Textures().size(); return Assets->getTexture(handle);}
[Edited by - JustChris on December 23, 2010 6:12:56 PM]