bool ResourceManager::loadResourceGroup(const std::string &groupName) { // note: it's ok to load a group more than once as long as it's // released more than once too. different parts of the code // can use the same resource group and each of them should load // it when they need it and unload it when they done with it if (mResourceGroups.find(groupName) != mResourceGroups.end()) { // disable full screen toggle while resource load/unload: Environment::instance()->disableFullScreenToggle(); ResourceGroup *g = mResourceGroups[groupName]; bool success = true; if (!g->isEmpty()) { for (const std::string *path = g->getFirstPath() ; path!=NULL ; path = g->getNextPath()) { assert(mResourcesByPath.find(*path) != mResourcesByPath.end()); Resource *res = mResourcesByPath[*path]; assert(res!=NULL); success &= res->load(); } } Environment::instance()->enableFullScreenToggle(); return success; } else { assert(false); return false; } }
void ResourceManager::unloadResourceGroup(const std::string &groupName) { if (mResourceGroups.find(groupName) != mResourceGroups.end()) { // disable full screen toggle while resource load/unload: Environment::instance()->disableFullScreenToggle(); ResourceGroup *g = mResourceGroups[groupName]; for (const std::string *path=g->getFirstPath() ; path!=NULL ; path=g->getNextPath()) { Resource *res = mResourcesByPath[*path]; assert(res!=NULL); res->release(); } Environment::instance()->enableFullScreenToggle(); } else { assert(false); } }