Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::ComponentStorage< T > Class Template Reference

Stores component data for a specific component type. More...

#include <Component.h>

Inheritance diagram for Raven::ComponentStorage< T >:
Raven::ComponentBase

Public Member Functions

void Add (const UUID &entity, const T &component)
 Add a component instance for a given entity.
void Remove (const UUID &entity) override
 Remove the component associated with a given entity.
bool Has (const UUID &entity) const
 Check if a component exists for a given entity.
T * Get (const UUID &entity)
 Retrieve the component associated with a given entity.
const std::unordered_map< UUID, T > & GetAll () const
 Get all stored components.
Public Member Functions inherited from Raven::ComponentBase
virtual ~ComponentBase ()=default

Detailed Description

template<typename T>
class Raven::ComponentStorage< T >

Stores component data for a specific component type.

Template Parameters
TThe type of component being stored.

Each component type has a dedicated ComponentStorage instance that handles storage and retrieval of component data, indexed by entity UUID.

Member Function Documentation

◆ Add()

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

Add a component instance for a given entity.

Parameters
entityUUID of the entity.
componentThe component instance to store.

◆ Get()

template<typename T>
T * Raven::ComponentStorage< T >::Get ( const UUID & entity)
inline

Retrieve the component associated with a given entity.

Parameters
entityUUID of the entity.
Returns
Pointer to the component, or nullptr if not found.

◆ GetAll()

template<typename T>
const std::unordered_map< UUID, T > & Raven::ComponentStorage< T >::GetAll ( ) const
inline

Get all stored components.

Returns
Const reference to the internal unordered map of components.

◆ Has()

template<typename T>
bool Raven::ComponentStorage< T >::Has ( const UUID & entity) const
inline

Check if a component exists for a given entity.

Parameters
entityUUID of the entity.
Returns
True if the component exists, false otherwise.

◆ Remove()

template<typename T>
void Raven::ComponentStorage< T >::Remove ( const UUID & entity)
inlineoverridevirtual

Remove the component associated with a given entity.

Parameters
entityUUID of the entity.

Implements Raven::ComponentBase.


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