Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ECS::ComponentManager Class Reference

#include <ComponentManager.h>

+ Inheritance diagram for ECS::ComponentManager:

Classes

class  ComponentContainer
 
class  IComponentContainer
 

Public Types

template<class T >
using TComponentIterator = typename ComponentContainer< T >::iterator
 

Public Member Functions

 ComponentManager ()
 
 ~ComponentManager ()
 
template<class T , class ... ARGS>
T * AddComponent (const EntityId entityId, ARGS &&... args)
 
template<class T >
void RemoveComponent (const EntityId entityId)
 
void RemoveAllComponents (const EntityId entityId)
 
void PassDataToAllComponents (const EntityId entityId, const CustomEvent &data)
 
template<class T >
T * GetComponent (const EntityId entityId)
 
template<class T >
ComponentContainer< T > * GetComponentContainer ()
 
template<class T >
TComponentIterator< T > begin ()
 
template<class T >
TComponentIterator< T > end ()
 
template<class T >
size_t size () const noexcept
 

Private Types

using ComponentContainerRegistry = eastl::unordered_map< ComponentTypeId, IComponentContainer * >
 
using ComponentLookupTable = eastl::vector< IComponent * >
 
using EntityComponentMap = eastl::vector< eastl::vector< ComponentId > >
 

Private Member Functions

 ComponentManager (const ComponentManager &)=delete
 
ComponentManageroperator= (ComponentManager &)=delete
 
ComponentId AqcuireComponentId (IComponent *component)
 
void ReleaseComponentId (ComponentId id)
 
void MapEntityComponent (EntityId entityId, ComponentId componentId, ComponentTypeId componentTypeId)
 
void UnmapEntityComponent (EntityId entityId, ComponentId componentId, ComponentTypeId componentTypeId)
 
- Private Member Functions inherited from ECS::Memory::GlobalMemoryUser
 GlobalMemoryUser ()
 
virtual ~GlobalMemoryUser ()
 
const void * Allocate (size_t memSize, const char *user=nullptr)
 
void Free (void *pMem)
 

Private Attributes

ComponentContainerRegistry m_ComponentContainerRegistry
 
ComponentLookupTable m_ComponentLUT
 
EntityComponentMap m_EntityComponentMap
 

Friends

class IComponent
 

Detailed Description

Definition at line 37 of file ComponentManager.h.

Member Typedef Documentation

◆ ComponentContainerRegistry

Definition at line 96 of file ComponentManager.h.

◆ ComponentLookupTable

Definition at line 101 of file ComponentManager.h.

◆ EntityComponentMap

using ECS::ComponentManager::EntityComponentMap = eastl::vector<eastl::vector<ComponentId> >
private

Definition at line 104 of file ComponentManager.h.

◆ TComponentIterator

template<class T >
using ECS::ComponentManager::TComponentIterator = typename ComponentContainer<T>::iterator

Definition at line 117 of file ComponentManager.h.

Constructor & Destructor Documentation

◆ ComponentManager() [1/2]

ECS::ComponentManager::ComponentManager ( const ComponentManager )
privatedelete

◆ ComponentManager() [2/2]

ECS::ComponentManager::ComponentManager ( )

Definition at line 17 of file ComponentManager.cpp.

◆ ~ComponentManager()

ECS::ComponentManager::~ComponentManager ( )

Definition at line 29 of file ComponentManager.cpp.

Member Function Documentation

◆ AddComponent()

template<class T , class ... ARGS>
T * ECS::ComponentManager::AddComponent ( const EntityId  entityId,
ARGS &&...  args 
)
inline

Fn: template<class T, class ...ARGS> T* ComponentManager::AddComponent(const EntityId entityId, ARGS&&... args)

Summary: Adds a component of type T to entity described by entityId.

Author: Tobias Stein

Date: 30/09/2017

Typeparams: T - Generic type parameter. ...ARGS - Type of the ...args. Parameters: entityId - Identifier for the entity. args - Variable arguments providing [in,out] The arguments.

Returns: Null if it fails, else a pointer to a T.

Definition at line 143 of file ComponentManager.h.

◆ AqcuireComponentId()

ComponentId ECS::ComponentManager::AqcuireComponentId ( IComponent component)
private

Definition at line 41 of file ComponentManager.cpp.

◆ begin()

template<class T >
TComponentIterator< T > ECS::ComponentManager::begin ( )
inline

Fn: template<class T> inline TComponentIterator<T> ComponentManager::begin()

Summary: Returns an forward iterator object that points to the beginning of a collection of all components of type T.

Author: Tobias Stein

Date: 24/09/2017

Typeparams: T - Generic type parameter.

Returns: A TComponentIterator<T>

Definition at line 330 of file ComponentManager.h.

◆ end()

template<class T >
TComponentIterator< T > ECS::ComponentManager::end ( )
inline

Fn: template<class T> inline TComponentIterator<T> ComponentManager::end()

Summary: Returns an forward iterator object that points to the end of a collection of all components of type T.

Author: Tobias Stein

Date: 24/09/2017

Typeparams: T - Generic type parameter.

Returns: A TComponentIterator<T>

Definition at line 352 of file ComponentManager.h.

◆ GetComponent()

template<class T >
T * ECS::ComponentManager::GetComponent ( const EntityId  entityId)
inline

Fn: template<class T> T* ComponentManager::GetComponent(const EntityId entityId)

Summary: Get the component of type T of an entity. If component has no such component nullptr is returned.

Author: Tobias Stein

Date: 30/09/2017

Typeparams: T - Generic type parameter. Parameters: entityId - Identifier for the entity.

Returns: Null if it fails, else the component.

Definition at line 266 of file ComponentManager.h.

◆ GetComponentContainer()

template<class T >
ComponentContainer< T > * ECS::ComponentManager::GetComponentContainer ( )
inline

Fn: template<class T> inline ComponentContainer<T> ComponentManager::GetComponentContainer()

Summary: Returns the collection of all components of type T.

Author: Tobias Stein

Date: 24/09/2017

Typeparams: T - Generic type parameter.

Returns: A ComponentContainer<T>

Definition at line 294 of file ComponentManager.h.

◆ MapEntityComponent()

void ECS::ComponentManager::MapEntityComponent ( EntityId  entityId,
ComponentId  componentId,
ComponentTypeId  componentTypeId 
)
private

Definition at line 66 of file ComponentManager.cpp.

◆ operator=()

ComponentManager & ECS::ComponentManager::operator= ( ComponentManager )
privatedelete

◆ PassDataToAllComponents()

void ECS::ComponentManager::PassDataToAllComponents ( const EntityId  entityId,
const CustomEvent data 
)
inline

Definition at line 233 of file ComponentManager.h.

◆ ReleaseComponentId()

void ECS::ComponentManager::ReleaseComponentId ( ComponentId  id)
private

Definition at line 60 of file ComponentManager.cpp.

◆ RemoveAllComponents()

void ECS::ComponentManager::RemoveAllComponents ( const EntityId  entityId)
inline

Definition at line 207 of file ComponentManager.h.

◆ RemoveComponent()

template<class T >
void ECS::ComponentManager::RemoveComponent ( const EntityId  entityId)
inline

Fn: template<class T> void ComponentManager::RemoveComponent(const EntityId entityId)

Summary: Removes the component of type T from an entity described by entityId.

Author: Tobias Stein

Date: 30/09/2017

Typeparams: T - Generic type parameter. Parameters:

entityId - Identifier for the entity.

Definition at line 186 of file ComponentManager.h.

◆ size()

template<class T >
size_t ECS::ComponentManager::size ( ) const
inlinenoexcept

Definition at line 358 of file ComponentManager.h.

◆ UnmapEntityComponent()

void ECS::ComponentManager::UnmapEntityComponent ( EntityId  entityId,
ComponentId  componentId,
ComponentTypeId  componentTypeId 
)
private

Definition at line 87 of file ComponentManager.cpp.

Friends And Related Function Documentation

◆ IComponent

friend class IComponent
friend

Definition at line 39 of file ComponentManager.h.

Member Data Documentation

◆ m_ComponentContainerRegistry

ComponentContainerRegistry ECS::ComponentManager::m_ComponentContainerRegistry
private

Definition at line 98 of file ComponentManager.h.

◆ m_ComponentLUT

ComponentLookupTable ECS::ComponentManager::m_ComponentLUT
private

Definition at line 102 of file ComponentManager.h.

◆ m_EntityComponentMap

EntityComponentMap ECS::ComponentManager::m_EntityComponentMap
private

Definition at line 105 of file ComponentManager.h.


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