Skip to content

Engine → Assets → asset_ref.h

asset_ref

Syntax

template <typename AssetType> class asset_ref

Constructors

AccessSignatureDescription
publicconstexpr asset_ref() noexcept = default;
publicconstexpr explicit asset_ref( const asset_id &id) noexcept;An unbound reference: carries the uuid, reads nullptr until bound by the manager.
publicconstexpr asset_ref( const asset_id &id, const asset_slot *slot) noexcept;A bound reference. The slot must belong to id.

Variables

AccessNameTypeDefaultDescription
privatemIdasset_id{}
privatemSlotconst asset_slot *nullptr

Functions

Public

get

[[nodiscard]] AssetType *get() const noexcept;

Hot path: one atomic load, no hashing, no locking. Returns nullptr unless LOADED. The pointer is valid until the end of the next frame.

id

[[nodiscard]] constexpr const asset_id &id() const noexcept;

is_bound

[[nodiscard]] constexpr bool is_bound() const noexcept;

slot

[[nodiscard]] constexpr const asset_slot *slot() const noexcept;

The bound slot, or nullptr.

state

[[nodiscard]] asset_state state() const noexcept;

UNLOADED when unbound.

version

[[nodiscard]] u32 version() const noexcept;

Publish counter of the slot; 0 when unbound. Changes on every publish and unload.

Operator Overloads

Public

operator==

[[nodiscard]] constexpr bool operator==(
    const asset_ref &other) const noexcept;

Equality is by uuid: two references to the same asset compare equal whether or not they are bound.