template<typename... Ts>
cubos::core::ecs::QueryData class

Holds the data necessary to execute a query.

Template parameters
Ts Argument types.

The argument types of the query specify exactly what data will be accessed during iteration. For example, the query might have been constructed with properties such that a given column must be present on the entity. That doesn't mean that the data will actually end up being accessed.

If an argument type is present which requires a certain column to be present, then that column is automatically added to the query properties, if it isn't there already.

Constructors, destructors, conversion operators

QueryData(World& world, const std::vector<QueryTerm>& extraTerms)
Constructs.
QueryData(QueryData&& other) noexcept
Move constructs.

Public functions

auto accesses() const -> const std::unordered_set<DataTypeId, DataTypeIdHash>&
Gets a set with the data types accessed by this query.
void update()
Fetches any new matching archetypes that have been added since the last call to this function.
auto view() -> View
Returns a view which can be used to iterate over the matches.
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.

Function documentation

template<typename... Ts>
cubos::core::ecs::QueryData<Ts>::QueryData(World& world, const std::vector<QueryTerm>& extraTerms)

Constructs.

Parameters
world World being queried.
extraTerms Extra query terms.

template<typename... Ts>
cubos::core::ecs::QueryData<Ts>::QueryData(QueryData&& other) noexcept

Move constructs.

Parameters
other Other query data.

template<typename... Ts>
const std::unordered_set<DataTypeId, DataTypeIdHash>& cubos::core::ecs::QueryData<Ts>::accesses() const

Gets a set with the data types accessed by this query.

Returns Data type set.

template<typename... Ts>
View cubos::core::ecs::QueryData<Ts>::view()

Returns a view which can be used to iterate over the matches.

Returns View.

template<typename... Ts>
memory::Opt<std::tuple<Ts...>> cubos::core::ecs::QueryData<Ts>::at(Entity entity)

Accesses the match for the given entity, if there is one.

Parameters
entity Entity.
Returns Requested data, or nothing if the entity does not match the query.

template<typename... Ts>
memory::Opt<std::tuple<Ts...>> cubos::core::ecs::QueryData<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.