2#include "gaia/config/config.h"
7#include "gaia/core/hashing_policy.h"
8#include "gaia/core/utility.h"
9#include "gaia/ecs/id.h"
10#include "gaia/mem/data_layout_policy.h"
11#include "gaia/meta/type_info.h"
19 using ComponentVersion = uint32_t;
20 using ChunkDataVersionOffset = uint8_t;
21 using CompOffsetMappingIndex = uint8_t;
22 using ChunkDataOffset = uint16_t;
23 using ComponentLookupHash = core::direct_hash_key<uint64_t>;
28 using SortComponentCond = core::is_smaller<Entity>;
34 enum class DataStorageType : uint32_t {
42 #define GAIA_STORAGE(storage_name) \
43 static constexpr auto gaia_Storage_Type = ::gaia::ecs::DataStorageType::storage_name
47 template <
typename,
typename =
void>
49 static constexpr DataStorageType value = DataStorageType::Table;
52 struct storage_type<T, std::void_t<decltype(T::gaia_Storage_Type)>> {
53 static constexpr DataStorageType value = T::gaia_Storage_Type;
66 struct is_component_size_valid: std::bool_constant<sizeof(T) < Component::MaxComponentSizeInBytes> {};
69 struct is_component_type_valid:
72 (!mem::is_soa_layout_v<T> || std::is_trivially_copyable_v<T>)> {};
80 constexpr void verify_comp() {
81 using U = typename actual_type_t<T>::TypeOriginal;
86 "Components have to be \"raw\" types - no arrays, no const, reference, pointer or volatile");
93 template <typename Container>
94 GAIA_NODISCARD constexpr ComponentLookupHash calc_lookup_hash(Container arr) noexcept {
95 constexpr auto arrSize = arr.size();
96 if constexpr (arrSize == 0) {
99 ComponentLookupHash::Type hash = arr[0];
100 core::each<arrSize - 1>([&hash, &arr](auto i) {
101 hash = core::hash_combine(hash, arr[i + 1]);
107 template <typename = void, typename...>
108 constexpr ComponentLookupHash calc_lookup_hash() noexcept;
110 template <typename T, typename... Rest>
111 GAIA_NODISCARD constexpr ComponentLookupHash calc_lookup_hash() noexcept {
112 if constexpr (sizeof...(Rest) == 0)
113 return {meta::type_info::hash<T>()};
115 return {core::hash_combine(meta::type_info::hash<T>(), meta::type_info::hash<Rest>()...)};
119 GAIA_NODISCARD constexpr ComponentLookupHash calc_lookup_hash() noexcept {
126 GAIA_NODISCARD inline ComponentLookupHash calc_lookup_hash(EntitySpan comps) noexcept {
127 const auto compsSize = comps.size();
131 auto hash = core::calculate_hash64(comps[0].value());
132 GAIA_FOR2(1, compsSize) {
133 hash = core::hash_combine(hash, core::calculate_hash64(comps[i].value()));
143 template <uint32_t MAX_COMPONENTS>
144 GAIA_NODISCARD inline uint32_t comp_idx(const Entity* pComps, Entity entity) {
147 GAIA_FOR(MAX_COMPONENTS) {
148 if (pComps[i] == entity)
160 GAIA_NODISCARD inline uint32_t comp_idx(std::span<const Entity> comps, Entity entity) {
163 const auto cnt = (uint32_t)comps.size();
165 if (comps[i] == entity)
Definition span_impl.h:99
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9
Definition component.h:48