Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::Component Struct Referencefinal

Identifier of a registered component type. Packs the component id, size, alignment, storage mode and SoA layout into one 64-bit value. More...

#include <id.h>

Classes

struct  InternalData
 Bit-packed storage layout of a component id. More...
 

Public Member Functions

 Component (uint32_t id, uint32_t soa, uint32_t size, uint32_t alig, DataStorageType storage) noexcept
 
GAIA_NODISCARD constexpr auto id () const noexcept
 Component id.
 
GAIA_NODISCARD constexpr auto soa () const noexcept
 Whether the component uses SoA storage.
 
GAIA_NODISCARD constexpr auto size () const noexcept
 Component size in bytes.
 
GAIA_NODISCARD constexpr auto alig () const noexcept
 Component alignment in bytes.
 
GAIA_NODISCARD constexpr DataStorageType storage_type () const noexcept
 Storage mode of the component.
 
GAIA_NODISCARD constexpr auto value () const noexcept
 Raw identifier value.
 
GAIA_NODISCARD constexpr bool operator== (Component other) const noexcept
 
GAIA_NODISCARD constexpr bool operator!= (Component other) const noexcept
 
GAIA_NODISCARD constexpr bool operator< (Component other) const noexcept
 
template<typename Serializer >
void save (Serializer &s) const
 Serializes the component id.
 
template<typename Serializer >
void load (Serializer &s)
 Deserializes the component id.
 

Public Attributes

union { 
 
   InternalData   data 
 Structured view of the packed value.
 
   Identifier   val 
 Raw 64-bit value.
 
};  
 

Static Public Attributes

static constexpr uint32_t IdMask = IdentifierIdBad
 Bit mask covering all valid component ids.
 
static constexpr uint32_t MaxComponentSize_Bits = 13
 Number of bits used to store the component size.
 
static constexpr uint32_t MaxComponentSizeInBytes = (1 << MaxComponentSize_Bits) - 1
 Largest component size storable, in bytes.
 
static constexpr uint32_t MaxAlignment_Bits = MaxComponentSize_Bits
 Number of bits used to store the component alignment.
 
static constexpr uint32_t MaxAlignment = MaxComponentSizeInBytes
 Largest component alignment storable.
 

Detailed Description

Identifier of a registered component type. Packs the component id, size, alignment, storage mode and SoA layout into one 64-bit value.

Member Function Documentation

◆ alig()

GAIA_NODISCARD constexpr auto gaia::ecs::Component::alig ( ) const
inlineconstexprnoexcept

Component alignment in bytes.

Returns
Component alignment in bytes.

◆ id()

GAIA_NODISCARD constexpr auto gaia::ecs::Component::id ( ) const
inlineconstexprnoexcept

Component id.

Returns
Component id.

◆ load()

template<typename Serializer >
void gaia::ecs::Component::load ( Serializer &  s)
inline

Deserializes the component id.

Template Parameters
Serializerserializer type.
Parameters
sserializer to read from.

◆ save()

template<typename Serializer >
void gaia::ecs::Component::save ( Serializer &  s) const
inline

Serializes the component id.

Template Parameters
Serializerserializer type.
Parameters
sserializer to write to.

◆ size()

GAIA_NODISCARD constexpr auto gaia::ecs::Component::size ( ) const
inlineconstexprnoexcept

Component size in bytes.

Returns
Component size in bytes.

◆ soa()

GAIA_NODISCARD constexpr auto gaia::ecs::Component::soa ( ) const
inlineconstexprnoexcept

Whether the component uses SoA storage.

Returns
Non-zero when SoA storage is used.

◆ storage_type()

GAIA_NODISCARD constexpr DataStorageType gaia::ecs::Component::storage_type ( ) const
inlineconstexprnoexcept

Storage mode of the component.

Returns
Storage mode of the component.

◆ value()

GAIA_NODISCARD constexpr auto gaia::ecs::Component::value ( ) const
inlineconstexprnoexcept

Raw identifier value.

Returns
Raw 64-bit value.

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