A lightweight, read-only snapshot of a set of entities.
More...
#include <view.hpp>
|
| | View (std::vector< Easys::Entity > ents) noexcept |
| | Constructs a View by taking ownership of a vector of entities.
|
| |
| | View (View &&) noexcept=default |
| |
| View & | operator= (View &&) noexcept=default |
| |
| | View (const View &)=default |
| |
| View & | operator= (const View &)=default |
| |
| auto | begin () noexcept |
| |
| auto | end () noexcept |
| |
| auto | begin () const noexcept |
| |
| auto | end () const noexcept |
| |
| const auto & | data () const noexcept |
| | Access the internal vector of entities.
|
| |
| size_t | size () const noexcept |
| | Number of entities in the view.
|
| |
| bool | empty () const noexcept |
| | Checks if the view is empty.
|
| |
| auto | find (Entity e) const noexcept |
| | Finds an entity in the view.
|
| |
| bool | contains (Entity e) const noexcept |
| | Checks if the view contains the given entity.
|
| |
A lightweight, read-only snapshot of a set of entities.
The View class owns a vector of entity IDs. It is typically used as the result of Registry::getEntities() or Registry::getEntities<Components...>().
Views are movable and copyable, and provide iterators, size queries, and utility functions such as find() and contains().
Example usage:
View view = ecs.getEntities<Transform, Velocity>();
for(
const Entity &e : view) { ... }
A lightweight, read-only snapshot of a set of entities.
Definition view.hpp:30
bool contains(Entity e) const noexcept
Checks if the view contains the given entity.
Definition view.hpp:88
EASYS_ENTITY_TYPE Entity
Definition entity.hpp:11
◆ View() [1/3]
Constructs a View by taking ownership of a vector of entities.
- Parameters
-
| ents | The vector of entities to move into the view. |
This constructor is move-friendly: passing an rvalue vector avoids copying.
◆ View() [2/3]
| Easys::View::View |
( |
View && |
| ) |
|
|
defaultnoexcept |
◆ View() [3/3]
| Easys::View::View |
( |
const View & |
| ) |
|
|
default |
◆ begin() [1/2]
| auto Easys::View::begin |
( |
| ) |
const |
|
inlinenoexcept |
◆ begin() [2/2]
| auto Easys::View::begin |
( |
| ) |
|
|
inlinenoexcept |
◆ contains()
| bool Easys::View::contains |
( |
Entity |
e | ) |
const |
|
inlinenoexcept |
Checks if the view contains the given entity.
- Parameters
-
| e | The entity to search for |
- Returns
- true if the entity is in the view, false otherwise
◆ data()
| const auto & Easys::View::data |
( |
| ) |
const |
|
inlinenoexcept |
Access the internal vector of entities.
- Returns
- const reference to the underlying vector
◆ empty()
| bool Easys::View::empty |
( |
| ) |
const |
|
inlinenoexcept |
Checks if the view is empty.
- Returns
- true if the view contains no entities, false otherwise
◆ end() [1/2]
| auto Easys::View::end |
( |
| ) |
const |
|
inlinenoexcept |
◆ end() [2/2]
| auto Easys::View::end |
( |
| ) |
|
|
inlinenoexcept |
◆ find()
| auto Easys::View::find |
( |
Entity |
e | ) |
const |
|
inlinenoexcept |
Finds an entity in the view.
- Parameters
-
| e | The entity to search for |
- Returns
- Iterator to the entity if found, or end() if not found
◆ operator=() [1/2]
| View & Easys::View::operator= |
( |
const View & |
| ) |
|
|
default |
◆ operator=() [2/2]
| View & Easys::View::operator= |
( |
View && |
| ) |
|
|
defaultnoexcept |
◆ size()
| size_t Easys::View::size |
( |
| ) |
const |
|
inlinenoexcept |
Number of entities in the view.
- Returns
- The number of entities
The documentation for this class was generated from the following file: