GPR5100 - Rollback
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
core::ComponentManager< T, C > Class Template Reference

ComponentManager is a class that owns Component in a contiguous array. Component indexing is done with an Entity. More...

#include <component.h>

Collaboration diagram for core::ComponentManager< T, C >:
Collaboration graph
[legend]

Public Member Functions

 ComponentManager (EntityManager &entityManager)
 
 ComponentManager (const ComponentManager &)=delete
 
ComponentManageroperator= (ComponentManager &)=delete
 
 ComponentManager (ComponentManager &&)=delete
 
ComponentManageroperator= (ComponentManager &&)=delete
 
virtual void AddComponent (Entity entity)
 AddComponent is a method that sets the flag C in the EntityManager and resize if need the components_ array. More...
 
virtual void RemoveComponent (Entity entity)
 RemoveComponent is a method that unsets the flag C in the EntityManager. More...
 
const T & GetComponent (Entity entity) const
 GetComponent is a method that gets a constant reference to a Component given the Entity. More...
 
T & GetComponent (Entity entity)
 GetComponent is a method that gets a reference to a Component given the Entity. More...
 
void SetComponent (Entity entity, const T &value)
 SetComponent is a method that sets a new value of the Component of an Entity. More...
 
const std::vector< T > & GetAllComponents () const
 GetAllComponents is a method that returns the internal array of components. More...
 
void CopyAllComponents (const std::vector< T > &components)
 CopyAllComponents is a method that changes the internal components array by copying a newly provided one. It is used by the RollbackManager when reverting the current game world data with the last validated game world data. More...
 

Protected Attributes

EntityManagerentityManager_
 
std::vector< T > components_
 

Detailed Description

template<typename T, Component C>
class core::ComponentManager< T, C >

ComponentManager is a class that owns Component in a contiguous array. Component indexing is done with an Entity.

Template Parameters
Ttype of the component
Cunique binary flag of the component. This will be set in the EntityMask of the EntityManager when added.

Member Function Documentation

◆ AddComponent()

template<typename T , Component C>
void core::ComponentManager< T, C >::AddComponent ( Entity  entity)
virtual

AddComponent is a method that sets the flag C in the EntityManager and resize if need the components_ array.

Parameters
entitywill have its flag C added in EntityManager

Reimplemented in core::ScaleManager.

Here is the caller graph for this function:

◆ CopyAllComponents()

template<typename T , Component C>
void core::ComponentManager< T, C >::CopyAllComponents ( const std::vector< T > &  components)

CopyAllComponents is a method that changes the internal components array by copying a newly provided one. It is used by the RollbackManager when reverting the current game world data with the last validated game world data.

Parameters
componentsis the new component array to be copy instead of the old components array

◆ GetAllComponents()

template<typename T , Component C>
const std::vector< T > & core::ComponentManager< T, C >::GetAllComponents

GetAllComponents is a method that returns the internal array of components.

Returns
the internal array of components

◆ GetComponent() [1/2]

template<typename T , Component C>
T & core::ComponentManager< T, C >::GetComponent ( Entity  entity)

GetComponent is a method that gets a reference to a Component given the Entity.

Parameters
entityis the one that we want the Component of.
Returns
the reference to the Component of Entity entity.

◆ GetComponent() [2/2]

template<typename T , Component C>
const T & core::ComponentManager< T, C >::GetComponent ( Entity  entity) const

GetComponent is a method that gets a constant reference to a Component given the Entity.

Parameters
entityis the one that we want the Component of.
Returns
the constant reference to the Component of Entity entity.

◆ RemoveComponent()

template<typename T , Component C>
void core::ComponentManager< T, C >::RemoveComponent ( Entity  entity)
virtual

RemoveComponent is a method that unsets the flag C in the EntityManager.

Parameters
entitywill have its flag C removed

◆ SetComponent()

template<typename T , Component C>
void core::ComponentManager< T, C >::SetComponent ( Entity  entity,
const T &  value 
)

SetComponent is a method that sets a new value of the Component of an Entity.

Parameters
entitywill have its component set.
valueis the new value that will be set.

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