Raven Engine v0.1
A modern 3D Game Engine
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>
bool RegisterComponent ()
 Register a component type T in the registry.
template<typename T>
bool UnregisterComponent ()
 Unregister a component type T and free its storage.
template<typename T>
bool IsComponentRegistered () const
 Check if a component type T is registered.
bool HasRegisteredComponents () const noexcept
 Check if the registry has any components registered.
template<typename T>
bool AddComponent (const UUID &entity, const T &component)
 Add a component instance to an entity.
template<typename T>
bool RemoveComponent (const UUID &entity)
 Remove a component instance from an entity.
CORE_API bool RemoveAllComponents (const UUID &entity)
 Remove all components 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.
CORE_API 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 Copy (Registry &dst)

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>
bool 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.
Returns
True if the Component was added, false otherwise.

◆ Copy()

void Raven::Registry::Copy ( Registry & dst)
inline

◆ 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.

◆ HasRegisteredComponents()

bool Raven::Registry::HasRegisteredComponents ( ) const
inlinenoexcept

Check if the registry has any components registered.

Returns
True if at least one component is registered, false if empty.

◆ IsComponentRegistered()

template<typename T>
bool Raven::Registry::IsComponentRegistered ( ) const
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>
bool 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.
Returns
True if the component was registered, false otherwise.

◆ RemoveAllComponents()

bool Raven::Registry::RemoveAllComponents ( const UUID & entity)

Remove all components from an entity.

Parameters
entityThe to be removed entity's unique Identifier
Returns
True if the entity had components to be removed, false otherwise

◆ RemoveComponent()

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

Remove a component instance from an entity.

Template Parameters
TComponent type.
Parameters
entityThe entity to remove the component from.
Returns
True if the Component was removed, false otherwise.

◆ UnregisterComponent()

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

Unregister a component type T and free its storage.

Template Parameters
TComponent type to unregister.
Returns
True if the component was registered, false otherwise.

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