Easys
A minimalist, header-only C++ ECS library for efficient and fuss-free entity and component management.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Easys::View Class Reference

A lightweight, read-only snapshot of a set of entities. More...

#include <view.hpp>

Public Member Functions

 View (std::vector< Easys::Entity > ents) noexcept
 Constructs a View by taking ownership of a vector of entities.
 
 View (View &&) noexcept=default
 
Viewoperator= (View &&) noexcept=default
 
 View (const View &)=default
 
Viewoperator= (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.
 

Detailed Description

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>();
if(view.contains(playerEntity)) { ... }
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

Constructor & Destructor Documentation

◆ View() [1/3]

Easys::View::View ( std::vector< Easys::Entity ents)
inlineexplicitnoexcept

Constructs a View by taking ownership of a vector of entities.

Parameters
entsThe 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

Member Function Documentation

◆ 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
eThe 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
eThe 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: