Optimized view for single-component queries.
More...
#include <View.hpp>
|
| | View (SparseSet< T > *pool) |
| | Constructs a single-component view.
|
| Iterator | begin () const |
| | Returns iterator to the first entity.
|
| Iterator | end () const |
| | Returns iterator past the last entity.
|
| T & | get (Entity entity) |
| | Gets the component for an entity.
|
| const T & | get (Entity entity) const |
| | Gets the component for an entity.
|
| std::tuple< T & > | getAll (Entity entity) |
| | Gets all components for an entity as a tuple.
|
| bool | empty () const |
| | Checks if the view is empty.
|
| usize | size () const |
| | Gets the exact number of entities in the view.
|
| usize | sizeHint () const |
| | Upper bound on matching entities — exact here, since nothing filters.
|
| template<typename Func> |
| void | each (Func &&func) |
| | Executes a function for each entity.
|
| template<typename Func> |
| void | eachLive (Func &&func) |
| | Like each(), but iterates the live dense array with no defensive copy.
|
template<typename T>
class esengine::ecs::View< T >
Optimized view for single-component queries.
- Template Parameters
-
| T | The single component type |
When querying for only one component type, no filtering is needed. This specialization directly iterates the component pool for maximum efficiency.
}
p.x += 1.0f;
});
void each(Func &&func)
Executes a function for each entity.
Entity identifier with packed index + generation.
Definition at line 397 of file View.hpp.
◆ Iterator
◆ PoolsTuple
Tuple type for pool pointers.
Definition at line 189 of file View.hpp.
◆ View()
Constructs a single-component view.
- Parameters
-
| pool | Pointer to the component pool |
Definition at line 406 of file View.hpp.
◆ begin()
Returns iterator to the first entity.
- Returns
- Begin iterator
Definition at line 412 of file View.hpp.
◆ each()
template<typename T>
template<typename Func>
Executes a function for each entity.
- Template Parameters
-
- Parameters
-
| func | The callback to invoke |
Optimized direct iteration without any filtering. Callback signatures:
- void(Entity, T&) - entity and component
- void(T&) - component only
- void(Entity) - entity only
Definition at line 467 of file View.hpp.
◆ eachLive()
template<typename T>
template<typename Func>
Like each(), but iterates the live dense array with no defensive copy.
- Warning
- The callback MUST NOT emplace/remove T during iteration — that would invalidate the dense array. Use for read-only per-frame system passes (the common hot path); use each() when the callback may mutate the pool.
Definition at line 494 of file View.hpp.
◆ empty()
Checks if the view is empty.
- Returns
- True if no entities have this component
Definition at line 441 of file View.hpp.
◆ end()
Returns iterator past the last entity.
- Returns
- End iterator
Definition at line 418 of file View.hpp.
◆ get() [1/2]
Gets the component for an entity.
- Parameters
-
- Returns
- Reference to the component
Definition at line 425 of file View.hpp.
◆ get() [2/2]
Gets the component for an entity.
- Parameters
-
- Returns
- Reference to the component
Definition at line 428 of file View.hpp.
◆ getAll()
Gets all components for an entity as a tuple.
- Parameters
-
- Returns
- Tuple of component references
Definition at line 435 of file View.hpp.
◆ size()
◆ sizeHint()
Upper bound on matching entities — exact here, since nothing filters.
- Returns
- Entity count
Definition at line 453 of file View.hpp.
References size().
The documentation for this class was generated from the following file:
- /home/runner/work/estella/estella/src/esengine/ecs/View.hpp