Skip to content

Engine → Scripting → script_component.h

script_store

Syntax

class CONJURE_API script_store

Constructors

AccessSignatureDescription
publicscript_store();
publicscript_store( script_store &&) noexcept = default;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~script_store();

Variables

AccessNameTypeDefaultDescription
publicGENERATION_MASKstatic constexpr u320xFFFu
publicINDEX_BITSstatic constexpr u3220
publicMAX_SETSstatic constexpr u321u << INDEX_BITS
privatemFreeListstd::vector<u32>{}
privatemLiveCountusize0
privatemMappedCountusize0
privatemSlotsstd::vector<set_slot>{}
privatemSlotToEntrystd::vector<script_entry_id>{}

Functions

Public

add_entry

[[nodiscard]] script_entry_id add_entry(
    u32 handle,
    script_entry entry);

Appends an entry; an invalid id when the set is unknown or holds MAX_SCRIPTS_PER_ENTITY.

clear

void clear();

Frees every set and clears the reverse map.

clone_set

[[nodiscard]] u32 clone_set(
    u32 handle,
    ecs::entity owner = {});

Deep-copies a set into a new one: same class hashes and JSON, no managed slots, flags reset to CLASS_MISSING where it was set. INVALID_SET_HANDLE for an invalid source.

contains

[[nodiscard]] bool contains(
    u32 handle) const noexcept;

create_set

[[nodiscard]] u32 create_set(
    ecs::entity owner);

Creates an empty set and returns its handle; INVALID_SET_HANDLE (and an assert) when MAX_SETS sets are live.

find

[[nodiscard]] script_set *find(
    u32 handle) noexcept;
[[nodiscard]] const script_set *find(
    u32 handle) const noexcept;

find_entry

[[nodiscard]] script_entry *find_entry(
    script_entry_id id) noexcept;
[[nodiscard]] const script_entry *find_entry(
    script_entry_id id) const noexcept;

for_each_set

void for_each_set(
    const std::function<void(u32, script_set &)> &callable);

Invokes callable(u32 handle, script_set &) for every live set.

free_set

bool free_set(
    u32 handle);

Frees a set and unmaps its live slots. False for a null, stale or unknown handle.

handle_generation

[[nodiscard]] static constexpr u32 handle_generation(
    u32 handle) noexcept;

handle_index

[[nodiscard]] static constexpr u32 handle_index(
    u32 handle) noexcept;

make_handle

[[nodiscard]] static constexpr u32 make_handle(
    u32 index,
    u32 generation) noexcept;

Handle arithmetic.

map_slot

void map_slot(
    i32 slot,
    script_entry_id id);

Binds a managed slot to an entry (and writes the entry's managedSlot).

mapped_slot_count

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

Number of mapped slots: a counter the mapping functions keep, so stats() costs nothing.

remove_entry

bool remove_entry(
    script_entry_id id);

Removes an entry (later entries shift down; the reverse map follows). False when unknown.

resolve_slot

[[nodiscard]] std::optional<script_entry_id> resolve_slot(
    i32 slot) const noexcept;

The entry a managed slot belongs to, or nullopt.

size

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

Live sets.

unmap_slot

void unmap_slot(
    i32 slot);

Clears the mapping of a slot (and the entry's managedSlot when it still points at the slot).

Private

live_slot

[[nodiscard]] set_slot *live_slot(
    u32 handle) noexcept;
[[nodiscard]] const set_slot *live_slot(
    u32 handle) const noexcept;

Operator Overloads

Public

operator=

script_store &operator=(
    script_store &&) noexcept = default;