Skip to content

Engine → Assets → asset_type_registry.h

asset_type_registry

Syntax

class CONJURE_API asset_type_registry

Constructors

AccessSignatureDescription
publicasset_type_registry();

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~asset_type_registry();

Variables

AccessNameTypeDefaultDescription
privatemHooksasset_type_registry_hooks{}
privatemIndexByIdcore::flat_hash_map<asset_type_id, usize>{}
privatemTypesstd::vector<std::unique_ptr<asset_type_desc>>{}
privatemViewstd::vector<const asset_type_desc *>{}

Functions

Public

find

[[nodiscard]] const asset_type_desc *find(
    asset_type_id id) const noexcept;
[[nodiscard]] const asset_type_desc *find(
    std::string_view name) const noexcept;

find_loader

[[nodiscard]] const asset_loader *find_loader(
    asset_type_id id) const noexcept;

register_type

[[nodiscard]] core::result<void> register_type(
    asset_type_desc desc);

Main thread, before systems run. Fails with TYPE_DUPLICATE if the id is taken, with INVALID_ARGUMENT for an INVALID id, a name whose hash is not the id, or a missing loader whose type differs from the id, and with OUT_OF_RANGE past MAX_ASSET_TYPES.

set_hooks

void set_hooks(
    asset_type_registry_hooks hooks);

Installs the manager's callbacks. Engine plumbing, not for general use.

size

[[nodiscard]] usize size() const noexcept;

types

[[nodiscard]] std::span<const asset_type_desc *const> types() const noexcept;

Every registered type in registration order. The span is valid until the next registration or removal; the descriptions it points at follow the find() rule.

unregister_type

[[nodiscard]] core::result<void> unregister_type(
    asset_type_id id);

Plugin unload. TYPE_UNKNOWN for an unregistered id; INVALID_STATE while any slot of the type is loaded or in flight. Only pointers to the removed description die.

Private

rebuild_index

void rebuild_index();