query
| Type | Class |
| Namespace | conjure::ecs |
| Include File Path | engine/include/conjure/ecs/query.h |
| Source File Path | engine/src/ecs/query.cpp |
| API ↗ | Queries, views and systems |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | query(
world &target,
query_desc desc); | |
| public | query(
const query &) = default; | |
| public | query(
query &&) noexcept = default; |
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~query(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mContext | const system_context * | nullptr | |
| private | mDesc | query_desc | {} | |
| private | mMatches | core:: | {} | |
| private | mRegistry | const component_ | nullptr | |
| private | m | u32 | 0 | |
| private | mWorld | world * | nullptr |
Functions
Public
bind_context
bind_contextvoid bind_context(
const system_context *context) noexcept;Attaches the running system: every chunk_view this query builds carries it, so a non-const span of a component the system did not declare as written asserts (Debug validation), and non-const spans stamp the system's run version instead of the current world version, so the system never sees its own writes through its next since_version(). Set by system_context::view(); nullptr for plain world queries. The context must outlive the query's iterations.
chunk
chunk[[nodiscard]] chunk_view chunk(
u32 index);The chunk at a flat index over the visited chunks (bindings). An out-of-range index yields an invalid view. The caller holds world::lock_iteration() while using the result. The view stamps like for_each_chunk: the bound system's run version, else the current world version.
chunk_count
chunk_count[[nodiscard]] u32 chunk_count();Number of chunks the next iteration would visit. Refreshes lazily first (archetypes created since the last refresh join the cached matches), so it is non-const by design.
chunk_passes
chunk_passesTrue when a chunk of a matching archetype passes the changed filter and is not empty.
context
context[[nodiscard]] const system_context *context() const noexcept;The system bound with bind_context(), or nullptr.
desc
desc[[nodiscard]] const query_desc &desc() const noexcept;The description this query was built from.
entity_count
entity_count[[nodiscard]] u32 entity_count();Number of entities in the chunks the next iteration would visit. Refreshes lazily first, so it is non-const by design.
for_each_chunk
for_each_chunktemplate <typename Callable> void for_each_chunk(
Callable &&callable);Invokes callable(chunk_view &) for every non-empty chunk of every matching archetype that passes the changed filter, under an iteration lock. Non-const spans acquired from the view stamp the run version of the system bound with bind_context(), otherwise the world version current when the iteration started.
matches
matches[[nodiscard]] std::span<archetype *const> matches();The matching archetypes. Refreshes lazily first, so it is non-const by design.
refresh
refreshvoid refresh();Scans the archetypes created since the last refresh and caches the matching ones.
registry
registry[[nodiscard]] const component_registry ®istry() const noexcept;The registry of the world.
Private
visit_chunks
visit_chunksvoid visit_chunks(
void (*visit)(void *context, chunk_view &view),
void *context);