VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::View< Components > Class Template Reference

Provides iteration over entities that have all specified component types. More...

#include <View.hpp>

Public Member Functions

 View (Registry &reg)
 Constructs a View for querying entities with the specified component types.
template<typename Func>
void each (Func func)
 Iterates over all entities with the specified component types.

Private Attributes

Registrym_registry
 Reference to the Registry containing the component data.

Detailed Description

template<typename... Components>
class vex::View< Components >

Provides iteration over entities that have all specified component types.

View is a query interface that allows efficient iteration over all entities matching a given component signature. It uses the first component type as the primary storage to iterate over, then filters based on presence of other components.

Template Parameters
ComponentsVariable number of component types that entities must have.
Note
This is a lightweight, non-owning view into the Registry's component data. The Registry must remain valid for the lifetime of the View.
Examples
/home/devu/Documents/Projects/VEX/Engine/Core/include/components/ECS/ECS.hpp.

Definition at line 17 of file View.hpp.

Constructor & Destructor Documentation

◆ View()

template<typename... Components>
vex::View< Components >::View ( Registry & reg)
inline

Constructs a View for querying entities with the specified component types.

Parameters
regReference to the Registry to query.

Definition at line 25 of file View.hpp.

Member Function Documentation

◆ each()

template<typename... Components>
template<typename Func>
void vex::View< Components >::each ( Func func)
inline

Iterates over all entities with the specified component types.

Template Parameters
FuncThe callable type that processes each matching entity.
Parameters
funcCallback function invoked for each matching entity.

The callback receives the entity ID followed by references to all components in the order specified in the View template parameters. Example usage:

View<Position, Velocity> view(registry);
view.each([](Entity e, Position& pos, Velocity& vel) {
pos.x += vel.x;
pos.y += vel.y;
});
View(Registry &reg)
Constructs a View for querying entities with the specified component types.
Definition View.hpp:25
uint32_t Entity
Type alias representing a unique entity identifier in the ECS system.
Definition Types.hpp:11

Definition at line 40 of file View.hpp.

Member Data Documentation

◆ m_registry

template<typename... Components>
Registry& vex::View< Components >::m_registry
private

Reference to the Registry containing the component data.

Definition at line 20 of file View.hpp.


The documentation for this class was generated from the following file: