|
Unravel Engine C++ Reference
|
Manages storage and loading of assets of a specific type. More...
#include <asset_storage.h>
Public Types | |
| using | request_container_t = std::unordered_map<std::string, asset_handle<T>> |
| Container for asset requests. | |
| template<typename F > | |
| using | callable = std::function<F> |
| Type alias for callable functions. | |
| using | load_from_file_t = callable<bool(tpp::thread_pool& pool, asset_handle<T>&, const std::string&, load_mode)> |
| Function type for loading from file. | |
| using | predicate_t = callable<bool(const asset_handle<T>&)> |
| Function type for loading from instance. Predicate function type. | |
| using | load_from_instance_t = callable<bool(tpp::thread_pool& pool, asset_handle<T>&, std::shared_ptr<T>)> |
Public Member Functions | |
| ~asset_storage () override=default | |
| void | unload_handle (tpp::thread_pool &pool, asset_handle< T > &handle) |
| Unloads a handle. | |
| void | unload_with_condition (tpp::thread_pool &pool, const predicate_t &predicate) |
| Unloads assets that satisfy a condition. | |
| void | unload_all (tpp::thread_pool &pool) final |
| Unloads all assets. | |
| void | unload_group (tpp::thread_pool &pool, const std::string &group) final |
| Unloads all assets in a specified group. | |
| void | unload_single (tpp::thread_pool &pool, const std::string &key) final |
| Unloads a single asset by its key. | |
| auto | get_with_condition (const predicate_t &predicate) const -> std::vector< asset_handle< T > > |
| Gets assets that satisfy a condition. | |
| auto | get_group (const std::string &group) const -> std::vector< asset_handle< T > > |
| Gets all assets in a specified group. | |
| void | evict_unused (tpp::thread_pool &pool, const std::string &group, std::chrono::steady_clock::duration max_idle) final |
| Evicts loaded assets not accessed within the given duration. Assets whose weak_ptr has expired (no external references) and that have been idle longer than max_idle are demoted back to deferred state. | |
| void | preload_all () final |
| Triggers loading on all deferred handles in this storage. Non-blocking: starts background loads but does not wait. | |
Public Member Functions inherited from unravel::basic_storage | |
| virtual | ~basic_storage ()=default |
Public Attributes | |
| load_from_file_t | load_from_file |
| Function for loading assets from file. | |
| load_from_instance_t | load_from_instance |
| Function for loading assets from instance. | |
| request_container_t | container |
| Container for asset requests. | |
| std::recursive_mutex | container_mutex |
| Mutex for container operations. | |
Manages storage and loading of assets of a specific type.
| T | The type of the assets. |
Definition at line 472 of file asset_storage.h.
| using unravel::asset_storage< T >::callable = std::function<F> |
Type alias for callable functions.
Definition at line 478 of file asset_storage.h.
| using unravel::asset_storage< T >::load_from_file_t = callable<bool(tpp::thread_pool& pool, asset_handle<T>&, const std::string&, load_mode)> |
Function type for loading from file.
Definition at line 481 of file asset_storage.h.
| using unravel::asset_storage< T >::load_from_instance_t = callable<bool(tpp::thread_pool& pool, asset_handle<T>&, std::shared_ptr<T>)> |
Definition at line 485 of file asset_storage.h.
| using unravel::asset_storage< T >::predicate_t = callable<bool(const asset_handle<T>&)> |
Function type for loading from instance. Predicate function type.
Definition at line 484 of file asset_storage.h.
| using unravel::asset_storage< T >::request_container_t = std::unordered_map<std::string, asset_handle<T>> |
Container for asset requests.
Definition at line 475 of file asset_storage.h.
|
overridedefault |
|
inlinefinalvirtual |
Evicts loaded assets not accessed within the given duration. Assets whose weak_ptr has expired (no external references) and that have been idle longer than max_idle are demoted back to deferred state.
| pool | The thread pool. |
| max_idle | Maximum idle duration before eviction. |
Implements unravel::basic_storage.
Definition at line 613 of file asset_storage.h.
|
inline |
Gets all assets in a specified group.
| group | The group to get assets from. |
Definition at line 595 of file asset_storage.h.
|
inline |
Gets assets that satisfy a condition.
| predicate | The predicate function to determine which assets to get. |
Definition at line 572 of file asset_storage.h.
|
inlinefinalvirtual |
Triggers loading on all deferred handles in this storage. Non-blocking: starts background loads but does not wait.
Implements unravel::basic_storage.
Definition at line 640 of file asset_storage.h.
|
inlinefinalvirtual |
Unloads all assets.
| pool | The thread pool for unloading tasks. |
Implements unravel::basic_storage.
Definition at line 527 of file asset_storage.h.
|
inlinefinalvirtual |
Unloads all assets in a specified group.
| pool | The thread pool for unloading tasks. |
| group | The group to unload. |
Implements unravel::basic_storage.
Definition at line 541 of file asset_storage.h.
|
inline |
Unloads a handle.
| pool | The thread pool for unloading tasks. |
| handle | The handle to unload. |
Definition at line 494 of file asset_storage.h.
|
inlinefinalvirtual |
Unloads a single asset by its key.
| pool | The thread pool for unloading tasks. |
| key | The key of the asset to unload. |
Implements unravel::basic_storage.
Definition at line 557 of file asset_storage.h.
|
inline |
Unloads assets that satisfy a condition.
| pool | The thread pool for unloading tasks. |
| predicate | The predicate function to determine which assets to unload. |
Definition at line 505 of file asset_storage.h.
| request_container_t unravel::asset_storage< T >::container |
Container for asset requests.
Definition at line 657 of file asset_storage.h.
|
mutable |
Mutex for container operations.
Definition at line 659 of file asset_storage.h.
| load_from_file_t unravel::asset_storage< T >::load_from_file |
Function for loading assets from file.
Definition at line 653 of file asset_storage.h.
| load_from_instance_t unravel::asset_storage< T >::load_from_instance |
Function for loading assets from instance.
Definition at line 655 of file asset_storage.h.