class final
#include <core/ecs/query/node/archetype.hpp>
QueryArchetypeNode Node which forces a given target to belong to a set of archetypes.
Base classes
Constructors, destructors, conversion operators
- QueryArchetypeNode(int target)
- Constructs.
Public functions
- void with(ColumnId column)
- Forces the node to match only archetypes with the given column.
- void without(ColumnId column)
- Forces the node to match only archetypes without the given column.
- auto equivalent(const QueryArchetypeNode& other) const -> bool
- Returns whether two nodes are equivalent.
- auto target() const -> int
- Gets the target being filtered.
- auto archetypes() const -> const std::vector<ArchetypeId>&
- Gets the known archetypes which match the requirements for the target.
- auto estimate() const -> std::size_t override
- Returns a rough estimate on how many matches this node produces by itself.
- void update(World& world) override
- Updates the node with new data from the given world.
- auto next(World& world, TargetMask pins, Iterator& iterator) const -> bool override
- Advances the iterator to the next valid match, or checks if the pinned targets are valid.
Function documentation
cubos:: core:: ecs:: QueryArchetypeNode:: QueryArchetypeNode(int target)
Constructs.
Parameters | |
---|---|
target | Target. |
bool cubos:: core:: ecs:: QueryArchetypeNode:: equivalent(const QueryArchetypeNode& other) const
Returns whether two nodes are equivalent.
Parameters | |
---|---|
other | Other node. |
std::size_t cubos:: core:: ecs:: QueryArchetypeNode:: estimate() const override
Returns a rough estimate on how many matches this node produces by itself.
Nodes are sorted by this value to minimize the number of iterations. It makes more sense to first run the node which produces the fewest matches, as it will be the most selective.
bool cubos:: core:: ecs:: QueryArchetypeNode:: next(World& world,
TargetMask pins,
Iterator& iterator) const override
Advances the iterator to the next valid match, or checks if the pinned targets are valid.
Parameters | |
---|---|
world | World being queried. |
pins | Whether each target is pinned. |
iterator | Iterator. |
Returns | Whether a match was found. |
Operates in two different modes:
- Iterate: at least one of the node targets is not pinned.
- Validate: all node targets are already pinned.
When iterating, this function should receive an iterator with the cursor index set to SIZE_MAX, or one previously returned by this function. It will update the iterator's cursor index and row to point to the first or next valid match. The relevant target archetypes and cursor rows will be set for any newly pinned targets.
When validating, the function will only check if the pinned targets match the requirements and return true or false without modifying the iterator. The passed iterator should have the pinned targets' archetypes and cursor rows set.