From e7cd4fde2ca6775d2a1cfb28228b88da34b2f3cf Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Mon, 19 Aug 2019 15:41:45 +0200 Subject: [PATCH] Added function to retrieve all the resources from the ResourceManager --- src/Magnum/ResourceManager.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Magnum/ResourceManager.h b/src/Magnum/ResourceManager.h index d2d6f21ab3..e5a0b7ca28 100644 --- a/src/Magnum/ResourceManager.h +++ b/src/Magnum/ResourceManager.h @@ -118,6 +118,9 @@ template class ResourceManagerData { template Resource get(ResourceKey key); + template std::vector> getAll(); + + void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy); T* fallback() { return _fallback; } @@ -293,6 +296,10 @@ template class ResourceManager: private Implementation::Resource return this->Implementation::ResourceManagerData::template get(key); } + template std::vector> getAll() { + return this->Implementation::ResourceManagerData::template getAll(); + } + /** * @brief Reference count of given resource * @@ -536,6 +543,15 @@ template template Resource ResourceManagerData::get(R return Resource(this, key); } +template template std::vector> ResourceManagerData::getAll() { + std::vector> resources; + resources.reserve(_data.size()); + for (const auto& it : _data) { + resources.push_back(get(it.first)); + } + return resources; +} + template void ResourceManagerData::set(const ResourceKey key, T* const data, const ResourceDataState state, const ResourcePolicy policy) { auto it = _data.find(key); @@ -560,6 +576,7 @@ template void ResourceManagerData::set(const ResourceKey key, T* con ++_lastChange; } + template void ResourceManagerData::setFallback(T* const data) { safeDelete(_fallback); _fallback = data;