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)
 Registers the component item for.
 
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 const ComponentCacheItemget (Entity entity) const noexcept
 Returns the component cache item.
 
GAIA_NODISCARD const ComponentCacheItemfind (const char *name, uint32_t len=0) const noexcept
 Searches for the component cache item. The provided string is NOT copied internally.
 
GAIA_NODISCARD const ComponentCacheItemget (const char *name, uint32_t len=0) const noexcept
 Returns the component cache item. The provided string is NOT copied internally.
 
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()

template<typename T >
GAIA_NODISCARD GAIA_FORCEINLINE const ComponentCacheItem & gaia::ecs::ComponentCache::add ( Entity  entity)
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 ( const char *  name,
uint32_t  len = 0 
) const
inlinenoexcept

Searches for the component cache item. The provided string is NOT copied internally.

Parameters
nameA null-terminated string.
lenString length. If zero, the length is calculated.
Returns
Component cache item if found, nullptr otherwise.

◆ find() [3/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() [4/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.

◆ 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 ( const char *  name,
uint32_t  len = 0 
) const
inlinenoexcept

Returns the component cache item. The provided string is NOT copied internally.

Parameters
nameA null-terminated string
lenString length. If zero, the length is calculated
Returns
Component info.
Warning
It is expected the component item with the given name/length exists! Undefined behavior otherwise.

◆ get() [3/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() [4/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 with the given name/length exists! Undefined behavior otherwise.

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