Skip to content

Engine → ECS → view.h

view

Syntax

template <typename... ComponentTypes> class view

Constructors

AccessSignatureDescription
publicexplicit view( world &target);A view over every entity of target holding the required components of the pack.
publicview( const view &) = default;
publicview( view &&) noexcept = default;

Destructors

AccessSignatureDescription
public~view() = default;

Variables

AccessNameTypeDefaultDescription
privateMATCH_NOTHINGstatic constexpr component_mask~component_mask{}A with mask no archetype satisfies: the match set of a view over an unregistered type.
privatemIdsstd::array<component_id, PACK_SIZE>{}
privatemQueryquery—
privatemValidbooltrue
privatePACK_SIZEstatic constexpr usizesizeof...(ComponentTypes)

Functions

Public

access

[[nodiscard]] view_access access() const noexcept;

The read and write sets derived from the pack.

changed

template <typename OtherType> view &changed(
    u64 sinceVersion) &;

Visits only chunks whose column of OtherType was stamped after sinceVersion. Narrows this named view in place and returns it for chaining.

template <typename OtherType> [[nodiscard]] view changed(
    u64 sinceVersion) &&;

Visits only chunks whose column of OtherType was stamped after sinceVersion. Narrows this temporary view and returns it by value (a move), so binding the chain to a reference cannot dangle; discarding the result warns.

entity_count

[[nodiscard]] u32 entity_count();

Number of matching entities.

for_each

template <typename Callable> void for_each(
    Callable &&callable);

Invokes callable(entity, ComponentTypes&...) for every matching entity (maybe<T> as T *).

for_each_chunk

template <typename Callable> void for_each_chunk(
    Callable &&callable);

Invokes callable(chunk_view &) for every matching chunk.

is_valid

[[nodiscard]] bool is_valid() const noexcept;

False once the pack or a builder call required a type the registry does not know; such a view matches nothing.

parallel_for_each_chunk

template <typename Callable> void parallel_for_each_chunk(
    system_context &context,
    Callable &&callable);

Runs callable(chunk_view &, command_buffer &) over the matching chunks through the system's job system, one command buffer per grain (system_context::parallel_for_chunks). Defined in system.h, which callers using it must include.

underlying

[[nodiscard]] query &underlying() noexcept;

The query behind this view.

with

template <typename TagType> view &with() &;

Requires a component (typically a tag) without reading it. Narrows this named view in place and returns it for chaining.

template <typename TagType> [[nodiscard]] view with() &&;

Requires a component (typically a tag) without reading it. Narrows this temporary view and returns it by value (a move), so binding the chain to a reference cannot dangle; discarding the result warns.

without

template <typename OtherType> view &without() &;

Excludes entities holding a component. Narrows this named view in place and returns it for chaining.

template <typename OtherType> [[nodiscard]] view without() &&;

Excludes entities holding a component. Narrows this temporary view and returns it by value (a move), so binding the chain to a reference cannot dangle; discarding the result warns.

Private

collect_access

template <typename PackType> void collect_access(
    view_access &result,
    usize &slot) const noexcept;

exclude

template <typename OtherType> void exclude();

fill_slot

template <typename PackType> void fill_slot(
    const component_registry &registry,
    query_desc &desc,
    usize &slot);

filter_changed

template <typename OtherType> void filter_changed(
    u64 sinceVersion);

invoke_row

template <typename Callable, typename Columns, usize... Indices> static void invoke_row(
    Callable &callable,
    entity target,
    Columns &columns,
    u32 row,
    std::index_sequence<Indices...>);

require

template <typename TagType> void require();

require_unregistered

template <typename OtherType> void require_unregistered();

Operator Overloads

Public

operator=

view &operator=(
    const view &) = default;
view &operator=(
    view &&) noexcept = default;