template<typename... Ts>
Query class
System argument which holds the result of a query over all entities in world which match the given arguments.
Template parameters | |
---|---|
Ts | Argument types. |
An example of a valid query is:
Query<Position&, const Velocity&, Opt<Rotation&>, Opt<const Scale&>>
This query will return all entities with a Position
and Velocity
component. Accessors to Rotation
and Scale
components are also passed but may be null if the component is not present in the entity. Whenever mutability is not needed, const
should be used.
Constructors, destructors, conversion operators
Public functions
- auto begin() -> Iterator
- Returns an iterator pointing to the first query match.
- auto end() -> Iterator
- Returns an out of bounds iterator representing the end of the query matches.
- auto pin(int target, Entity entity) -> Query
- Returns a new query equal to this one but with the given target pinned to the given entity.
-
auto at(Entity entity) -> memory::
Opt<std::tuple<Ts...>> - Accesses the match for the given entity, if there is one.
-
auto at(Entity firstEntity,
Entity secondEntity) -> memory::
Opt<std::tuple<Ts...>> - Accesses the match for the given entities, if there is one.
-
auto first() -> memory::
Opt<std::tuple<Ts...>> - Returns the first match of the query, if there's any.
- auto empty() -> bool
- Returns whether the query is empty.
Function documentation
template<typename... Ts>
Query cubos:: core:: ecs:: Query<Ts>:: pin(int target,
Entity entity)
Returns a new query equal to this one but with the given target pinned to the given entity.
Parameters | |
---|---|
target | Target index. |
entity | Entity. |
Returns | Query. |
Effectively this filters out all matches where the given target isn't the given entity.
template<typename... Ts>
memory:: Opt<std::tuple<Ts...>> cubos:: core:: ecs:: Query<Ts>:: at(Entity entity)
Accesses the match for the given entity, if there is one.
Parameters | |
---|---|
entity | Entity. |
Returns | Requested components, or nothing if the entity does not match the query. |
template<typename... Ts>
memory:: Opt<std::tuple<Ts...>> cubos:: core:: ecs:: Query<Ts>:: at(Entity firstEntity,
Entity secondEntity)
Accesses the match for the given entities, if there is one.
Parameters | |
---|---|
firstEntity | Entity for the first target. |
secondEntity | Entity for the second target. |
Returns | Requested data, or nothing if the entities do not match the query. |
template<typename... Ts>
memory:: Opt<std::tuple<Ts...>> cubos:: core:: ecs:: Query<Ts>:: first()
Returns the first match of the query, if there's any.
Returns | Requested data, or nothing if there are no matches. |
---|
template<typename... Ts>
bool cubos:: core:: ecs:: Query<Ts>:: empty()
Returns whether the query is empty.
Returns | True if the query is empty, false otherwise. |
---|