GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::execution::Entities< ComponentsAndExclusions > Class Template Reference

View of entities in an EntityRegistry that have all of the required components and none of the excluded components specified in a list of types. More...

#include <GREM/execution/EntityRegistry.hpp>

Public Types

using MutableComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::MutableComponents...>
 List of non-const components required by the range, provided as a meta::TypeList.
using ImmutableComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::ImmutableComponents...>
 List of const components required by the range, provided as a meta::TypeList.
using IncludedComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::IncludedComponents...>
 List of components required by the range, provided as a meta::TypeList.
using ExcludedComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::ExcludedComponents...>
 List of components excluded by the range, provided as a meta::TypeList.
using iterator = detail::MultiComponentIterator<IncludedComponents, ExcludedComponents>
using sentinel = detail::MultiComponentSentinel
using value_type = typename iterator::value_type
using reference = typename iterator::reference
using size_type = size_t
using difference_type = ptrdiff_t

Public Member Functions

GREM_ALWAYS_INLINE constexpr Entities () noexcept=default
 Construct an empty entity range.
GREM_ALWAYS_INLINE constexpr Entities (const iterator &first, const iterator &last) noexcept
 Construct an entity subrange from an iterator pair.
GREM_ALWAYS_INLINE constexpr iterator begin () const noexcept
GREM_ALWAYS_INLINE constexpr sentinel end () const noexcept
GREM_ALWAYS_INLINE constexpr size_type getCandidateCount () const noexcept
 Get an upper bound estimate on the number of entities in the range.
GREM_ALWAYS_INLINE constexpr bool containsEntity (EntityID id) const
 Check if the range contains a specific entity.
GREM_ALWAYS_INLINE constexpr reference operator[] (EntityID id) const
template<component T>
GREM_ALWAYS_INLINE bool hasComponent (EntityID id) const noexcept
 Check if the range contains a specific entity with a specific component.
template<component T>
GREM_ALWAYS_INLINE auto & getComponent (EntityID id) const
 Get a specific component of a specific entity in the range.
template<component T, typename U>
GREM_ALWAYS_INLINE auto getComponentOr (EntityID id, U &&defaultValue) const
 Get a specific component of a specific entity in the range, or a default value in case the entity doesn't exist or doesn't have the specified component.
template<component T>
GREM_ALWAYS_INLINE auto * findComponent (EntityID id) const noexcept
 Try to get a specific component of a specific entity in the range.
GREM_ALWAYS_INLINE EntityID getEntityIDAtEntityIndexUnsafe (EntityID::Index slotIndex) const
 Get the entity handle of the entity in a specific slot of the underlying EntityRegistry.
template<component T>
GREM_ALWAYS_INLINE auto & getComponentAtEntityIndexUnsafe (EntityID::Index slotIndex) const
 Get a specific component of the entity in a specific slot of the underlying EntityRegistry.

Friends

template<typename... KnownComponents>
class EntityRegistry
 Entity registry used by a Simulation.

Detailed Description

template<typename... ComponentsAndExclusions>
class grem::execution::Entities< ComponentsAndExclusions >

View of entities in an EntityRegistry that have all of the required components and none of the excluded components specified in a list of types.

Template Parameters
ComponentsAndExclusionscomponent and component exclusion types (e.g. Exclude<Component>) that specify which entities are part of the range.

Member Typedef Documentation

◆ MutableComponents

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::MutableComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::MutableComponents...>

List of non-const components required by the range, provided as a meta::TypeList.

◆ ImmutableComponents

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::ImmutableComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::ImmutableComponents...>

List of const components required by the range, provided as a meta::TypeList.

◆ IncludedComponents

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::IncludedComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::IncludedComponents...>

List of components required by the range, provided as a meta::TypeList.

◆ ExcludedComponents

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::ExcludedComponents = meta::type_list_concat_t<typename detail::entities_extract_components<ComponentsAndExclusions>::ExcludedComponents...>

List of components excluded by the range, provided as a meta::TypeList.

◆ iterator

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::iterator = detail::MultiComponentIterator<IncludedComponents, ExcludedComponents>

◆ sentinel

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::sentinel = detail::MultiComponentSentinel

◆ value_type

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::value_type = typename iterator::value_type

◆ reference

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::reference = typename iterator::reference

◆ size_type

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::size_type = size_t

◆ difference_type

template<typename... ComponentsAndExclusions>
using grem::execution::Entities< ComponentsAndExclusions >::difference_type = ptrdiff_t

Constructor & Destructor Documentation

◆ Entities() [1/2]

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr grem::execution::Entities< ComponentsAndExclusions >::Entities ( )
constexprdefaultnoexcept

Construct an empty entity range.

◆ Entities() [2/2]

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr grem::execution::Entities< ComponentsAndExclusions >::Entities ( const iterator & first,
const iterator & last )
inlineconstexprnoexcept

Construct an entity subrange from an iterator pair.

Parameters
firstbegin iterator of the subrange.
lastpast-the-end iterator of the subrange.
Warning
The subrange [first, last) must form a valid range.

Member Function Documentation

◆ begin()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr iterator grem::execution::Entities< ComponentsAndExclusions >::begin ( ) const
inlinenodiscardconstexprnoexcept

