Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Magnum/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ template<class T> class ResourceManagerData {

template<class U> Resource<T, U> get(ResourceKey key);

template<class U> std::vector<Resource<T, U>> getAll();


void set(ResourceKey key, T* data, ResourceDataState state, ResourcePolicy policy);

T* fallback() { return _fallback; }
Expand Down Expand Up @@ -293,6 +296,10 @@ template<class... Types> class ResourceManager: private Implementation::Resource
return this->Implementation::ResourceManagerData<T>::template get<U>(key);
}

template<class T, class U = T> std::vector<Resource<T, U>> getAll() {
return this->Implementation::ResourceManagerData<T>::template getAll<U>();
}

/**
* @brief Reference count of given resource
*
Expand Down Expand Up @@ -536,6 +543,15 @@ template<class T> template<class U> Resource<T, U> ResourceManagerData<T>::get(R
return Resource<T, U>(this, key);
}

template<class T> template<class U> std::vector<Resource<T, U>> ResourceManagerData<T>::getAll() {
std::vector<Resource<T, U>> resources;
resources.reserve(_data.size());
for (const auto& it : _data) {
resources.push_back(get<T>(it.first));
}
return resources;
}

template<class T> void ResourceManagerData<T>::set(const ResourceKey key, T* const data, const ResourceDataState state, const ResourcePolicy policy) {
auto it = _data.find(key);

Expand All @@ -560,6 +576,7 @@ template<class T> void ResourceManagerData<T>::set(const ResourceKey key, T* con
++_lastChange;
}


template<class T> void ResourceManagerData<T>::setFallback(T* const data) {
safeDelete(_fallback);
_fallback = data;
Expand Down