class
#include <core/ecs/query/node/node.hpp>
QueryNode Query filter step, which receives an iterator and advances it until it points to a valid match.
Derived classes
- class QueryArchetypeNode final
- Node which forces a given target to belong to a set of archetypes.
- class QueryRelatedNode final
- Node which forces two given targets to be related with a given relation.
Public types
- using TargetMask = unsigned char
- Target mask type.
Public static variables
- static int MaxTargetCount constexpr
- Maximum number of targets.
- static int MaxCursorCount constexpr
- Maximum number of cursors.
Constructors, destructors, conversion operators
- QueryNode(int cursor)
- Constructs.
Public functions
- auto cursor() const -> int
- Gets the cursor index of the node.
- auto pins() const -> TargetMask
- Gets the mask which indicates which targets the node pins.
- auto estimate() const -> std::size_t pure virtual
- Returns a rough estimate on how many matches this node produces by itself.
- void update(World& world) pure virtual
- Updates the node with new data from the given world.
- auto next(World& world, TargetMask pins, Iterator& iterator) const -> bool pure virtual
- Advances the iterator to the next valid match, or checks if the pinned targets are valid.
Protected functions
- void pins(int target)
- Indicates that the node pins the given target.
Function documentation
std::size_t cubos:: core:: ecs:: QueryNode:: estimate() const pure virtual
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:: QueryNode:: next(World& world,
TargetMask pins,
Iterator& iterator) const pure virtual
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.
void cubos:: core:: ecs:: QueryNode:: pins(int target) protected
Indicates that the node pins the given target.
Parameters | |
---|---|
target | Target. |