Basic cache for resources of any type. More...
#include <cache.hpp>
Public Types | |
using | allocator_type = Allocator |
Allocator type. | |
using | value_type = Type |
Resource type. | |
using | size_type = std::size_t |
Unsigned integer type. | |
using | loader_type = Loader |
Loader type. | |
using | iterator = internal::resource_cache_iterator<Type, typename container_type::iterator> |
Input iterator type. | |
using | const_iterator = internal::resource_cache_iterator<const Type, typename container_type::const_iterator> |
Constant input iterator type. | |
Public Member Functions | |
resource_cache () | |
Default constructor. | |
resource_cache (const allocator_type &allocator) | |
Constructs an empty cache with a given allocator. | |
resource_cache (const loader_type &callable, const allocator_type &allocator=allocator_type{}) | |
Constructs an empty cache with a given allocator and loader. | |
resource_cache (const resource_cache &)=default | |
Default copy constructor. | |
resource_cache (const resource_cache &other, const allocator_type &allocator) | |
Allocator-extended copy constructor. | |
resource_cache (resource_cache &&) noexcept=default | |
Default move constructor. | |
resource_cache (resource_cache &&other, const allocator_type &allocator) | |
Allocator-extended move constructor. | |
~resource_cache ()=default | |
Default destructor. | |
resource_cache & | operator= (const resource_cache &)=default |
Default copy assignment operator. | |
resource_cache & | operator= (resource_cache &&) noexcept=default |
Default move assignment operator. | |
constexpr allocator_type | get_allocator () const noexcept |
Returns the associated allocator. | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the beginning. | |
const_iterator | begin () const noexcept |
Returns an iterator to the beginning. | |
iterator | begin () noexcept |
Returns an iterator to the beginning. | |
const_iterator | cend () const noexcept |
Returns an iterator to the end. | |
const_iterator | end () const noexcept |
Returns an iterator to the end. | |
iterator | end () noexcept |
Returns an iterator to the end. | |
bool | empty () const noexcept |
Returns true if a cache contains no resources, false otherwise. | |
size_type | size () const noexcept |
Number of resources managed by a cache. | |
void | clear () noexcept |
Clears a cache. | |
template<typename... Args> | |
std::pair< iterator, bool > | load (const id_type id, Args &&...args) |
Loads a resource, if its identifier does not exist. | |
template<typename... Args> | |
std::pair< iterator, bool > | force_load (const id_type id, Args &&...args) |
Force loads a resource, if its identifier does not exist. | |
resource< const value_type > | operator[] (const id_type id) const |
Returns a handle for a given resource identifier. | |
resource< value_type > | operator[] (const id_type id) |
Returns a handle for a given resource identifier. | |
bool | contains (const id_type id) const |
Checks if a cache contains a given identifier. | |
iterator | erase (const_iterator pos) |
Removes an element from a given position. | |
iterator | erase (const_iterator first, const_iterator last) |
Removes the given elements from a cache. | |
size_type | erase (const id_type id) |
Removes the given elements from a cache. | |
loader_type | loader () const |
Returns the loader used to create resources. | |
Basic cache for resources of any type.
Type | Type of resources managed by a cache. |
Loader | Type of loader used to create the resources. |
Allocator | Type of allocator used to manage memory and elements. |
using entt::resource_cache< Type, Loader, Allocator >::allocator_type = Allocator |
using entt::resource_cache< Type, Loader, Allocator >::const_iterator = internal::resource_cache_iterator<const Type, typename container_type::const_iterator> |
using entt::resource_cache< Type, Loader, Allocator >::iterator = internal::resource_cache_iterator<Type, typename container_type::iterator> |
using entt::resource_cache< Type, Loader, Allocator >::loader_type = Loader |
using entt::resource_cache< Type, Loader, Allocator >::size_type = std::size_t |
using entt::resource_cache< Type, Loader, Allocator >::value_type = Type |
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inline |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenoexcept |
|
inlinenodiscard |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
|
inline |
|
inline |
|
inline |
|
inline |
Force loads a resource, if its identifier does not exist.
Arguments are forwarded directly to the loader and consumed only if the resource doesn't already exist.
Args | Types of arguments to use to load the resource if required. |
id | Unique resource identifier. |
args | Arguments to use to load the resource if required. |
|
inlinenodiscardconstexprnoexcept |
|
inline |
Loads a resource, if its identifier does not exist.
Arguments are forwarded directly to the loader and consumed only if the resource doesn't already exist.
Args | Types of arguments to use to load the resource if required. |
id | Unique resource identifier. |
args | Arguments to use to load the resource if required. |
|
inlinenodiscard |
|
default |
Default copy assignment operator.
|
defaultnoexcept |
Default move assignment operator.
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscardnoexcept |