Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::ecs::details::ComponentStorageBase Class Referenceabstract

Base class for type-erased component storage. More...

#include <components_manager.hpp>

Inheritance diagram for helios::ecs::details::ComponentStorageBase:
helios::ecs::details::ComponentStorage< T >

Public Member Functions

virtual ~ComponentStorageBase ()=default
 
virtual void Clear () noexcept=0
 Clears all components from storage.
 
virtual void Remove (Entity entity)=0
 Removes component for the specified entity.
 
virtual bool TryRemove (Entity entity)=0
 Attempts to remove component for the specified entity.
 
virtual bool Contains (Entity entity) const =0
 Checks if entity has a component in this storage.
 
virtual size_t Size () const noexcept=0
 Gets the number of components in storage.
 
virtual ComponentTypeInfo GetTypeInfo () const noexcept=0
 Gets type information for the component type stored.
 

Detailed Description

Base class for type-erased component storage.

Provides a common interface for storing different component types in a heterogeneous container. Each derived ComponentStorage<T> manages components of a specific type T using a sparse set for efficient operations.

Note
Not thread-safe. All operations should be performed from the main thread.

Definition at line 30 of file components_manager.hpp.

Constructor & Destructor Documentation

◆ ~ComponentStorageBase()

virtual helios::ecs::details::ComponentStorageBase::~ComponentStorageBase ( )
virtualdefault

Member Function Documentation

◆ Clear()

virtual void helios::ecs::details::ComponentStorageBase::Clear ( )
pure virtualnoexcept

Clears all components from storage.

Removes all component instances and resets internal state.

Implemented in helios::ecs::details::ComponentStorage< T >.

◆ Contains()

virtual bool helios::ecs::details::ComponentStorageBase::Contains ( Entity  entity) const
pure virtual

Checks if entity has a component in this storage.

Performs fast lookup to determine component presence.

Parameters
entityEntity to check
Returns
True if entity has a component in this storage, false otherwise

Implemented in helios::ecs::details::ComponentStorage< T >.

◆ GetTypeInfo()

virtual ComponentTypeInfo helios::ecs::details::ComponentStorageBase::GetTypeInfo ( ) const
pure virtualnoexcept

Gets type information for the component type stored.

Returns compile-time component metadata including size, alignment, etc.

Returns
ComponentTypeInfo for the stored component type

Implemented in helios::ecs::details::ComponentStorage< T >.

◆ Remove()

virtual void helios::ecs::details::ComponentStorageBase::Remove ( Entity  entity)
pure virtual

Removes component for the specified entity.

Removes the component associated with the entity.

Warning
Triggers assertion if entity doesn't have the component.
Parameters
entityEntity to remove component from

Implemented in helios::ecs::details::ComponentStorage< T >.

◆ Size()

virtual size_t helios::ecs::details::ComponentStorageBase::Size ( ) const
pure virtualnoexcept

Gets the number of components in storage.

Returns count of component instances currently stored.

Returns
Number of components in storage

Implemented in helios::ecs::details::ComponentStorage< T >.

◆ TryRemove()

virtual bool helios::ecs::details::ComponentStorageBase::TryRemove ( Entity  entity)
pure virtual

Attempts to remove component for the specified entity.

Removes the component if it exists, otherwise does nothing.

Parameters
entityEntity to remove component from
Returns
True if component was removed, false if entity didn't have the component

Implemented in helios::ecs::details::ComponentStorage< T >.