Unravel Engine C++ Reference
Loading...
Searching...
No Matches
asset_handle.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <engine/engine.h>
7
10
11namespace ser20
12{
13
14template<typename Archive, typename T>
15inline void SAVE_FUNCTION_NAME(Archive& ar, asset_handle<T> const& obj)
16{
17 try_save(ar, ser20::make_nvp("uid", obj.uid()));
18}
19
20template<typename Archive, typename T>
21inline void LOAD_FUNCTION_NAME(Archive& ar, asset_handle<T>& obj)
22{
23 hpp::uuid uid{};
24 try_load(ar, ser20::make_nvp("uid", uid));
25
26 if(uid.is_nil())
27 {
28 obj = {};
29 }
30 else
31 {
32 auto& ctx = unravel::engine::context();
33 auto& am = ctx.get_cached<unravel::asset_manager>();
34 obj = am.get_asset<T>(uid);
35 }
36}
37} // namespace ser20
Manages assets, including loading, unloading, and storage.
Definition yaml.hpp:46
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_FUNCTION_NAME
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define SAVE_FUNCTION_NAME
Represents a handle to an asset, providing access and management functions.
auto uid() const -> const hpp::uuid &
Gets the unique identifier of the asset.
static auto context() -> rtti::context &
Definition engine.cpp:115