Template Class component_pool

Inheritance Relationships

Base Type

Class Documentation

template<typename component_type>
class legion::core::ecs::component_pool : public legion::core::ecs::component_pool_base

Thread-safe container to store a component family in.

Template Parameters
  • component_type: Type of component.

Public Functions

component_pool() = default
inline component_pool(EcsRegistry *registry, events::EventBus *eventBus)
inline virtual void serialize(cereal::JSONOutputArchive &oarchive, id_type entityId) override
inline virtual void serialize(cereal::BinaryOutputArchive &oarchive, id_type entityId) override
inline virtual void serialize(cereal::JSONInputArchive &iarchive, id_type entityId) override
inline virtual void serialize(cereal::BinaryInputArchive &iarchive, id_type entityId) override
inline async::rw_spinlock &get_lock() const noexcept

Get the rw_spinlock of this container.

inline virtual component_container_base *get_components(const entity_container &entities) const override
inline virtual void get_components(const entity_container &entities, component_container_base &comps) const override
inline virtual void set_components(const entity_container &entities, const component_container_base &comps) override
inline virtual bool has_component(id_type entityId) const override

Thread-safe check for whether an entity has the component.

Parameters
  • entityId: ID of the entity you wish to check for.

inline component_type &get_component(id_type entityId)

Thread unsafe component fetch, use component_pool::get_lock and lock for at least read_only before calling this function.

Parameters

inline const component_type &get_component(id_type entityId) const

Thread unsafe component fetch, use component_pool::get_lock and lock for at least read_only before calling this function.

Parameters

inline virtual void create_component(id_type entityId) override

Creates component in a thread-safe way.

Note

Calls component_type::init if it exists.

Note

Raises the events::component_creation<component_type>> event.

Parameters
  • entityId: ID of entity you wish to add the component to.

inline virtual void create_component(id_type entityId, void *value) override

Creates component in a thread-safe way and initializes it with the given value.

Note

Does NOT call component_type::init.

Note

Raises the events::component_creation<component_type>> event.

Parameters
  • entityId: ID of entity you wish to add the component to.

  • value: Pointer to component_type that has the starting value you require.

inline virtual void destroy_component(id_type entityId) override

Destroys component in a thread-safe way.

Note

Calls component_type::destroy if it exists.

Note

Raises the events::component_destruction<component_type>> event.

Parameters
  • entityId: ID of entity you wish to remove the component from.

inline virtual void clone_component(id_type dst, id_type src) override

clones a component from a source to a destination entity