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 ecs::ComponentDesc &desc, util::str_view scopePath={})
 Registers a runtime-defined component.
 
GAIA_NODISCARD const ComponentCacheItemadd (Entity entity, const ComponentCacheItem::ComponentCacheItemCtx &item, util::str_view scopePath={})
 Registers a runtime-defined component.
 
GAIA_NODISCARD bool add_field (Entity component, const RuntimeFieldDesc &field)
 Adds runtime field metadata to a registered component.
 
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/3]

GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::add ( Entity  entity,
const ComponentCacheItem::ComponentCacheItemCtx item,
util::str_view  scopePath = {} 
)
inline

Registers a runtime-defined component.

Parameters
entityComponent entity to bind the cache record to.
itemComponent item registration context.
scopePathOptional scoped path prefix used to derive the default component path.
Returns
Component info.

◆ add() [2/3]

GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::ComponentCache::add ( Entity  entity,
const ecs::ComponentDesc desc,
util::str_view  scopePath = {} 
)
inline

Registers a runtime-defined component.

Parameters
entityComponent entity to bind the cache record to.
descPlain component registration descriptor.
scopePathOptional scoped path prefix used to derive the default component path.
Returns
Component info.

◆ add() [3/3]

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

◆ add_field()

GAIA_NODISCARD bool gaia::ecs::ComponentCache::add_field ( Entity  component,
const RuntimeFieldDesc field 
)
inline

Adds runtime field metadata to a registered component.

Parameters
componentComponent entity receiving the field.
fieldField descriptor. A count of 0 means scalar. Returns true when the field was added or updated, false if validation failed.

◆ find() [1/3]

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/3]

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() [3/3]

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/3]

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/3]

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() [3/3]

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: