View for iterating entities with multiple required components.
More...
#include <View.hpp>
|
| | View (PoolsTuple pools) |
| | Constructs a view from component pools.
|
| Iterator | begin () const |
| | Returns iterator to the first matching entity.
|
| Iterator | end () const |
| | Returns iterator past the last entity.
|
| template<typename T> |
| T & | get (Entity entity) |
| | Gets a specific component from an entity.
|
| template<typename T> |
| const T & | get (Entity entity) const |
| | Gets a specific component from an entity.
|
| std::tuple< Components &... > | getAll (Entity entity) |
| | Gets all components for an entity as a tuple.
|
| bool | empty () const |
| | Checks if the view is empty.
|
| usize | sizeHint () const |
| | Gets the estimated number of matching entities.
|
| template<typename Func> |
| void | each (Func &&func) |
| template<typename Func> |
| void | eachLive (Func &&func) |
| | Like each(), but iterates the live dense array with no defensive copy.
|
template<typename... Components>
class esengine::ecs::View< Components >
View for iterating entities with multiple required components.
- Template Parameters
-
| Components | The component types that entities must have |
Provides iteration over all entities that have ALL of the specified component types. Optimizes by iterating over the smallest pool and filtering by other components.
pos.x += vel.x * dt;
}
p.x += v.x * dt;
});
Entity identifier with packed index + generation.
Velocity component for simple kinematic motion.
Definition at line 184 of file View.hpp.
◆ Iterator
template<typename... Components>
◆ PoolsTuple
template<typename... Components>
Tuple type for pool pointers.
Definition at line 189 of file View.hpp.
◆ View()
template<typename... Components>
Constructs a view from component pools.
- Parameters
-
| pools | Tuple of pointers to component pools |
Definition at line 195 of file View.hpp.
◆ begin()
template<typename... Components>
Returns iterator to the first matching entity.
- Returns
- Begin iterator
Definition at line 204 of file View.hpp.
References end().
◆ each()
template<typename... Components>
template<typename Func>
◆ eachLive()
template<typename... Components>
template<typename Func>
Like each(), but iterates the live dense array with no defensive copy.
- Warning
- The callback MUST NOT emplace/remove ANY of the iterated components — that reallocates or swap-pops the array being walked. Use for the read-only per-frame pass; use each() when the callback may mutate.
Definition at line 304 of file View.hpp.
◆ empty()
template<typename... Components>
Checks if the view is empty.
- Returns
- True if no entities match
Definition at line 257 of file View.hpp.
◆ end()
template<typename... Components>
Returns iterator past the last entity.
- Returns
- End iterator
Definition at line 213 of file View.hpp.
Referenced by begin().
◆ get() [1/2]
template<typename... Components>
template<typename T>
Gets a specific component from an entity.
- Template Parameters
-
| T | The component type to get |
- Parameters
-
| entity | The entity (must be valid in view) |
- Returns
- Reference to the component
Definition at line 229 of file View.hpp.
References get().
Referenced by get(), and get().
◆ get() [2/2]
template<typename... Components>
template<typename T>
Gets a specific component from an entity.
- Template Parameters
-
| T | The component type to get |
- Parameters
-
| entity | The entity (must be valid in view) |
- Returns
- Reference to the component
Definition at line 235 of file View.hpp.
References get().
◆ getAll()
template<typename... Components>
Gets all components for an entity as a tuple.
- Parameters
-
- Returns
- Tuple of component references
Definition at line 244 of file View.hpp.
◆ sizeHint()
template<typename... Components>
Gets the estimated number of matching entities.
- Returns
- Upper bound on entity count (actual may be lower)
Returns the size of the smallest pool. Actual matches may be fewer due to filtering by other components.
Definition at line 268 of file View.hpp.
The documentation for this class was generated from the following file:
- /home/runner/work/estella/estella/src/esengine/ecs/View.hpp