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

Public Types

enum class  ChangeKind : uint8_t { Structural , DynamicResult , All }
 

Public Member Functions

 QueryCache (QueryCache &&)=delete
 
 QueryCache (const QueryCache &)=delete
 
QueryCacheoperator= (QueryCache &&)=delete
 
QueryCacheoperator= (const QueryCache &)=delete
 
GAIA_NODISCARD bool valid (QueryHandle handle) const
 
void clear ()
 
void clear_archetype_tracking ()
 Clears only the reverse indices that keep raw archetype pointers alive. Used during world shutdown before archetypes begin running chunk/component dtors.
 
QueryInfotry_get (QueryHandle handle)
 Returns a QueryInfo object associated with handle.
 
QueryInfoget (QueryHandle handle)
 Returns a QueryInfo object associated with handle.
 
QueryInfoadd (QueryCtx &&ctx, const EntityToArchetypeMap &entityToArchetypeMap, std::span< const Archetype * > allArchetypes)
 Registers the provided query lookup context ctx. If it already exists it is returned.
 
QueryInfoadd_local (QueryCtx &&ctx, const EntityToArchetypeMap &entityToArchetypeMap, std::span< const Archetype * > allArchetypes)
 Registers a cached query without deduplicating against the shared lookup map.
 
bool del (QueryHandle handle)
 Deletes an existing QueryInfo object given the provided query handle.
 
auto begin ()
 
auto end ()
 
void invalidate_queries_for_entity (EntityLookupKey entityKey, ChangeKind changeKind)
 Invalidates all cached queries that work with the given entity This covers the following kinds of query terms: 1) X 2) (*, X) 3) (X, *)
 
void invalidate_queries_for_rel (Entity relation, ChangeKind changeKind)
 
void invalidate_sorted_queries_for_entity (Entity entity)
 
void invalidate_sorted_queries ()
 Invalidates all cached sorted queries after chunk row order changes.
 
void sync_archetype_cache (QueryInfo &queryInfo)
 
void remove_archetype_from_queries (Archetype *pArchetype)
 
void register_archetype_with_queries (const Archetype *pArchetype)
 

Member Function Documentation

◆ add()

QueryInfo & gaia::ecs::QueryCache::add ( QueryCtx &&  ctx,
const EntityToArchetypeMap entityToArchetypeMap,
std::span< const Archetype * >  allArchetypes 
)
inline

Registers the provided query lookup context ctx. If it already exists it is returned.

Parameters
ctxQuery context
entityToArchetypeMapMap of all archetypes
allArchetypesArray of all archetypes
Returns
Reference to the newly created or an already existing QueryInfo object.

◆ del()

bool gaia::ecs::QueryCache::del ( QueryHandle  handle)
inline

Deletes an existing QueryInfo object given the provided query handle.

Parameters
handleQuery handle
Returns
True if handle was found. False otherwise.

◆ get()

QueryInfo & gaia::ecs::QueryCache::get ( QueryHandle  handle)
inline

Returns a QueryInfo object associated with handle.

Parameters
handleQuery handle
Returns
Query info

◆ invalidate_queries_for_entity()

void gaia::ecs::QueryCache::invalidate_queries_for_entity ( EntityLookupKey  entityKey,
ChangeKind  changeKind 
)
inline

Invalidates all cached queries that work with the given entity This covers the following kinds of query terms: 1) X 2) (*, X) 3) (X, *)

Parameters
entityKeyEntity lookup key

◆ try_get()

QueryInfo * gaia::ecs::QueryCache::try_get ( QueryHandle  handle)
inline

Returns a QueryInfo object associated with handle.

Parameters
handleQuery handle
Returns
Query info

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