std::unique_ptr<CInputStream> CFilesystemList::load(const ResourceID & resourceName) const { // load resource from last loader that have it (last overridden version) for (auto & loader : boost::adaptors::reverse(loaders)) { if (loader->existsResource(resourceName)) return loader->load(resourceName); } throw std::runtime_error("Resource with name " + resourceName.getName() + " and type " + EResTypeHelper::getEResTypeAsString(resourceName.getType()) + " wasn't found."); }
std::unique_ptr<CInputStream> CResourceLoader::load(const ResourceID & resourceIdent) const { auto resource = resources.find(resourceIdent); if(resource == resources.end()) { throw std::runtime_error("Resource with name " + resourceIdent.getName() + " and type " + EResTypeHelper::getEResTypeAsString(resourceIdent.getType()) + " wasn't found."); } // get the last added resource(most overriden) const ResourceLocator & locator = resource->second.back(); // load the resource and return it return locator.getLoader()->load(locator.getResourceName()); }