Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::ecs::ComponentMask Class Reference

Dynamic bitset for tracking which components an entity has. More...

#include <ComponentMask.hpp>

Public Member Functions

 ComponentMask ()=default
void set (u32 bit)
 Sets the given bit.
void clear (u32 bit)
 Clears the given bit.
bool test (u32 bit) const
 Tests the given bit.
void reset ()
 Clears all bits.
bool none () const
 Returns true if no bits are set.
template<typename Func>
void forEachSet (Func &&fn) const
 Iterates all set bits, calling fn(bitIndex) for each.

Static Public Attributes

static constexpr u32 INLINE_WORDS = 2
static constexpr u32 BITS_PER_WORD = 64
static constexpr u32 INLINE_BITS = INLINE_WORDS * BITS_PER_WORD

Detailed Description

Dynamic bitset for tracking which components an entity has.

The first 128 bits are stored inline as two u64 words. An overflow vector is allocated only when type IDs exceed 128.

Definition at line 41 of file ComponentMask.hpp.

Constructor & Destructor Documentation

◆ ComponentMask()

esengine::ecs::ComponentMask::ComponentMask ( )
default

Member Function Documentation

◆ clear()

void esengine::ecs::ComponentMask::clear ( u32 bit)
inline

Clears the given bit.

Definition at line 63 of file ComponentMask.hpp.

References BITS_PER_WORD, and INLINE_BITS.

◆ forEachSet()

template<typename Func>
void esengine::ecs::ComponentMask::forEachSet ( Func && fn) const
inline

Iterates all set bits, calling fn(bitIndex) for each.

Template Parameters
FuncCallable accepting u32

Definition at line 105 of file ComponentMask.hpp.

References BITS_PER_WORD, INLINE_BITS, and INLINE_WORDS.

◆ none()

bool esengine::ecs::ComponentMask::none ( ) const
inlinenodiscard

Returns true if no bits are set.

Definition at line 92 of file ComponentMask.hpp.

◆ reset()

void esengine::ecs::ComponentMask::reset ( )
inline

Clears all bits.

Definition at line 85 of file ComponentMask.hpp.

◆ set()

void esengine::ecs::ComponentMask::set ( u32 bit)
inline

Sets the given bit.

Definition at line 50 of file ComponentMask.hpp.

References BITS_PER_WORD, and INLINE_BITS.

◆ test()

bool esengine::ecs::ComponentMask::test ( u32 bit) const
inlinenodiscard

Tests the given bit.

Definition at line 75 of file ComponentMask.hpp.

References BITS_PER_WORD, and INLINE_BITS.

Member Data Documentation

◆ BITS_PER_WORD

u32 esengine::ecs::ComponentMask::BITS_PER_WORD = 64
staticconstexpr

Definition at line 44 of file ComponentMask.hpp.

Referenced by clear(), forEachSet(), set(), and test().

◆ INLINE_BITS

u32 esengine::ecs::ComponentMask::INLINE_BITS = INLINE_WORDS * BITS_PER_WORD
staticconstexpr

Definition at line 45 of file ComponentMask.hpp.

Referenced by clear(), forEachSet(), set(), and test().

◆ INLINE_WORDS

u32 esengine::ecs::ComponentMask::INLINE_WORDS = 2
staticconstexpr

Definition at line 43 of file ComponentMask.hpp.

Referenced by forEachSet().


The documentation for this class was generated from the following file: