class final
#include <core/ecs/query/node/related.hpp>
QueryRelatedNode Node which forces two given targets to be related with a given relation.
Base classes
Constructors, destructors, conversion operators
- QueryRelatedNode(int cursor, DataTypeId dataType, bool isSymmetric, bool includeDuplicates, Traversal traversal, QueryArchetypeNode& fromNode, QueryArchetypeNode& toNode)
- Constructs.
Public functions
- 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:: QueryRelatedNode:: QueryRelatedNode(int cursor,
DataTypeId dataType,
bool isSymmetric,
bool includeDuplicates,
Traversal traversal,
QueryArchetypeNode& fromNode,
QueryArchetypeNode& toNode)
Constructs.
Parameters | |
---|---|
cursor | Cursor index. |
dataType | Relation data type. |
isSymmetric | Whether the relation is symmetric. |
includeDuplicates | Whether, if the relation is symmetric, a relation may appear twice. |
traversal | Traversal type, in case we're filtering a tree relation. |
fromNode | From target node. |
toNode | To target node. |
std::size_t cubos:: core:: ecs:: QueryRelatedNode:: 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:: QueryRelatedNode:: 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.