![]() |
Gaia-ECS v0.9.3
A simple and powerful entity component system
|
Iterator for iterating entity subsets selected by Constraints. Disabled entities always precede enabled ones in AcceptAll mode. More...
#include <chunk_iterator.h>
Inheritance diagram for gaia::ecs::Iter:Public Member Functions | |
| GAIA_NODISCARD uint16_t | size_enabled () const noexcept |
| Returns the number of enabled entities accessible via the iterator. | |
| GAIA_NODISCARD uint16_t | size_disabled () const noexcept |
| Returns the number of disabled entities accessible via the iterator. Can be read also as "the index of the first enabled entity". | |
Public Member Functions inherited from gaia::ecs::detail::ChunkIterImpl | |
| ChunkIterImpl (ChunkIterImpl &&) noexcept=default | |
| ChunkIterImpl & | operator= (ChunkIterImpl &&) noexcept=default |
| ChunkIterImpl (const ChunkIterImpl &)=delete | |
| ChunkIterImpl & | operator= (const ChunkIterImpl &)=delete |
| void | set_world (const World *pWorld) |
| GAIA_NODISCARD World * | world () |
| GAIA_NODISCARD const World * | world () const |
| void | set_archetype (const Archetype *pArchetype) |
| GAIA_NODISCARD const Archetype * | archetype () const |
| void | set_chunk (Chunk *pChunk) |
| void | set_chunk (Chunk *pChunk, uint16_t from, uint16_t to) |
| GAIA_NODISCARD const Chunk * | chunk () const |
| void | set_comp_indices (const uint8_t *pCompIndices) |
| void | set_inherited_data (InheritedTermDataView inheritedData) |
| void | set_term_ids (const Entity *pTermIds) |
| GAIA_NODISCARD const uint8_t * | comp_indices () const |
| GAIA_NODISCARD InheritedTermDataView | inherited_data () const |
| GAIA_NODISCARD const Entity * | term_ids () const |
| void | set_write_im (bool value) |
| void | set_constraints (Constraints constraints) |
| void | init_query_state (const World *pWorld, Constraints constraints, bool writeIm) |
| Initializes stable query execution state stored by the iterator. | |
| void | set_query_chunk (const Archetype *pArchetype, const uint8_t *pCompIndices, Chunk *pChunk, uint16_t from, uint16_t to) |
| Binds the iterator to the next query chunk and keeps archetype/mapping state on the iterator. | |
| GAIA_NODISCARD bool | write_im () const |
| GAIA_NODISCARD Constraints | constraints () const |
| void | clear_touched_writes () |
| GAIA_NODISCARD const Entity * | entity_snapshot () |
| GAIA_NODISCARD auto | touched_comp_indices () const |
| GAIA_NODISCARD auto | touched_terms () const |
| GAIA_NODISCARD auto | entity_rows () |
| template<typename U > | |
| GAIA_NODISCARD auto | entity_view_set (Entity termId, bool writeIm) |
| template<typename U > | |
| GAIA_NODISCARD auto | entity_soa_view_set (Entity termId, bool writeIm) |
| void | set_group_id (GroupId groupId) |
| GAIA_NODISCARD GroupId | group_id () const |
| GAIA_NODISCARD CommandBufferST & | cmd_buffer_st () const |
| GAIA_NODISCARD CommandBufferMT & | cmd_buffer_mt () const |
| GAIA_NODISCARD IterTermDesc | resolved_term_desc (uint32_t termIdx, IterTermDesc desc) const |
| void | touch_comp_idx (uint8_t compIdx) |
| void | touch_term (Entity term) |
| void | touch_term_desc (const IterTermDesc &desc) |
| template<typename T > | |
| GAIA_NODISCARD auto | view_any () const |
| Returns a read-only entity or component view that can resolve non-direct storage. This is the fallback accessor for terms that may come from outside the chunk column, such as inherited, sparse, out-of-line, or other entity-backed storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_any (uint32_t termIdx) |
| Returns a read-only entity or component view for a query-term index that can resolve non-direct storage. Use this when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage instead of a dense chunk column. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view () const |
| Returns a read-only entity or component view for the owned chunk-backed fast path. This assumes the resolved term is stored directly in the current chunk range and therefore skips all non-direct dispatch. Use view_any() when the term may resolve to inherited, sparse, out-of-line, or otherwise entity-backed storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view (uint32_t termIdx) const |
| Returns a read-only entity or component view for a query-term owned chunk-backed term. The caller is responsible for passing a term index that maps to a dense chunk column. Use view_any(termIdx) when the term may resolve to inherited, sparse, out-of-line, or other non-direct storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_any_mut () |
| Returns a mutable entity or component view that can resolve non-direct storage. This is the fallback accessor for inherited, sparse, out-of-line, or other entity-backed terms that are not guaranteed to be backed by the current chunk column. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_mut () |
| Returns a mutable entity or component view for the owned chunk-backed fast path. Updates world versioning through the underlying chunk view and skips all non-direct dispatch. Use view_any_mut() when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_mut (uint32_t termIdx) |
| Returns a mutable entity or component view for a query-term owned chunk-backed term. Updates world versioning for the selected chunk column before handing out mutable access. Use view_any_mut(termIdx) when the term may resolve to inherited, sparse, out-of-line, or other non-direct storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_any_mut (uint32_t termIdx) |
| Returns a mutable entity or component view for a query-term index that can resolve non-direct storage. Use this when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage instead of a dense chunk column. Updates world versioning for chunk-backed terms before handing out mutable access. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_any_mut () |
| Returns a mutable component view that can resolve non-direct storage. This is the fallback accessor for inherited, sparse, out-of-line, or other entity-backed terms that are not guaranteed to be backed by the current chunk column. Doesn't update the world version when the access is acquired. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_mut () |
| Returns a mutable component view for the owned chunk-backed fast path. Doesn't update the world version when the access is acquired and skips all non-direct dispatch. Use sview_any_mut() when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_mut (uint32_t termIdx) |
| Returns a mutable component view for a query-term owned chunk-backed term. Doesn't update the world version when the access is acquired. Use sview_any_mut(termIdx) when the term may resolve to inherited, sparse, out-of-line, or other non-direct storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_any_mut (uint32_t termIdx) |
| Returns a mutable component view for a query-term index that can resolve non-direct storage. Use this when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage instead of a dense chunk column. Doesn't update the world version when the access is acquired. | |
| template<typename T , bool TriggerHooks> | |
| void | modify () |
| Marks the component T as modified. Best used with sview to manually trigger an update at user's whim. If. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_auto () |
| Returns either a mutable or immutable entity/component view for the owned chunk-backed fast path. Value and const types are treated as immutable. Mutable references select the mutable path. Use view_auto_any() when the term may resolve to inherited, sparse, out-of-line, or other non-direct storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | view_auto_any () |
| Returns either a mutable or immutable entity/component view that can resolve non-direct storage. Value and const types are considered immutable. Anything else is mutable. Use this when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_auto_any () |
| Returns either a mutable or immutable entity/component view that can resolve non-direct storage. Value and const types are considered immutable. Anything else is mutable. Use this when the term may resolve to inherited, sparse, out-of-line, or other entity-backed storage. Doesn't update the world version when read-write access is acquired. | |
| template<typename T > | |
| GAIA_NODISCARD auto | sview_auto () |
| Returns either a mutable or immutable entity/component view for the owned chunk-backed fast path. Value and const types are treated as immutable. Mutable references select the mutable path. Doesn't update the world version when read-write access is acquired. Use sview_auto_any() when the term may resolve to inherited, sparse, out-of-line, or other non-direct storage. | |
| GAIA_NODISCARD bool | enabled (uint32_t index) const |
| Checks if the entity at the current iterator index is enabled. | |
| GAIA_NODISCARD bool | has (Entity entity) const |
| Checks if entity entity is present in the chunk. | |
| GAIA_NODISCARD bool | has (Pair pair) const |
| Checks if relationship pair pair is present in the chunk. | |
| template<typename T > | |
| GAIA_NODISCARD bool | has () const |
| Checks if component T is present in the chunk. | |
| GAIA_NODISCARD uint16_t | size () const noexcept |
| Returns the number of entities accessible via the iterator. | |
| GAIA_NODISCARD uint16_t | row_begin () const noexcept |
| Returns the first row covered by the iterator in the current chunk. | |
| GAIA_NODISCARD uint16_t | row_end () const noexcept |
| Returns one-past-the-end row covered by the iterator in the current chunk. | |
| template<typename T > | |
| uint32_t | acc_index (uint32_t idx) const noexcept |
| Returns the absolute index that should be used to access an item in the chunk. AoS indices map directly, SoA indices need some adjustments because the view is always considered {0..ChunkCapacity} instead of {FirstEnabled..ChunkSize}. | |
| void | ctx (void *pCtx) |
| Sets the user-owned context pointer visible through ctx(). | |
| GAIA_NODISCARD void * | ctx () const |
| Returns the user-owned context pointer supplied by the caller driving this iteration. | |
Static Public Member Functions | |
| static GAIA_NODISCARD uint16_t | start_index (Chunk *pChunk) noexcept |
| static GAIA_NODISCARD uint16_t | end_index (Chunk *pChunk) noexcept |
| static GAIA_NODISCARD uint16_t | size (Chunk *pChunk) noexcept |
Static Public Member Functions inherited from gaia::ecs::detail::ChunkIterImpl | |
| static GAIA_NODISCARD uint16_t | start_index (Chunk *pChunk, Constraints constraints) noexcept |
| static GAIA_NODISCARD uint16_t | end_index (Chunk *pChunk, Constraints constraints) noexcept |
| static GAIA_NODISCARD uint16_t | size (Chunk *pChunk, Constraints constraints) noexcept |
Static Public Attributes | |
| static constexpr Constraints | ConstraintMode = Constraints::EnabledOnly |
Additional Inherited Members | |
Protected Types inherited from gaia::ecs::detail::ChunkIterImpl | |
| using | CompIndicesBitView = core::bit_view< ChunkHeader::MAX_COMPONENTS_BITS > |
Protected Member Functions inherited from gaia::ecs::detail::ChunkIterImpl | |
| GAIA_NODISCARD uint16_t | from () const noexcept |
| Returns the starting index of the iterator. | |
| GAIA_NODISCARD uint16_t | to () const noexcept |
| Returns the ending index of the iterator (one past the last valid index) | |
Protected Attributes inherited from gaia::ecs::detail::ChunkIterImpl | |
| const World * | m_pWorld = nullptr |
| World pointer. | |
| const Archetype * | m_pArchetype = nullptr |
| Currently iterated archetype. | |
| Chunk * | m_pChunk = nullptr |
| Chunk currently associated with the iterator. | |
| const uint8_t * | m_pCompIndices = nullptr |
| ChunkHeader::MAX_COMPONENTS values for component indices mapping for the parent archetype. | |
| InheritedTermDataView | m_inheritedData |
| Optional inherited term data view for exact semantic self-source terms. | |
| const Entity * | m_pTermIdMapping = nullptr |
| Optional per-term ids used by one-row direct iterators when a term resolves semantically. | |
| bool | m_writeIm = true |
| Whether mutable access should finish writes immediately or defer them until the callback returns. | |
| Constraints | m_constraints = Constraints::EnabledOnly |
| Which entity subset the iterator currently exposes from the chunk. | |
| uint8_t | m_touchedCompIndices [ChunkHeader::MAX_COMPONENTS] {} |
| Chunk-backed columns that were exposed as mutable during the current callback. | |
| uint8_t | m_touchedCompCnt = 0 |
| Entity | m_touchedTerms [ChunkHeader::MAX_COMPONENTS] {} |
| Entity-backed terms that were exposed as mutable during the current callback. | |
| uint8_t | m_touchedTermCnt = 0 |
| Entity | m_entitySnapshot [ChunkHeader::MAX_CHUNK_ENTITIES] {} |
| Stable copy of the currently iterated entity rows for mutable entity-backed views. | |
| bool | m_entitySnapshotValid = false |
| uint16_t | m_from |
| Row of the first entity we iterate from. | |
| uint16_t | m_to |
| Row of the last entity we iterate to. | |
| GroupId | m_groupId = 0 |
| GroupId. 0 if not set. | |
| void * | m_pCtx = nullptr |
| User-owned pointer supplied by the caller driving this iteration. | |
Iterator for iterating entity subsets selected by Constraints. Disabled entities always precede enabled ones in AcceptAll mode.