Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::ComponentGetter Struct Reference

Entity-scoped component accessor bound to a specific world, chunk and row. It is not a standalone chunk view and expects the referenced entity to remain valid. More...

#include <component_getter.h>

+ Inheritance diagram for gaia::ecs::ComponentGetter:

Public Member Functions

 ComponentGetter (const World &world, const Chunk *pChunk, Entity entity, uint16_t row)
 Creates an accessor for one entity row.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get () const
 Returns the value stored in the component T on entity.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get (Entity type) const
 Returns the value stored in the component associated with type on entity.
 
GAIA_NODISCARD ComponentRawView get_raw (Entity component) const
 Returns a raw byte view for a runtime component on this entity.
 
GAIA_NODISCARD ComponentRawView get_raw_field (Entity component, uint32_t fieldIdx) const
 Returns one read-only SoA field value for a runtime component on this entity.
 

Public Attributes

const Worldm_pWorld
 World used to resolve inherited and sparse component data.
 
const Chunkm_pChunk
 Chunk containing the entity's table-backed data.
 
Entity m_entity
 Entity whose components are accessed.
 
uint16_t m_row
 Entity row within the chunk.
 

Detailed Description

Entity-scoped component accessor bound to a specific world, chunk and row. It is not a standalone chunk view and expects the referenced entity to remain valid.

Constructor & Destructor Documentation

◆ ComponentGetter()

gaia::ecs::ComponentGetter::ComponentGetter ( const World world,
const Chunk pChunk,
Entity  entity,
uint16_t  row 
)
inline

Creates an accessor for one entity row.

Parameters
worldWorld that owns the entity.
pChunkChunk containing the entity row.
entityEntity being accessed.
rowEntity row within pChunk.

Member Function Documentation

◆ get() [1/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::ComponentGetter::get ( ) const
inline

Returns the value stored in the component T on entity.

Template Parameters
TComponent
Returns
Value stored in the component.

◆ get() [2/2]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::ComponentGetter::get ( Entity  type) const

Returns the value stored in the component associated with type on entity.

Template Parameters
TComponent
Parameters
typeEntity associated with the component type
Returns
Value stored in the selected component.

◆ get_raw()

ComponentRawView gaia::ecs::ComponentGetter::get_raw ( Entity  component) const
inline

Returns a raw byte view for a runtime component on this entity.

Parameters
componentRuntime component entity.
Returns
Raw payload view, or an invalid view when unavailable.

◆ get_raw_field()

ComponentRawView gaia::ecs::ComponentGetter::get_raw_field ( Entity  component,
uint32_t  fieldIdx 
) const
inline

Returns one read-only SoA field value for a runtime component on this entity.

Parameters
componentRuntime component entity.
fieldIdxSoA field array index.
Returns
Raw field value view, or an invalid view when unavailable.

The documentation for this struct was generated from the following files: