CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Component< T > Struct Template Reference

Components serve as the base for data storage for an entity. More...

#include <CeresEngine/Entity/Component.hpp>

Inheritance diagram for CeresEngine::Component< T >:
CeresEngine::AbstractComponent

Classes

struct  Accessor
 An accessor class that implements high-level access to an entity that has the given component. More...
 

Public Member Functions

const ComponentTypegetComponentType () const noexcept final
 Gets the component type.
 
- Public Member Functions inherited from CeresEngine::AbstractComponent
virtual CE_DISABLE_WARNING_MISSING_OVERRIDE ::CeresEngine::ClassInfo getClassInfo () noexcept
 
virtual ::CeresEngine::ClassInfo getClassInfo () const noexcept
 
virtual ~AbstractComponent ()=default
 Defaulted virtual destructor.
 

Static Public Attributes

static const ComponentID componentID = getComponentID()
 This component type ID.
 
static const ComponentMask mask
 The component mask.
 
static const ComponentTypecomponentType = ComponentType::get<C>()
 Gets the component type.
 

Static Private Member Functions

static ComponentID getComponentID () noexcept
 

Detailed Description

template<typename T>
struct CeresEngine::Component< T >

Components serve as the base for data storage for an entity.

All data for an entity must be stored in a component. The storage, lifetime and allocation of the component is managed by the EntityManager.

All components should implement serialization via RTTI to allow them to be transferred over the network or persisted into a file for save/load support.

Components are also encouraged to implement an Accessor type that acts as a high-level interface to access data in an entity, as direct access to the component data is discouraged.

See also
Component::Accessor For more details on how to implement an accessor for a user-defined component.
Template Parameters
Tthe component implementation type

Member Function Documentation

◆ getComponentID()

template<typename C >
ComponentID CeresEngine::Component< C >::getComponentID ( )
staticprivatenoexcept
Returns
This component type ID

◆ getComponentType()

template<typename T >
const ComponentType & CeresEngine::Component< T >::getComponentType ( ) const
inlinefinalvirtualnoexcept

Gets the component type.

This object can be used to compare if two components are of the same type.

Implements CeresEngine::AbstractComponent.

Member Data Documentation

◆ componentID

template<typename T >
const ComponentID CeresEngine::Component< T >::componentID = getComponentID()
inlinestatic

This component type ID.

◆ componentType

template<typename C >
const ComponentType & CeresEngine::Component< C >::componentType = ComponentType::get<C>()
static

Gets the component type.

This object can be used to compare if two components are of the same type.

◆ mask

template<typename T >
const ComponentMask CeresEngine::Component< T >::mask
inlinestatic
Initial value:
= []() noexcept {
m[componentID] = true;
return m;
}()
std::bitset< 128 > ComponentMask
A bitset that represents a components mask (i.e. a set of components)
Definition Component.hpp:35
static const ComponentID componentID
This component type ID.
Definition Component.hpp:76

The component mask.

Can be used with the or operator to join multiple component masks.


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