co_ecs 0.9.0
Cobalt ECS
Loading...
Searching...
No Matches
co_ecs::base_registry Class Reference

#include <base_registry.hpp>

Inheritance diagram for co_ecs::base_registry:
co_ecs::registry

Public Member Functions

constexpr auto alive (entity ent) const noexcept -> bool
 Checks if the specified entity is currently active within the registry.
 
void destroy (entity ent)
 Destroys the given entity.
 
constexpr auto archetypes () noexcept -> class archetypes &
 Provides access to the modifiable list of archetypes in the registry.
 
constexpr auto archetypes () const noexcept -> const class archetypes &
 Provides access to the immutable list of archetypes in the registry.
 
constexpr auto reserve () -> placeholder_entity
 Reserves an entity in a thread-safe manner.
 
constexpr void sync ()
 Synchronizes concurently reserved entities.
 
template<component... C>
constexpr auto has (entity ent) const -> bool
 Checks if the specified entity has all the given components.
 
constexpr void visit (entity ent, auto &&func)
 Visit all components of an entity.
 
constexpr void visit (entity ent, auto &&func) const
 Visit all components of an entity (const variant).
 

Protected Member Functions

template<component... Components>
constexpr auto create_impl (Components &&... args) -> entity
 
template<component C>
constexpr auto set_impl (entity ent) -> std::pair< bool, C * >
 
template<component C>
constexpr void remove (entity ent)
 
constexpr auto allocate () -> entity
 
entity move (entity ent, base_registry &dest)
 
entity copy (entity ent, base_registry &dest) const
 
entity move (entity ent, base_registry &dest, placeholder_entity placeholder)
 
entity copy (entity ent, base_registry &dest, placeholder_entity placeholder) const
 
entity clone (entity ent)
 
entity clone (entity ent, placeholder_entity placeholder)
 

Static Protected Member Functions

template<component... Args>
static constexpr auto get_impl (auto &&self, entity ent) -> decltype(auto)
 

Protected Attributes

entity_pool _entity_pool
 
class archetypes _archetypes
 
detail::sparse_map< typename entity::id_t, entity_location_entity_archetype_map
 

Friends

class entity_ref
 
class const_entity_ref
 

Member Function Documentation

◆ alive()

constexpr auto co_ecs::base_registry::alive ( entity ent) const -> bool
inlineconstexprnoexcept

Checks if the specified entity is currently active within the registry.

This method determines whether an entity is still active and not yet destroyed in the registry. This is useful for validating entities before performing operations on them, helping to avoid errors related to using invalid or destroyed entity references.

Parameters
entThe entity to check for activity.
Returns
bool Returns true if the entity is active, false otherwise.

◆ allocate()

constexpr auto co_ecs::base_registry::allocate ( ) -> entity
inlineconstexprprotected

◆ archetypes() [1/2]

constexpr auto co_ecs::base_registry::archetypes ( ) const -> const class archetypes&
inlineconstexprnoexcept

Provides access to the immutable list of archetypes in the registry.

This constant method returns a reference to the internal container of archetypes without allowing modifications. It is intended for inspecting or querying the archetypes, suitable for operations that require reading archetype information without altering it.

Returns
const archetypes& A reference to the immutable archetypes container.

◆ archetypes() [2/2]

constexpr auto co_ecs::base_registry::archetypes ( ) -> class archetypes&
inlineconstexprnoexcept

Provides access to the modifiable list of archetypes in the registry.

This method returns a reference to the internal container of archetypes, allowing for modifications to the archetypes. It can be used to add, modify, or inspect the archetypes directly, which represent different entity configurations within the entity-component system.

Returns
archetypes& A reference to the modifiable archetypes container.

◆ clone() [1/2]

entity co_ecs::base_registry::clone ( entity ent)
inlineprotected

◆ clone() [2/2]

entity co_ecs::base_registry::clone ( entity ent,
placeholder_entity placeholder )
inlineprotected

◆ copy() [1/2]

entity co_ecs::base_registry::copy ( entity ent,
base_registry & dest ) const
inlineprotected

◆ copy() [2/2]

entity co_ecs::base_registry::copy ( entity ent,
base_registry & dest,
placeholder_entity placeholder ) const
inlineprotected

◆ create_impl()

template<component... Components>
constexpr auto co_ecs::base_registry::create_impl ( Components &&... args) -> entity
inlineconstexprprotected

◆ destroy()

void co_ecs::base_registry::destroy ( entity ent)
inline

Destroys the given entity.

void destroy(entity ent)
Destroys the given entity.
Definition base_registry.hpp:55
Registry is a container for all our entities and components. Components are stored in continuously in...
Definition registry.hpp:13
detail::handle< struct entity_tag_t > entity
Represents an entity, consisting of an ID and generation.
Definition entity.hpp:13
Parameters
entEntity to destroy

◆ get_impl()

template<component... Args>
static constexpr auto co_ecs::base_registry::get_impl ( auto && self,
entity ent ) -> decltype(auto)
inlinestaticconstexprprotected

◆ has()

template<component... C>
constexpr auto co_ecs::base_registry::has ( entity ent) const -> bool
inlineconstexpr

Checks if the specified entity has all the given components.

Template Parameters
CVariadic template arguments representing the component types to check.
Parameters
entThe entity to check for component existence.
Returns
True if the entity has all specified components, false otherwise.

◆ move() [1/2]

entity co_ecs::base_registry::move ( entity ent,
base_registry & dest )
inlineprotected

◆ move() [2/2]

entity co_ecs::base_registry::move ( entity ent,
base_registry & dest,
placeholder_entity placeholder )
inlineprotected

◆ remove()

template<component C>
constexpr void co_ecs::base_registry::remove ( entity ent)
inlineconstexprprotected

◆ reserve()

constexpr auto co_ecs::base_registry::reserve ( ) -> placeholder_entity
inlineconstexpr

Reserves an entity in a thread-safe manner.

This method reserves an entity ID concurrently and guarantees thread safety. The reserved entity is not fully initialized or published until the sync() method is called. This mechanism allows multiple threads to reserve entities concurrently without interference.

Returns
Returns a reserved entity that will need to be published by calling the sync() method.

◆ set_impl()

template<component C>
constexpr auto co_ecs::base_registry::set_impl ( entity ent) -> std::pair<bool, C*>
inlineconstexprprotected

◆ sync()

constexpr void co_ecs::base_registry::sync ( )
inlineconstexpr

Synchronizes concurently reserved entities.

Postcondition
Once called, all the entities returned by reserve() accessible in the registry.

◆ visit() [1/2]

constexpr void co_ecs::base_registry::visit ( entity ent,
auto && func )
inlineconstexpr

Visit all components of an entity.

Parameters
entEntity to visit.
funcFunction, a visitor, to apply components to.

◆ visit() [2/2]

constexpr void co_ecs::base_registry::visit ( entity ent,
auto && func ) const
inlineconstexpr

Visit all components of an entity (const variant).

Parameters
entEntity to visit.
funcFunction, a visitor, to apply components to.

Friends And Related Symbol Documentation

◆ const_entity_ref

friend class const_entity_ref
friend

◆ entity_ref

friend class entity_ref
friend

Member Data Documentation

◆ _archetypes

class archetypes co_ecs::base_registry::_archetypes
protected

◆ _entity_archetype_map

detail::sparse_map<typename entity::id_t, entity_location> co_ecs::base_registry::_entity_archetype_map
protected

◆ _entity_pool

entity_pool co_ecs::base_registry::_entity_pool
protected

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