Unravel Engine C++ Reference
|
Manages assets, including loading, unloading, and storage. More...
#include <asset_manager.h>
Public Member Functions | |
asset_manager (rtti::context &ctx) | |
Constructs an asset manager with the given context. | |
~asset_manager () | |
Destructs the asset manager. | |
void | set_parent (asset_manager *parent) |
Sets the parent asset manager. | |
auto | init (rtti::context &ctx) -> bool |
Initializes the asset manager with the given context. | |
auto | deinit (rtti::context &ctx) -> bool |
Deinitializes the asset manager with the given context. | |
void | unload_all () |
Unloads all assets. | |
void | unload_group (const std::string &group) |
Unloads all assets in a specified group. | |
auto | load_database (const std::string &protocol) -> bool |
Loads an asset database from a protocol. | |
void | save_database (const std::string &protocol, const fs::path &path) |
Saves the asset database to a specified path. | |
void | remove_asset_info_for_path (const fs::path &path) |
Removes asset information for a specified path. | |
void | remove_asset_info_for_key (const std::string &key) |
Removes asset information for a specified key. | |
auto | add_asset_info_for_path (const fs::path &path, const asset_meta &meta, bool override) -> hpp::uuid |
Adds asset information for a specified path. | |
auto | add_asset_info_for_key (const std::string &key, const asset_meta &meta, bool override) -> hpp::uuid |
Adds asset information for a specified key. | |
auto | get_metadata (const hpp::uuid &uid) const -> asset_database::meta |
Gets metadata for a resource uid. | |
auto | generate_metadata (const fs::path &p) const -> asset_meta |
template<typename S , typename... Args> | |
auto | add_storage (Args &&... args) -> asset_storage< S > & |
Adds a storage for a specific type. | |
template<typename T > | |
auto | get_asset (const std::string &key, load_flags flags=load_flags::standard) -> asset_handle< T > |
Gets an asset by its key. | |
template<typename T > | |
auto | get_asset (const hpp::uuid &uid, load_flags flags=load_flags::standard) -> asset_handle< T > |
Gets an asset by its UUID. | |
template<typename T > | |
auto | find_asset (const std::string &key) const -> const asset_handle< T > & |
Finds an asset by its key. | |
template<typename T > | |
auto | get_asset_from_instance (const std::string &key, std::shared_ptr< T > entry) -> asset_handle< T > |
Gets an asset handle from an instance. | |
template<typename T > | |
void | rename_asset (const std::string &key, const std::string &new_key) |
Renames an asset. | |
template<typename T > | |
void | unload_asset (const std::string &key) |
Unloads an asset by its key. | |
template<typename T > | |
auto | get_assets (const std::string &group={}) const -> std::vector< asset_handle< T > > |
Gets all assets in a specified group. | |
template<typename T , typename F > | |
auto | get_assets_with_predicate (F &&predicate) const -> std::vector< asset_handle< T > > |
Gets all assets that satisfy a predicate. | |
template<typename T , typename F > | |
void | for_each_asset (F &&callback) |
Applies a callback function to each asset. | |
Manages assets, including loading, unloading, and storage.
Definition at line 18 of file asset_manager.h.
unravel::asset_manager::asset_manager | ( | rtti::context & | ctx | ) |
Constructs an asset manager with the given context.
ctx | The context for the asset manager. |
Definition at line 23 of file asset_manager.cpp.
|
default |
Destructs the asset manager.
auto unravel::asset_manager::add_asset_info_for_key | ( | const std::string & | key, |
const asset_meta & | meta, | ||
bool | override ) -> hpp::uuid |
Adds asset information for a specified key.
key | The key of the asset. |
meta | The metadata of the asset. |
Definition at line 200 of file asset_manager.cpp.
auto unravel::asset_manager::add_asset_info_for_path | ( | const fs::path & | path, |
const asset_meta & | meta, | ||
bool | override ) -> hpp::uuid |
Adds asset information for a specified path.
path | The path of the asset. |
meta | The metadata of the asset. |
Definition at line 194 of file asset_manager.cpp.
|
inline |
Adds a storage for a specific type.
S | The type of storage. |
Args | The arguments for constructing the storage. |
args | The arguments for constructing the storage. |
Definition at line 122 of file asset_manager.h.
auto unravel::asset_manager::deinit | ( | rtti::context & | ctx | ) | -> bool |
Deinitializes the asset manager with the given context.
ctx | The context to deinitialize. |
Definition at line 120 of file asset_manager.cpp.
|
inline |
Finds an asset by its key.
T | The type of the asset. |
key | The key of the asset. |
Definition at line 179 of file asset_manager.h.
|
inline |
Applies a callback function to each asset.
T | The type of the assets. |
F | The callback function. |
callback | The callback function. |
Definition at line 295 of file asset_manager.h.
auto unravel::asset_manager::generate_metadata | ( | const fs::path & | p | ) | const -> asset_meta |
Definition at line 222 of file asset_manager.cpp.
|
inline |
Gets an asset by its UUID.
T | The type of the asset. |
uid | The UUID of the asset. |
flags | The load flags for the asset. |
Definition at line 156 of file asset_manager.h.
|
inline |
Gets an asset by its key.
T | The type of the asset. |
key | The key of the asset. |
flags | The load flags for the asset. |
Definition at line 138 of file asset_manager.h.
|
inline |
Gets an asset handle from an instance.
T | The type of the asset. |
key | The key of the asset. |
entry | The shared pointer to the asset instance. |
Definition at line 193 of file asset_manager.h.
|
inline |
Gets all assets in a specified group.
T | The type of the assets. |
group | The group to get assets from. |
Definition at line 260 of file asset_manager.h.
|
inline |
Gets all assets that satisfy a predicate.
T | The type of the assets. |
F | The predicate function. |
predicate | The predicate function. |
Definition at line 282 of file asset_manager.h.
auto unravel::asset_manager::get_metadata | ( | const hpp::uuid & | uid | ) | const -> asset_database::meta |
Gets metadata for a resource uid.
uid | The the uuid of the resource. |
Definition at line 207 of file asset_manager.cpp.
auto unravel::asset_manager::init | ( | rtti::context & | ctx | ) | -> bool |
Initializes the asset manager with the given context.
ctx | The context to initialize with. |
Definition at line 34 of file asset_manager.cpp.
auto unravel::asset_manager::load_database | ( | const std::string & | protocol | ) | -> bool |
Loads an asset database from a protocol.
protocol | The protocol to load from. |
Definition at line 172 of file asset_manager.cpp.
void unravel::asset_manager::remove_asset_info_for_key | ( | const std::string & | key | ) |
Removes asset information for a specified key.
key | The key of the asset. |
Definition at line 246 of file asset_manager.cpp.
void unravel::asset_manager::remove_asset_info_for_path | ( | const fs::path & | path | ) |
Removes asset information for a specified path.
path | The path of the asset. |
Definition at line 240 of file asset_manager.cpp.
|
inline |
Renames an asset.
T | The type of the asset. |
key | The current key of the asset. |
new_key | The new key for the asset. |
Definition at line 210 of file asset_manager.h.
void unravel::asset_manager::save_database | ( | const std::string & | protocol, |
const fs::path & | path ) |
Saves the asset database to a specified path.
protocol | The protocol to use for saving. |
path | The path to save the database to. |
Definition at line 181 of file asset_manager.cpp.
void unravel::asset_manager::set_parent | ( | asset_manager * | parent | ) |
Sets the parent asset manager.
parent | The parent asset manager. |
Definition at line 29 of file asset_manager.cpp.
void unravel::asset_manager::unload_all | ( | ) |
Unloads all assets.
Definition at line 131 of file asset_manager.cpp.
|
inline |
Unloads an asset by its key.
T | The type of the asset. |
key | The key of the asset. |
Definition at line 242 of file asset_manager.h.
void unravel::asset_manager::unload_group | ( | const std::string & | group | ) |
Unloads all assets in a specified group.
group | The group to unload. |
Definition at line 145 of file asset_manager.cpp.