Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::QueryInfo Class Reference
+ Inheritance diagram for gaia::ecs::QueryInfo:

Public Types

enum class  MatchArchetypeQueryRet : uint8_t { Fail , Ok , Skip }
 Query matching result.
 

Public Member Functions

void add_ref ()
 
void dec_ref ()
 
uint32_t refs () const
 
void init (World *world)
 
void reset ()
 
void compile (const EntityToArchetypeMap &entityToArchetypeMap, const ArchetypeDArray &allArchetypes)
 Compile the query terms into a form we can easily process.
 
void recompile ()
 Recompile the query.
 
void set_world_version (uint32_t version)
 
GAIA_NODISCARD uint32_t world_version () const
 
GAIA_NODISCARD bool operator== (const QueryCtx &other) const
 
GAIA_NODISCARD bool operator!= (const QueryCtx &other) const
 
void match (const EntityToArchetypeMap &entityToArchetypeMap, const ArchetypeDArray &allArchetypes, ArchetypeId archetypeLastId)
 Tries to match the query against archetypes in entityToArchetypeMap. This is necessary so we do not iterate all chunks over and over again when running queries.
 
void calculate_sort_data ()
 Calculates the sort data for the archetypes in the cache. This allows us to iterate entites in the order they are sorted across all archetypes.
 
void sort_entities ()
 
void sort_cache_groups ()
 
ArchetypeCacheData create_cache_data (Archetype *pArchetype)
 
void add_archetype_to_cache_no_grouping (Archetype *pArchetype)
 
void add_archetype_to_cache_w_grouping (Archetype *pArchetype)
 
void add_archetype_to_cache (Archetype *pArchetype)
 
bool del_archetype_from_cache (Archetype *pArchetype)
 
GAIA_NODISCARD Worldworld ()
 
GAIA_NODISCARD const Worldworld () const
 
GAIA_NODISCARD QuerySerBufferser_buffer ()
 
void ser_buffer_reset ()
 
GAIA_NODISCARD QueryCtxctx ()
 
GAIA_NODISCARD const QueryCtxctx () const
 
GAIA_NODISCARD bool has_filters () const
 
template<typename... T>
bool has_any () const
 
template<typename... T>
bool has_all () const
 
template<typename... T>
bool has_no () const
 
void remove (Archetype *pArchetype)
 Removes an archetype from cache.
 
std::span< const uint8_t > indices_mapping_view (uint32_t archetypeIdx) const
 Returns a view of indices mapping for component entities in a given archetype.
 
GAIA_NODISCARD ArchetypeDArray::iterator begin ()
 
GAIA_NODISCARD ArchetypeDArray::const_iterator begin () const
 
GAIA_NODISCARD ArchetypeDArray::const_iterator cbegin () const
 
GAIA_NODISCARD ArchetypeDArray::iterator end ()
 
GAIA_NODISCARD ArchetypeDArray::const_iterator end () const
 
GAIA_NODISCARD ArchetypeDArray::const_iterator cend () const
 
GAIA_NODISCARD std::span< const Archetype * > cache_archetype_view () const
 
GAIA_NODISCARD std::span< const ArchetypeCacheDatacache_data_view () const
 
GAIA_NODISCARD std::span< const SortData > cache_sort_view () const
 
GAIA_NODISCARD std::span< const GroupData > group_data_view () const
 
- Public Member Functions inherited from gaia::cnt::ilist_item
 ilist_item (uint32_t index, uint32_t generation)
 
 ilist_item (const ilist_item &other)
 
ilist_itemoperator= (const ilist_item &other)
 
 ilist_item (ilist_item &&other)
 
ilist_itemoperator= (ilist_item &&other)
 

Static Public Member Functions

static GAIA_NODISCARD QueryInfo create (QueryId id, QueryCtx &&ctx, const EntityToArchetypeMap &entityToArchetypeMap, const ArchetypeDArray &allArchetypes)
 
static GAIA_NODISCARD QueryInfo create (uint32_t idx, uint32_t gen, void *pCtx)
 
static GAIA_NODISCARD QueryHandle handle (const QueryInfo &info)
 

Additional Inherited Members

- Public Attributes inherited from gaia::cnt::ilist_item
uint32_t idx
 Allocated items: Index in the list. Deleted items: Index of the next deleted item in the list.
 
ItemData data
 Item data.
 

Member Function Documentation

◆ match()

void gaia::ecs::QueryInfo::match ( const EntityToArchetypeMap entityToArchetypeMap,
const ArchetypeDArray allArchetypes,
ArchetypeId  archetypeLastId 
)
inline

Tries to match the query against archetypes in entityToArchetypeMap. This is necessary so we do not iterate all chunks over and over again when running queries.

Parameters
entityToArchetypeMapMap of all archetypes
allArchetypesList of all archetypes
archetypeLastIdLast recorded archetype id
Warning
Not thread safe. No two threads can call this at the same time.

◆ remove()

void gaia::ecs::QueryInfo::remove ( Archetype pArchetype)
inline

Removes an archetype from cache.

Parameters
pArchetypeArchetype to remove

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