◆ end()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr sentinel grem::execution::Entities< ComponentsAndExclusions >::end ( ) const
inlinenodiscardconstexprnoexcept

◆ getCandidateCount()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr size_type grem::execution::Entities< ComponentsAndExclusions >::getCandidateCount ( ) const
inlinenodiscardconstexprnoexcept

Get an upper bound estimate on the number of entities in the range.

Returns
a number greater than or equal to std::distance(begin(), end()).

◆ containsEntity()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr bool grem::execution::Entities< ComponentsAndExclusions >::containsEntity ( EntityID id) const
inlinenodiscardconstexpr

Check if the range contains a specific entity.

Parameters
identity handle to check.
Returns
true if the given handle corresponds to a valid entity in this range, false otherwise.

◆ operator[]()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE constexpr reference grem::execution::Entities< ComponentsAndExclusions >::operator[] ( EntityID id) const
inlinenodiscardconstexpr

◆ hasComponent()

template<typename... ComponentsAndExclusions>
template<component T>
GREM_ALWAYS_INLINE bool grem::execution::Entities< ComponentsAndExclusions >::hasComponent ( EntityID id) const
inlinenodiscardnoexcept

Check if the range contains a specific entity with a specific component.

Template Parameters
Tcomponent type to check for. Must be one of the component types required by this entity range.
Parameters
identity handle to check.
Returns
true if the given handle corresponds to a valid entity in this range that has the specified component, false otherwise.

◆ getComponent()

template<typename... ComponentsAndExclusions>
template<component T>
GREM_ALWAYS_INLINE auto & grem::execution::Entities< ComponentsAndExclusions >::getComponent ( EntityID id) const
inlinenodiscard

Get a specific component of a specific entity in the range.

Template Parameters
Tcomponent type to get. Must be one of the component types required by this entity range.
Parameters
identity handle of the entity to get the component from.
Returns
a reference to the specified component of the specified entity.
Exceptions
std::out_of_rangeif the given handle does not correspond to a valid entity in this range that has the specified component.

◆ getComponentOr()

template<typename... ComponentsAndExclusions>
template<component T, typename U>
GREM_ALWAYS_INLINE auto grem::execution::Entities< ComponentsAndExclusions >::getComponentOr ( EntityID id,
U && defaultValue ) const
inlinenodiscard

Get a specific component of a specific entity in the range, or a default value in case the entity doesn't exist or doesn't have the specified component.

Template Parameters
Tcomponent type to get. Must be one of the component types required by this entity range.
Parameters
identity handle of the entity to get the component from.
defaultValuedefault value to return in case the given handle does not correspond to a valid entity with the specified component.
Returns
a copy of the specified component of the specified entity, or the specified default value if the given handle does not correspond to a valid entity in this range that has the specified component.

◆ findComponent()

template<typename... ComponentsAndExclusions>
template<component T>
GREM_ALWAYS_INLINE auto * grem::execution::Entities< ComponentsAndExclusions >::findComponent ( EntityID id) const
inlinenodiscardnoexcept

Try to get a specific component of a specific entity in the range.

Template Parameters
Tcomponent type to get. Must be one of the component types required by this entity range.
Parameters
identity handle of the entity to get the component from.
Returns
a pointer to the specified component of the specified entity, or nullptr if the given handle does not correspond to a valid entity in this range that has the specified component.

◆ getEntityIDAtEntityIndexUnsafe()

template<typename... ComponentsAndExclusions>
GREM_ALWAYS_INLINE EntityID grem::execution::Entities< ComponentsAndExclusions >::getEntityIDAtEntityIndexUnsafe ( EntityID::Index slotIndex) const
inlinenodiscard

Get the entity handle of the entity in a specific slot of the underlying EntityRegistry.

Parameters
slotIndexindex of the entity slot in the underlying EntityRegistry to get the entity handle of. Must be a valid slot index corresponding to an entity that is currently valid, e.g. the result of a previous call to id.getIndex() on a valid entity handle id that has not since been invalidated.
Returns
the entity handle of the entity in the specified slot.

◆ getComponentAtEntityIndexUnsafe()

template<typename... ComponentsAndExclusions>
template<component T>
GREM_ALWAYS_INLINE auto & grem::execution::Entities< ComponentsAndExclusions >::getComponentAtEntityIndexUnsafe ( EntityID::Index slotIndex) const
inlinenodiscard

Get a specific component of the entity in a specific slot of the underlying EntityRegistry.

Template Parameters
Tcomponent type to get. Must be one of the component types required by this entity range.
Parameters
slotIndexindex of the entity slot in the underlying EntityRegistry to get the entity handle of. Must be a valid slot index corresponding to an entity that is currently valid and has the specified component, e.g. the result of a previous call to id.getIndex() on a valid entity handle id that is known to have the specified component, and has not since been invalidated.
Returns
a reference to the specified component of the entity in the specified slot.

◆ EntityRegistry

template<typename... ComponentsAndExclusions>
template<typename... KnownComponents>
friend class EntityRegistry
friend

Entity registry used by a Simulation.

Template Parameters
Nnumber of dimensions of the world space (must be 2 or 3).

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