Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::CopyIter Class Referencefinal

Iterator used when copying entities. More...

#include <chunk_iterator.h>

Public Member Functions

 CopyIter (CopyIter &&) noexcept=default
 
CopyIteroperator= (CopyIter &&) noexcept=default
 
CopyIteroperator= (const CopyIter &)=delete
 
void set_range (uint16_t from, uint16_t cnt)
 Sets the iterator's range.
 
void set_world (const World *pWorld)
 Associates the iterator with its owning world.
 
GAIA_NODISCARD Worldworld ()
 Returns mutable access to the associated world.
 
GAIA_NODISCARD const Worldworld () const
 Returns read-only access to the associated world.
 
void set_archetype (const Archetype *pArchetype)
 Associates the iterator with the source archetype.
 
GAIA_NODISCARD const Archetypearchetype () const
 Returns the associated source archetype.
 
void set_chunk (Chunk *pChunk)
 Associates the iterator with a source chunk.
 
GAIA_NODISCARD const Chunkchunk () const
 Returns the associated source chunk.
 
GAIA_NODISCARD CommandBufferSTcmd_buffer_st () const
 Returns the world's single-threaded command buffer.
 
GAIA_NODISCARD CommandBufferMTcmd_buffer_mt () const
 Returns the world's multi-threaded command buffer.
 
template<typename T >
GAIA_NODISCARD auto view () const
 Returns a read-only entity or component view.
 
template<typename T >
GAIA_NODISCARD auto view_mut ()
 Returns a mutable entity or component view.
 
template<typename T >
GAIA_NODISCARD auto sview_mut ()
 Returns a mutable component view. 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 TriggerHooks is true, also triggers the component's set hooks.
 
template<typename T >
GAIA_NODISCARD auto view_auto ()
 Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable.
 
template<typename T >
GAIA_NODISCARD auto sview_auto ()
 Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable. Doesn't update the world version when read-write access is acquired.
 
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.
 

Protected Types

using CompIndicesBitView = core::bit_view< ChunkHeader::MAX_COMPONENTS_BITS >
 Bit view used to track component columns selected for copying.
 

Protected Attributes

const Worldm_pWorld = nullptr
 World pointer.
 
const Archetypem_pArchetype = nullptr
 Currently iterated archetype.
 
Chunkm_pChunk = nullptr
 Chunk currently associated with the iterator.
 
uint16_t m_from
 Row of the first entity we iterate from.
 
uint16_t m_cnt
 The number of entities accessible via the iterator.
 

Detailed Description

Iterator used when copying entities.

Member Function Documentation

◆ archetype()

GAIA_NODISCARD const Archetype * gaia::ecs::CopyIter::archetype ( ) const
inline

Returns the associated source archetype.

Returns
Source archetype.

◆ chunk()

GAIA_NODISCARD const Chunk * gaia::ecs::CopyIter::chunk ( ) const
inline

Returns the associated source chunk.

Returns
Source chunk.

◆ cmd_buffer_mt()

GAIA_NODISCARD CommandBufferMT & gaia::ecs::CopyIter::cmd_buffer_mt ( ) const
inline

Returns the world's multi-threaded command buffer.

Returns
Multi-threaded command buffer associated with the world.

◆ cmd_buffer_st()

GAIA_NODISCARD CommandBufferST & gaia::ecs::CopyIter::cmd_buffer_st ( ) const
inline

Returns the world's single-threaded command buffer.

Returns
Single-threaded command buffer associated with the world.

◆ enabled()

GAIA_NODISCARD bool gaia::ecs::CopyIter::enabled ( uint32_t  index) const
inline

Checks if the entity at the current iterator index is enabled.

Parameters
indexIterator-relative entity index.
Returns
True it the entity is enabled. False otherwise.

◆ has() [1/3]

template<typename T >
GAIA_NODISCARD bool gaia::ecs::CopyIter::has ( ) const
inline

Checks if component T is present in the chunk.

Template Parameters
TComponent
Returns
True if the component is present. False otherwise.

◆ has() [2/3]

GAIA_NODISCARD bool gaia::ecs::CopyIter::has ( Entity  entity) const
inline

Checks if entity entity is present in the chunk.

Parameters
entityEntity
Returns
True if the component is present. False otherwise.

◆ has() [3/3]

GAIA_NODISCARD bool gaia::ecs::CopyIter::has ( Pair  pair) const
inline

Checks if relationship pair pair is present in the chunk.

Parameters
pairRelationship pair
Returns
True if the component is present. False otherwise.

◆ set_archetype()

void gaia::ecs::CopyIter::set_archetype ( const Archetype pArchetype)
inline

Associates the iterator with the source archetype.

Parameters
pArchetypeNon-null archetype being copied.

◆ set_chunk()

void gaia::ecs::CopyIter::set_chunk ( Chunk pChunk)
inline

Associates the iterator with a source chunk.

Parameters
pChunkNon-null chunk containing the copied rows.

◆ set_range()

void gaia::ecs::CopyIter::set_range ( uint16_t  from,
uint16_t  cnt 
)
inline

Sets the iterator's range.

Parameters
fromRow of the first entity we want to iterate from
cntNumber of entities we are going to iterate

◆ set_world()

void gaia::ecs::CopyIter::set_world ( const World pWorld)
inline

Associates the iterator with its owning world.

Parameters
pWorldNon-null world used for component access and command buffers.

◆ size()

GAIA_NODISCARD uint16_t gaia::ecs::CopyIter::size ( ) const
inlinenoexcept

Returns the number of entities accessible via the iterator.

Returns
Number of rows in the configured copy range.

◆ sview_auto()

template<typename T >
GAIA_NODISCARD auto gaia::ecs::CopyIter::sview_auto ( )
inline

Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable. Doesn't update the world version when read-write access is acquired.

Warning
If T is a component it is expected to be present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Returns
Entity or component view

◆ sview_mut()

template<typename T >
GAIA_NODISCARD auto gaia::ecs::CopyIter::sview_mut ( )
inline

Returns a mutable component view. Doesn't update the world version when the access is acquired.

Warning
It is expected the component T is present. Undefined behavior otherwise.
Template Parameters
TComponent
Returns
Component view with read-write access

◆ view()

template<typename T >
GAIA_NODISCARD auto gaia::ecs::CopyIter::view ( ) const
inline

Returns a read-only entity or component view.

Warning
If T is a component it is expected it is present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Returns
Entity of component view with read-only access

◆ view_auto()

template<typename T >
GAIA_NODISCARD auto gaia::ecs::CopyIter::view_auto ( )
inline

Returns either a mutable or immutable entity/component view based on the requested type. Value and const types are considered immutable. Anything else is mutable.

Warning
If T is a component it is expected to be present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Returns
Entity or component view

◆ view_mut()

template<typename T >
GAIA_NODISCARD auto gaia::ecs::CopyIter::view_mut ( )
inline

Returns a mutable entity or component view.

Warning
If T is a component it is expected it is present. Undefined behavior otherwise.
Template Parameters
TComponent or Entity
Returns
Entity or component view with read-write access

◆ world() [1/2]

GAIA_NODISCARD World * gaia::ecs::CopyIter::world ( )
inline

Returns mutable access to the associated world.

Returns
Associated world.

◆ world() [2/2]

GAIA_NODISCARD const World * gaia::ecs::CopyIter::world ( ) const
inline

Returns read-only access to the associated world.

Returns
Associated world.

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