Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::Registry Class Reference

Central manager for component registration and entity-component mapping. More...

#include <Registry.h>

Public Member Functions

 Registry ()=default
 Default constructor.
 ~Registry ()
 Destructor cleans up all component storage.
template<typename T>
void RegisterComponent ()
 Register a component type T in the registry.
template<typename T>
void UnregisterComponent ()
 Unregister a component type T and free its storage.
template<typename T>
bool IsComponentRegistered ()
 Check if a component type T is registered.
template<typename T>
void AddComponent (const UUID &entity, const T &component)
 Add a component instance to an entity.
template<typename T>
void RemoveComponent (const UUID &entity, const T &component)
 Remove a component instance from an entity.
template<typename T>
bool HasComponent (const UUID &entity)
 Check if an entity has a component of type T.
template<typename T>
T * GetComponent (const UUID &entity)
 Retrieve a pointer to an entity's component data.
std::vector< ComponentIDGetEntityComponents (const UUID &entity)
 Get all component IDs attached to an entity.
std::vector< EntityGetAllEntities ()
 Retrieve all entities that have any components.
template<typename First, typename... Rest>
std::vector< EntityGetAllEntitiesWith ()
 Get entities that have all specified component types.
void RemoveEntity (const UUID &entity)
 Remove an entity based on its UUID.

Detailed Description

Central manager for component registration and entity-component mapping.

Provides methods to register/unregister component types, add/remove components on entities, and query entity lists based on component presence. Stores component data in type-specific ComponentStorage instances and tracks entity-to-component associations.

Constructor & Destructor Documentation

◆ Registry()

Raven::Registry::Registry ( )
default

Default constructor.

◆ ~Registry()

Raven::Registry::~Registry ( )
inline

Destructor cleans up all component storage.

Member Function Documentation

◆ AddComponent()

template<typename T>
void Raven::Registry::AddComponent ( const UUID & entity,
const T & component )
inline

Add a component instance to an entity.

Template Parameters
TComponent type.
Parameters
entityThe entity to add the component to.
componentThe component instance to attach.

◆ GetAllEntities()

std::vector< Entity > Raven::Registry::GetAllEntities ( )

Retrieve all entities that have any components.

Returns
Vector of entity Objects.

◆ GetAllEntitiesWith()

template<typename First, typename... Rest>
std::vector< Entity > Raven::Registry::GetAllEntitiesWith ( )
inline

Get entities that have all specified component types.

Template Parameters
FirstFirst component type.
RestRemaining component types.
Returns
Vector of entity Objects matching all components.

◆ GetComponent()

template<typename T>
T * Raven::Registry::GetComponent ( const UUID & entity)
inline

Retrieve a pointer to an entity's component data.

Template Parameters
TComponent type.
Parameters
entityThe entity whose component to retrieve.
Returns
Pointer to the component, or nullptr if not present.

◆ GetEntityComponents()

std::vector< ComponentID > Raven::Registry::GetEntityComponents ( const UUID & entity)
inline

Get all component IDs attached to an entity.

Parameters
entityThe entity whose components to list.
Returns
Vector of ComponentID values.

◆ HasComponent()

template<typename T>
bool Raven::Registry::HasComponent ( const UUID & entity)
inline

Check if an entity has a component of type T.

Template Parameters
TComponent type.
Parameters
entityThe entity to check.
Returns
True if the entity has the component, false otherwise.

◆ IsComponentRegistered()

template<typename T>
bool Raven::Registry::IsComponentRegistered ( )
inline

Check if a component type T is registered.

Template Parameters
TComponent type to check.
Returns
True if registered, false otherwise.

◆ RegisterComponent()

template<typename T>
void Raven::Registry::RegisterComponent ( )
inline

Register a component type T in the registry.

Allocates storage for T if not already registered.

Template Parameters
TComponent type to register.

◆ RemoveComponent()

template<typename T>
void Raven::Registry::RemoveComponent ( const UUID & entity,
const T & component )
inline

Remove a component instance from an entity.

Template Parameters
TComponent type.
Parameters
entityThe entity to remove the component from.
componentUnused parameter; component identity by type.

◆ RemoveEntity()

void Raven::Registry::RemoveEntity ( const UUID & entity)
inline

Remove an entity based on its UUID.

Parameters
entityThe to be removed entity's unique Identifier

◆ UnregisterComponent()

template<typename T>
void Raven::Registry::UnregisterComponent ( )
inline

Unregister a component type T and free its storage.

Template Parameters
TComponent type to unregister.

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