#include "GraphicsCache.h"
+#include "support/LAssert.h"
GraphicsCache * GraphicsCache::singleton = 0;
{
if (! singleton) {
singleton = new GraphicsCache;
+ Assert(singleton != 0);
}
return singleton;
GraphicsCache::~GraphicsCache()
{
- delete singleton;
+ // Free the map.
+ //std::foreach(map.begin(), map.end(), ...);
+ // This is not really needed, it will only happen on program close and in
+ // any case the OS will release those resources (not doing it may have
+ // a good effect on closing time).
+
+ delete singleton;
}
if (it != cache.end()) {
return (*it).second;
}
- // INCOMPLETE!
- return 0;
+
+ GraphicsCacheItem * cacheItem = new GraphicsCacheItem();
+ if (cacheItem == 0) {
+ return 0;
+ }
+
+ bool result = cacheItem->setFilename(filename);
+ if (!result)
+ return 0;
+
+ cache[filename] = cacheItem;
+
+ return cacheItem;
}