Skip to content

Engine → Assets → asset_importer.h

importer_registry

Syntax

class CONJURE_API importer_registry

Constructors

AccessSignatureDescription
publicimporter_registry();

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~importer_registry();

Variables

AccessNameTypeDefaultDescription
privatemImportersstd::vector<std::unique_ptr<asset_importer>>{}
privatemImportsInFlightstd::atomic<u32>0
privatemViewstd::vector<const asset_importer *>{}

Functions

Public

begin_imports

void begin_imports() noexcept;

Marks the start and end of an import batch; unregister_importer is refused between them. Used by asset_database.

end_imports

void end_imports() noexcept;

find

[[nodiscard]] const asset_importer *find(
    std::string_view id) const noexcept;

find_for_extension

[[nodiscard]] const asset_importer *find_for_extension(
    std::string_view extension) const noexcept;

The importer handling an extension, matched ignoring case; the dot is optional.

find_for_path

[[nodiscard]] const asset_importer *find_for_path(
    std::string_view path) const noexcept;

The importer whose registered extension is the longest suffix of the path's file name, ignoring case, so a ".scene.json" importer wins over a ".json" one for "main.scene.json". nullptr when no extension matches. An extension registered without its dot ("json") matches the same names as the dotted spelling. A suffix never consumes the whole file name: a leading dot is part of the name (path_utils), so ".scene.json" matches ".json" and ".json" matches nothing.

importers

[[nodiscard]] std::span<const asset_importer *const> importers() const noexcept;

Every importer in registration order.

imports_in_flight

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

register_importer

[[nodiscard]] core::result<void> register_importer(
    std::unique_ptr<asset_importer> importer);

ALREADY_EXISTS when an importer with the same id is registered; INVALID_ARGUMENT for a null importer or an empty id. An extension another importer already claims is accepted with a WARN naming both: the earlier importer stays the one chosen by extension and the new one applies only to a file whose .meta names it.

unregister_importer

[[nodiscard]] core::result<void> unregister_importer(
    std::string_view id);

NOT_FOUND (core) for an unknown id; INVALID_STATE while imports are in flight.