A non-owning cache for resources loaded from file paths.
More...
#include <FileResourceCache.h>
|
template<typename Factory>
requires (std::is_invocable_r_v<std::shared_ptr<const T>, Factory>) |
| auto | fetch (const std::filesystem::path &path, Factory &&factory) -> std::shared_ptr< const T > |
template<typename T>
class lmms::FileResourceCache< T >
A non-owning cache for resources loaded from file paths.
- Todo
- In the future, this class should have a cache replacement policy in order to cache unused resources temporarily until they are requested again, or if the eviction criteria is met.
- Template Parameters
-
| T | The type of resource to cache. |
◆ fetch()
template<typename T>
template<typename Factory>
requires (std::is_invocable_r_v<std::shared_ptr<const T>, Factory>)
| auto lmms::FileResourceCache< T >::fetch |
( |
const std::filesystem::path & | path, |
|
|
Factory && | factory ) -> std::shared_ptr< const T > |
|
inline |
Retrieves a cached resource or creates a new one.
The factory must be invocable without arguments and return a std::shared_ptr<const T>.
If the factory returns nullptr, no resource is cached.
- Parameters
-
| path | Filesystem path identifying the resource. |
| factory | Callable used to create the resource when necessary. |
- Returns
- The cached or newly created resource, or nullptr on failure.
◆ m_entries
The documentation for this class was generated from the following file: