Class QueryRegistry¶
Defined in File queryregistry.hpp
Class Documentation¶
-
class
legion::core::ecs
::
QueryRegistry
¶ Main manager and owner of all queries and query related objects.
Public Functions
-
inline
QueryRegistry
(EcsRegistry ®istry)¶
-
inline
~QueryRegistry
()¶
-
void
addComponentType
(id_type queryId, id_type componentTypeId)¶ Add a certain component type to a query.
- Warning
Changing the components for this query id will also change it for any other references that may not want the same change. For safety first check the amount of references to this query id and only change it if there’s only 1. otherwise generate a new query.
- Warning
A query with the components you want might already exist, adding them to this query might create duplicates. For safety and efficiency first check if there isn’t another query already using getQueryId.
- Note
Changes components to query for all other queries that used to query the same components.
- Note
Not the fastest thing in the world, don’t do it with loads of components. In that case create a new query instead.
-
void
removeComponentType
(id_type queryId, id_type componentTypeId)¶ Remove a certain component type to a query.
- Warning
Changing the components for this query id will also change it for any other references that may not want the same change. For safety first check the amount of references to this query id and only change it if there’s only 1. otherwise generate a new query.
- Warning
A query with the components you want might already exist, removing others from this query might create duplicates. For safety and efficiency first check if there isn’t another query already using getQueryId.
- Note
Changes components to query for all other queries that used to query the same components.
- Note
Not the fastest thing in the world, don’t do it with loads of components. In that case create a new query instead.
-
void
evaluateEntityChange
(id_type entityId, id_type componentTypeId, bool removal)¶ Mark a change in component composition of an entity.
- Parameters
entityId
: Id of entity in question.componentTypeId
: Type id of component that was added or removed.removal
: Whether the component was added or removed.
-
void
markEntityDestruction
(id_type entityId)¶ Mark an entity destruction. (removes entity from all queries.
- Parameters
entityId
: Id of the entity in question.
-
id_type
getQueryId
(const hashed_sparse_set<id_type> &componentTypes)¶ Get query id of a query that requests a certain component combination.
- Return
id_type Id of the matching query or invalid_id if none was found.
- Parameters
componentTypes
: Sparse map containing all component type ids that would need to be queried.
-
template<typename ...
component_types
>
inline EntityQuerycreateQuery
()¶ Creates an entity query for a certain component combination.
- Note
Will not always create a new query id. If another query exists with the same component type the query handle will get the same id as that one.
- Return
EntityQuery Query handle with the id that will query the requested component types.
- Template Parameters
component_types
: Types of components that need to be queried by the new query.
-
EntityQuery
createQuery
(const hashed_sparse_set<id_type> &componentTypes)¶ Creates an entity query for a certain component combination.
- Note
Will not always create a new query id. If another query exists with the same component type the query handle will get the same id as that one.
- Return
EntityQuery Query handle with the id that will query the requested component types.
- Parameters
componentTypes
: Sparse map with type ids of components that need to be queried by the new query.
-
const hashed_sparse_set<id_type> &
getComponentTypes
(id_type queryId)¶ Gets component types a query with a certain id would query for.
- Parameters
queryId
: Id of the query to check.
-
const entity_container &
getEntities
(id_type queryId)¶ Get the ids and handles of all entities that have all components of the query.
- Return
sparse_map<id_type, entity_handle>& Sparse map with the ids as the key and the handles as the value.
- Parameters
queryId
: Id of the query to get the entities from.
-
component_container_base &
getComponents
(id_type queryId, id_type componentTypeId)¶
-
void
addReference
(id_type queryId)¶ Add to reference count of a query.
- Parameters
queryId
: Id of query to increase reference count of.
Public Static Functions
-
static inline bool
isValid
(QueryRegistry *reg)¶
-
inline