23template<
typename =
void,
typename _
id_type = std::u
int64_t>
26 using id_type = _id_type;
32 CO_ECS_API static auto id(std::string_view type_string) -> id_type {
33 auto [iter, inserted] = get_id_map().emplace(type_string, get_next_id());
37 auto type_id = iter->second;
52 CO_ECS_API static auto get_next_id() -> id_type& {
53 static id_type next_id{};
62template<
typename Base =
void,
typename _
id_type = std::u
int64_t>
64 using id_type = _id_type;
67 inline static const id_type value = type_registry<Base, id_type>::id(type_name<T>());
79using component_id = detail::type_id<struct _component_family_t, component_id_t>;
87 std::is_class_v<T> && std::is_nothrow_move_constructible_v<T> && std::is_nothrow_move_assignable_v<T>;
99template<component_reference T>
105template<component_reference T>
107 constexpr static bool value = std::is_const_v<std::remove_reference_t<T>>;
113template<component_reference T>
119template<component_reference T>
121 constexpr static bool value = !std::is_const_v<std::remove_reference_t<T>>;
127template<component_reference T>
135 constexpr static bool value = std::conjunction_v<const_component_reference<Args>...>;
151 template<component T>
154 component_id::value<T>,
164 return id <=> rhs.id;
199 template<component T>
201 insert(component_id::value<T>);
207 template<component T>
209 erase(component_id::value<T>);
217 template<component T>
219 return contains(component_id::value<T>);
233 _bitset.set(
id,
false);
242 return _bitset.test(
id);
255 return _bitset == rhs._bitset;
271 return std::hash<typename component_set::storage_type>()(set._bitset);
290 s._components_meta.reserve(
sizeof...(Args));
298 template<component T>
300 insert(component_meta::of<T>());
306 template<component T>
308 erase(component_id::value<T>);
316 template<component T>
318 return contains(component_id::value<T>);
328 _component_set.
insert(meta.id);
329 _components_meta.emplace_back(meta);
339 _component_set.
erase(
id);
340 std::erase_if(_components_meta, [
id](
const auto& meta) {
return meta.id == id; });
356 return _components_meta.size();
363 return _components_meta.begin();
370 return _components_meta.end();
393 return _component_set == rhs._component_set;
400 return _component_set;
Component set hasher.
Definition component.hpp:264
auto operator()(const component_set &set) const -> std::size_t
Hash component set.
Definition component.hpp:270
Component set holds a set of component IDs.
Definition component.hpp:181
auto contains() const -> bool
Check if component of type T is present in the set.
Definition component.hpp:218
void clear() noexcept
Definition component.hpp:245
detail::dynamic_bitset<> storage_type
Definition component.hpp:183
void insert()
Insert component of type T.
Definition component.hpp:200
auto contains(component_id_t id) const -> bool
Check if component is present in the set.
Definition component.hpp:241
void insert(component_id_t id)
Inserts component into the set.
Definition component.hpp:225
void erase(component_id_t id)
Erases component from the set.
Definition component.hpp:232
void erase()
Erase component of type T.
Definition component.hpp:208
static auto create() -> component_set
Construct component set from given component types.
Definition component.hpp:190
auto operator==(const component_set &rhs) const noexcept -> bool
Equality operator.
Definition component.hpp:254
Component reference concept. It should be a reference or const reference to C, where C satisfies comp...
Definition component.hpp:94
Component concept. The component must be a struct/class that can be move constructed and move assigna...
Definition component.hpp:86
#define CO_ECS_API
Definition macro.hpp:41
hash_table< K, T, true, Hash, KeyEqual, Allocator > hash_map
Hash map.
Definition hash_map.hpp:19
Definition archetype.hpp:11
constexpr bool const_component_references_v
Returns true when all Args are const references.
Definition component.hpp:142
constexpr bool mutable_component_reference_v
Returns true for non-const component references.
Definition component.hpp:128
constexpr bool const_component_reference_v
Returns true for const component references.
Definition component.hpp:114
std::decay_t< T > decay_component_t
Decay component; converts component_reference to component by removing cv-qualifiers and reference.
Definition component.hpp:100
detail::type_id< struct _component_family_t, component_id_t > component_id
Type for family used to generated component IDs.
Definition component.hpp:79
constexpr auto invalid_component_id
Invalid component ID.
Definition component.hpp:76
std::uint32_t component_id_t
Type for component ID.
Definition component.hpp:73
Struct to determine const-ness of component reference type.
Definition component.hpp:106
static constexpr bool value
Definition component.hpp:107
Struct to determine whether all component references are const.
Definition component.hpp:134
static constexpr bool value
Definition component.hpp:135
Struct to determine mutability of component reference type.
Definition component.hpp:120
static constexpr bool value
Definition component.hpp:121