Symphony Of Empires
Entity< T > Struct Template Reference

An entity which can only be referenced by an (presumably) unique Id this is the base class for the other entity types. More...

#include <entity.hpp>

Inheritance diagram for Entity< T >:

Public Types

using Id = T
 

Public Member Functions

constexpr Entity () noexcept=default
 
constexpr Entity (Entity &&) noexcept=default
 
constexpr Entity (const Entity &) noexcept=default
 
constexpr Entityoperator= (const Entity &) noexcept=default
 
constexpr ~Entity () noexcept=default
 
constexpr bool is_invalid () const
 Checks if the current id is invalid. More...
 
constexpr bool is_valid () const
 Checks if the current id is valid. More...
 
constexpr operator Id () const noexcept
 
constexpr operator size_t () const noexcept
 
constexpr Id get_id () const
 

Static Public Member Functions

constexpr static Id invalid ()
 Returns an invalid id. More...
 
constexpr static bool is_invalid (Id id)
 Checks if the id is not valid. More...
 
constexpr static bool is_valid (Id id)
 Checks if the id is valid. More...
 

Public Attributes

Id cached_id
 Id used to speed up Id lookups on any context. More...
 

Detailed Description

template<typename T>
struct Entity< T >

An entity which can only be referenced by an (presumably) unique Id this is the base class for the other entity types.

Template Parameters
TThe type used for the Id

Definition at line 94 of file entity.hpp.

Member Typedef Documentation

◆ Id

template<typename T >
using Entity< T >::Id = T

Definition at line 95 of file entity.hpp.

Constructor & Destructor Documentation

◆ Entity() [1/3]

template<typename T >
constexpr Entity< T >::Entity ( )
constexprdefaultnoexcept

◆ Entity() [2/3]

template<typename T >
constexpr Entity< T >::Entity ( Entity< T > &&  )
constexprdefaultnoexcept

◆ Entity() [3/3]

template<typename T >
constexpr Entity< T >::Entity ( const Entity< T > &  )
constexprdefaultnoexcept

◆ ~Entity()

template<typename T >
constexpr Entity< T >::~Entity ( )
constexprdefaultnoexcept

Member Function Documentation

◆ get_id()

template<typename T >
constexpr Id Entity< T >::get_id ( ) const
inlineconstexpr

Definition at line 152 of file entity.hpp.

Here is the caller graph for this function:

◆ invalid()

template<typename T >
constexpr static Id Entity< T >::invalid ( )
inlinestaticconstexpr

Returns an invalid id.

Returns
constexpr Id The invalid id

Definition at line 110 of file entity.hpp.

Here is the caller graph for this function:

◆ is_invalid() [1/2]

template<typename T >
constexpr bool Entity< T >::is_invalid ( ) const
inlineconstexpr

Checks if the current id is invalid.

Returns
true
false

Definition at line 133 of file entity.hpp.

Here is the caller graph for this function:

◆ is_invalid() [2/2]

template<typename T >
constexpr static bool Entity< T >::is_invalid ( Id  id)
inlinestaticconstexpr

Checks if the id is not valid.

Parameters
idId to check
Returns
true
false

Definition at line 118 of file entity.hpp.

Here is the call graph for this function:

◆ is_valid() [1/2]

template<typename T >
constexpr bool Entity< T >::is_valid ( ) const
inlineconstexpr

Checks if the current id is valid.

Returns
true
false

Definition at line 140 of file entity.hpp.

Here is the call graph for this function:

◆ is_valid() [2/2]

template<typename T >
constexpr static bool Entity< T >::is_valid ( Id  id)
inlinestaticconstexpr

Checks if the id is valid.

Parameters
idId to check
Returns
true
false

Definition at line 126 of file entity.hpp.

Here is the call graph for this function:

◆ operator Id()

template<typename T >
constexpr Entity< T >::operator Id ( ) const
inlineconstexprnoexcept

Definition at line 144 of file entity.hpp.

◆ operator size_t()

template<typename T >
constexpr Entity< T >::operator size_t ( ) const
inlineconstexprnoexcept

Definition at line 148 of file entity.hpp.

◆ operator=()

template<typename T >
constexpr Entity& Entity< T >::operator= ( const Entity< T > &  )
constexprdefaultnoexcept

Member Data Documentation

◆ cached_id

template<typename T >
Id Entity< T >::cached_id

Id used to speed up Id lookups on any context.

Note
This depends that the container is sequential (as if it was a contigous array) - Otherwise this optimization will break

Definition at line 106 of file entity.hpp.


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