Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::ComponentCache Class Referencefinal

Cache for compile-time defined components. More...

#include <component_cache.h>

Public Member Functions

 ComponentCache (ComponentCache &&)=delete
 
 ComponentCache (const ComponentCache &)=delete
 
ComponentCacheoperator= (ComponentCache &&)=delete
 
ComponentCacheoperator= (const ComponentCache &)=delete
 
template<typename T >
GAIA_NODISCARD GAIA_FORCEINLINE const ComponentCacheItemadd (Entity entity, util::str_view scopePath={})
 Registers the component item for.
 
GAIA_NODISCARD const ComponentCacheItemadd (Entity entity, const char *name, uint32_t len, uint32_t size, DataStorageType storageType, uint32_t alig=1, uint32_t soa=0, const uint8_t *pSoaSizes=nullptr, ComponentLookupHash hashLookup={}, util::str_view scopePath={})
 Registers a runtime-defined component.
 
GAIA_NODISCARD const ComponentCacheItemfind (detail::ComponentDescId compDescId) const noexcept
 Searches for the component cache item given the compDescId.
 
GAIA_NODISCARD const ComponentCacheItemget (detail::ComponentDescId compDescId) const noexcept
 Returns the component cache item given the compDescId.
 
GAIA_NODISCARD const ComponentCacheItemfind (Entity entity) const noexcept
 Searches for the component cache item.
 
GAIA_NODISCARD ComponentCacheItemfind (Entity entity) noexcept
 Searches for the component cache item.
 
GAIA_NODISCARD const ComponentCacheItemget (Entity entity) const noexcept
 Returns the component cache item.
 
GAIA_NODISCARD ComponentCacheItemget (Entity entity) noexcept
 Returns the component cache item.
 
template<typename T >
GAIA_NODISCARD const ComponentCacheItemfind () const noexcept
 Searches for the component item for.
 
template<typename T >
GAIA_NODISCARD const ComponentCacheItemget () const noexcept
 Returns the component item for.
 
void diag () const
 

Friends

class World
 

Detailed Description

Cache for compile-time defined components.

Member Function Documentation

◆ add() [1/2]

GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::add ( Entity  entity,
const char *  name,
uint32_t  len,
uint32_t  size,
DataStorageType  storageType,
uint32_t  alig = 1,
uint32_t  soa = 0,
const uint8_t *  pSoaSizes = nullptr,
ComponentLookupHash  hashLookup = {},
util::str_view  scopePath = {} 
)
inline

Registers a runtime-defined component.

Parameters
entityEntity associated with the component.
nameComponent name.
lenName length. If zero, the length is calculated.
sizeComponent size in bytes.
aligComponent alignment in bytes.
soaNumber of SoA items (0 for AoS).
dataStorageData storage type. DataStorageType::Table by default.
pSoaSizesSoA item sizes, must contain at least soa values when soa > 0.
hashLookupOptional lookup hash. If zero, hash(name) is used.
scopePathOptional world-provided scoped path prefix used when assigning the default path/alias.
Returns
Component info.

◆ add() [2/2]

template<typename T >
GAIA_NODISCARD GAIA_FORCEINLINE const ComponentCacheItem & gaia::ecs::ComponentCache::add ( Entity  entity,
util::str_view  scopePath = {} 
)
inline

Registers the component item for.

Template Parameters
T.If it already exists it is returned.
Returns
Component info

◆ find() [1/4]

template<typename T >
GAIA_NODISCARD const ComponentCacheItem * gaia::ecs::ComponentCache::find ( ) const
inlinenoexcept

Searches for the component item for.

Template Parameters
T.
Warning
It is expected the component already exists! Undefined behavior otherwise.
Returns
Component info or nullptr if not found.

◆ find() [2/4]

GAIA_NODISCARD const ComponentCacheItem * gaia::ecs::ComponentCache::find ( detail::ComponentDescId  compDescId) const
inlinenoexcept

Searches for the component cache item given the compDescId.

Parameters
compDescIdComponent descriptor id
Returns
Component info or nullptr it not found.

◆ find() [3/4]

GAIA_NODISCARD const ComponentCacheItem * gaia::ecs::ComponentCache::find ( Entity  entity) const
inlinenoexcept

Searches for the component cache item.

Parameters
entityEntity associated with the component item.
Returns
Component cache item if found, nullptr otherwise.

◆ find() [4/4]

GAIA_NODISCARD ComponentCacheItem * gaia::ecs::ComponentCache::find ( Entity  entity)
inlinenoexcept

Searches for the component cache item.

Parameters
entityEntity associated with the component item.
Returns
Component cache item if found, nullptr otherwise.

◆ get() [1/4]

template<typename T >
GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::get ( ) const
inlinenoexcept

Returns the component item for.

Template Parameters
T.
Warning
It is expected the component already exists! Undefined behavior otherwise.
Returns
Component info

◆ get() [2/4]

GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::get ( detail::ComponentDescId  compDescId) const
inlinenoexcept

Returns the component cache item given the compDescId.

Parameters
compDescIdComponent descriptor id
Returns
Component info
Warning
It is expected the component item with the given id exists! Undefined behavior otherwise.

◆ get() [3/4]

GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::get ( Entity  entity) const
inlinenoexcept

Returns the component cache item.

Parameters
entityEntity associated with the component item.
Returns
Component info.
Warning
It is expected the component item exists! Undefined behavior otherwise.

◆ get() [4/4]

GAIA_NODISCARD ComponentCacheItem & gaia::ecs::ComponentCache::get ( Entity  entity)
inlinenoexcept

Returns the component cache item.

Parameters
entityEntity associated with the component item.
Returns
Component info.
Warning
It is expected the component item exists! Undefined behavior otherwise.

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