Skip to content

Engine → ECS → component.h

component_mask

Syntax

class CONJURE_API component_mask

Constructors

AccessSignatureDescription
publicconstexpr component_mask() noexcept = default;

Variables

AccessNameTypeDefaultDescription
privatemWordsstd::array<u64, WORD_COUNT>{}
publicWORD_COUNTstatic constexpr u32MAX_COMPONENTS / 64Number of 64-bit words.

Functions

Public

clear

constexpr void clear(
    component_id id) noexcept;

Clears the bit of id. Invalid ids assert and are ignored.

contains_all

[[nodiscard]] constexpr bool contains_all(
    const component_mask &other) const noexcept;

True when every bit of other is set here.

contains_any

[[nodiscard]] constexpr bool contains_any(
    const component_mask &other) const noexcept;

True when at least one bit of other is set here.

count

[[nodiscard]] constexpr u32 count() const noexcept;

Number of set bits.

for_each_set

template <typename Callable> constexpr void for_each_set(
    Callable &&callable) const;

Invokes callable(component_id) for every set bit in ascending id order.

hash

[[nodiscard]] u64 hash() const noexcept;

FNV-1a 64 over the words; equal masks hash equal on every platform.

none

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

True when no bit is set.

set

constexpr void set(
    component_id id) noexcept;

Sets the bit of id. Invalid ids assert and are ignored.

test

[[nodiscard]] constexpr bool test(
    component_id id) const noexcept;

True when the bit of id is set; false for an invalid id.

words

[[nodiscard]] constexpr const std::array<u64, WORD_COUNT> &words() const noexcept;

The raw words, lowest ids first.

Operator Overloads

Public

operator&

[[nodiscard]] constexpr component_mask operator&(
    const component_mask &other) const noexcept;

operator&=

constexpr component_mask &operator&=(
    const component_mask &other) noexcept;

operator==

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

operator|

[[nodiscard]] constexpr component_mask operator|(
    const component_mask &other) const noexcept;

operator|=

constexpr component_mask &operator|=(
    const component_mask &other) noexcept;

operator~

[[nodiscard]] constexpr component_mask operator~() const noexcept;