EnTT 3.13.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > > Class Template Reference

Non-owning group. More...

#include <group.hpp>

Public Types

using entity_type = underlying_type
 Underlying entity identifier.
 
using size_type = std::size_t
 Unsigned integer type.
 
using common_type = base_type
 Common type among all storage types.
 
using iterator = typename common_type::iterator
 Random access iterator type.
 
using reverse_iterator = typename common_type::reverse_iterator
 Reversed iterator type.
 
using iterable = iterable_adaptor< internal::extended_group_iterator< iterator, owned_t<>, get_t< Get... > > >
 Iterable group type.
 
using handler = internal::group_handler< owned_t<>, get_t< std::remove_const_t< Get >... >, exclude_t< std::remove_const_t< Exclude >... > >
 Group handler type.
 

Public Member Functions

 basic_group () noexcept
 Default constructor to use to create empty, invalid groups.
 
 basic_group (handler &ref) noexcept
 Constructs a group from a set of storage classes.
 
const common_typehandle () const noexcept
 Returns the leading storage of a group.
 
template<typename Type >
auto * storage () const noexcept
 Returns the storage for a given component type, if any.
 
template<std::size_t Index>
auto * storage () const noexcept
 Returns the storage for a given index, if any.
 
size_type size () const noexcept
 Returns the number of entities that are part of the group.
 
size_type capacity () const noexcept
 Returns the number of elements that a group has currently allocated space for.
 
void shrink_to_fit ()
 Requests the removal of unused capacity.
 
bool empty () const noexcept
 Checks whether a group is empty.
 
iterator begin () const noexcept
 Returns an iterator to the first entity of the group.
 
iterator end () const noexcept
 Returns an iterator that is past the last entity of the group.
 
reverse_iterator rbegin () const noexcept
 Returns an iterator to the first entity of the reversed group.
 
reverse_iterator rend () const noexcept
 Returns an iterator that is past the last entity of the reversed group.
 
entity_type front () const noexcept
 Returns the first entity of the group, if any.
 
entity_type back () const noexcept
 Returns the last entity of the group, if any.
 
iterator find (const entity_type entt) const noexcept
 Finds an entity.
 
entity_type operator[] (const size_type pos) const
 Returns the identifier that occupies the given position.
 
 operator bool () const noexcept
 Checks if a group is properly initialized.
 
bool contains (const entity_type entt) const noexcept
 Checks if a group contains an entity.
 
template<typename Type , typename... Other>
decltype(auto) get (const entity_type entt) const
 Returns the components assigned to the given entity.
 
template<std::size_t... Index>
decltype(auto) get (const entity_type entt) const
 Returns the components assigned to the given entity.
 
template<typename Func >
void each (Func func) const
 Iterates entities and components and applies the given function object to them.
 
iterable each () const noexcept
 Returns an iterable object to use to visit a group.
 
template<typename Type , typename... Other, typename Compare , typename Sort = std_sort, typename... Args>
void sort (Compare compare, Sort algo=Sort{}, Args &&...args)
 Sort a group according to the given comparison function.
 
template<std::size_t... Index, typename Compare , typename Sort = std_sort, typename... Args>
void sort (Compare compare, Sort algo=Sort{}, Args &&...args)
 Sort a group according to the given comparison function.
 
template<typename It >
void sort_as (It first, It last) const
 Sort entities according to their order in a range.
 
void sort_as (const common_type &other) const
 Sort entities according to their order in a range.
 

Detailed Description

template<typename... Get, typename... Exclude>
class entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >

Non-owning group.

A non-owning group returns all entities and only the entities that are at least in the given storage. Moreover, it's guaranteed that the entity list is tightly packed in memory for fast iterations.

Important

Iterators aren't invalidated if:

In all other cases, modifying the pools iterated by the group in any way invalidates all the iterators.

Template Parameters
GetTypes of storage observed by the group.
ExcludeTypes of storage used to filter the group.

Definition at line 285 of file group.hpp.

Member Typedef Documentation

◆ common_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::common_type = base_type

Common type among all storage types.

Definition at line 308 of file group.hpp.

◆ entity_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::entity_type = underlying_type

Underlying entity identifier.

Definition at line 304 of file group.hpp.

◆ handler

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::handler = internal::group_handler<owned_t<>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...> >

Group handler type.

Definition at line 316 of file group.hpp.

◆ iterable

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::iterable = iterable_adaptor<internal::extended_group_iterator<iterator, owned_t<>, get_t<Get...> >>

Iterable group type.

Definition at line 314 of file group.hpp.

◆ iterator

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::iterator = typename common_type::iterator

Random access iterator type.

Definition at line 310 of file group.hpp.

◆ reverse_iterator

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::reverse_iterator = typename common_type::reverse_iterator

Reversed iterator type.

Definition at line 312 of file group.hpp.

◆ size_type

template<typename... Get, typename... Exclude>
using entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::size_type = std::size_t

Unsigned integer type.

Definition at line 306 of file group.hpp.

Constructor & Destructor Documentation

◆ basic_group() [1/2]

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::basic_group ( )
inlinenoexcept

Default constructor to use to create empty, invalid groups.

Definition at line 319 of file group.hpp.

◆ basic_group() [2/2]

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::basic_group ( handler ref)
inlinenoexcept

Constructs a group from a set of storage classes.

Parameters
refA reference to a group handler.

Definition at line 326 of file group.hpp.

Member Function Documentation

◆ back()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::back ( ) const
inlinenoexcept

Returns the last entity of the group, if any.

Returns
The last entity of the group if one exists, the null entity otherwise.

Definition at line 451 of file group.hpp.

◆ begin()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::begin ( ) const
inlinenoexcept

Returns an iterator to the first entity of the group.

If the group is empty, the returned iterator will be equal to end().

Returns
An iterator to the first entity of the group.

Definition at line 402 of file group.hpp.

◆ capacity()

template<typename... Get, typename... Exclude>
size_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::capacity ( ) const
inlinenoexcept

Returns the number of elements that a group has currently allocated space for.

Returns
Capacity of the group.

Definition at line 376 of file group.hpp.

◆ contains()

template<typename... Get, typename... Exclude>
bool entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::contains ( const entity_type  entt) const
inlinenoexcept

Checks if a group contains an entity.

Parameters
enttA valid identifier.
Returns
True if the group contains the given entity, false otherwise.

Definition at line 488 of file group.hpp.

◆ each() [1/2]

template<typename... Get, typename... Exclude>
iterable entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::each ( ) const
inlinenoexcept

Returns an iterable object to use to visit a group.

The iterable object returns tuples that contain the current entity and a set of references to its non-empty components. The constness of the components is as requested.

Note
Empty types aren't explicitly instantiated and therefore they are never returned during iterations.
Returns
An iterable object to use to visit the group.

Definition at line 569 of file group.hpp.

◆ each() [2/2]

template<typename... Get, typename... Exclude>
template<typename Func >
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::each ( Func  func) const
inline

Iterates entities and components and applies the given function object to them.

The function object is invoked for each entity. It is provided with the entity itself and a set of references to non-empty components. The constness of the components is as requested.
The signature of the function must be equivalent to one of the following forms:

void(const entity_type, Type &...);
void(Type &...);
underlying_type entity_type
Underlying entity identifier.
Definition group.hpp:304
Note
Empty types aren't explicitly instantiated and therefore they are never returned during iterations.
Template Parameters
FuncType of the function object to invoke.
Parameters
funcA valid function object.

Definition at line 546 of file group.hpp.

◆ empty()

template<typename... Get, typename... Exclude>
bool entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::empty ( ) const
inlinenoexcept

Checks whether a group is empty.

Returns
True if the group is empty, false otherwise.

Definition at line 391 of file group.hpp.

◆ end()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::end ( ) const
inlinenoexcept

Returns an iterator that is past the last entity of the group.

Returns
An iterator to the entity following the last entity of the group.

Definition at line 411 of file group.hpp.

◆ find()

template<typename... Get, typename... Exclude>
iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::find ( const entity_type  entt) const
inlinenoexcept

Finds an entity.

Parameters
enttA valid identifier.
Returns
An iterator to the given entity if it's found, past the end iterator otherwise.

Definition at line 462 of file group.hpp.

◆ front()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::front ( ) const
inlinenoexcept

Returns the first entity of the group, if any.

Returns
The first entity of the group if one exists, the null entity otherwise.

Definition at line 441 of file group.hpp.

◆ get() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type , typename... Other>
decltype(auto) entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::get ( const entity_type  entt) const
inline

Returns the components assigned to the given entity.

Template Parameters
TypeType of the component to get.
OtherOther types of components to get.
Parameters
enttA valid identifier.
Returns
The components assigned to the entity.

Definition at line 500 of file group.hpp.

◆ get() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t... Index>
decltype(auto) entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::get ( const entity_type  entt) const
inline

Returns the components assigned to the given entity.

Template Parameters
IndexIndexes of the components to get.
Parameters
enttA valid identifier.
Returns
The components assigned to the entity.

Definition at line 511 of file group.hpp.

◆ handle()

template<typename... Get, typename... Exclude>
const common_type & entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::handle ( ) const
inlinenoexcept

Returns the leading storage of a group.

Returns
The leading storage of the group.

Definition at line 333 of file group.hpp.

◆ operator bool()

template<typename... Get, typename... Exclude>
entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::operator bool ( ) const
inlineexplicitnoexcept

Checks if a group is properly initialized.

Returns
True if the group is properly initialized, false otherwise.

Definition at line 479 of file group.hpp.

◆ operator[]()

template<typename... Get, typename... Exclude>
entity_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::operator[] ( const size_type  pos) const
inline

Returns the identifier that occupies the given position.

Parameters
posPosition of the element to return.
Returns
The identifier that occupies the given position.

Definition at line 471 of file group.hpp.

◆ rbegin()

template<typename... Get, typename... Exclude>
reverse_iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::rbegin ( ) const
inlinenoexcept

Returns an iterator to the first entity of the reversed group.

If the group is empty, the returned iterator will be equal to rend().

Returns
An iterator to the first entity of the reversed group.

Definition at line 422 of file group.hpp.

◆ rend()

template<typename... Get, typename... Exclude>
reverse_iterator entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::rend ( ) const
inlinenoexcept

Returns an iterator that is past the last entity of the reversed group.

Returns
An iterator to the entity following the last entity of the reversed group.

Definition at line 432 of file group.hpp.

◆ shrink_to_fit()

template<typename... Get, typename... Exclude>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::shrink_to_fit ( )
inline

Requests the removal of unused capacity.

Definition at line 381 of file group.hpp.

◆ size()

template<typename... Get, typename... Exclude>
size_type entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::size ( ) const
inlinenoexcept

Returns the number of entities that are part of the group.

Returns
Number of entities that are part of the group.

Definition at line 367 of file group.hpp.

◆ sort() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type , typename... Other, typename Compare , typename Sort = std_sort, typename... Args>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort ( Compare  compare,
Sort  algo = Sort{},
Args &&...  args 
)
inline

Sort a group according to the given comparison function.

The comparison function object must return true if the first element is less than the second one, false otherwise. The signature of the comparison function should be equivalent to one of the following:

bool(std::tuple<Type &...>, std::tuple<Type &...>);
bool(const Type &..., const Type &...);
bool(const Entity, const Entity);

Where Type are such that they are iterated by the group.
Moreover, the comparison function object shall induce a strict weak ordering on the values.

The sort function object must offer a member function template operator() that accepts three arguments:

  • An iterator to the first element of the range to sort.
  • An iterator past the last element of the range to sort.
  • A comparison function to use to compare the elements.
Template Parameters
TypeOptional type of component to compare.
OtherOther optional types of components to compare.
CompareType of comparison function object.
SortType of sort function object.
ArgsTypes of arguments to forward to the sort function object.
Parameters
compareA valid comparison function object.
algoA valid sort function object.
argsArguments to forward to the sort function object, if any.

Definition at line 608 of file group.hpp.

◆ sort() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t... Index, typename Compare , typename Sort = std_sort, typename... Args>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort ( Compare  compare,
Sort  algo = Sort{},
Args &&...  args 
)
inline

Sort a group according to the given comparison function.

See also
sort
Template Parameters
IndexOptional indexes of components to compare.
CompareType of comparison function object.
SortType of sort function object.
ArgsTypes of arguments to forward to the sort function object.
Parameters
compareA valid comparison function object.
algoA valid sort function object.
argsArguments to forward to the sort function object, if any.

Definition at line 626 of file group.hpp.

◆ sort_as() [1/2]

template<typename... Get, typename... Exclude>
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort_as ( const common_type other) const
inline

Sort entities according to their order in a range.

Parameters
otherThe storage to use to impose the order.

Definition at line 666 of file group.hpp.

◆ sort_as() [2/2]

template<typename... Get, typename... Exclude>
template<typename It >
void entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::sort_as ( It  first,
It  last 
) const
inline

Sort entities according to their order in a range.

The shared pool of entities and thus its order is affected by the changes to each and every pool that it tracks.

Template Parameters
ItType of input iterator.
Parameters
firstAn iterator to the first element of the range of entities.
lastAn iterator past the last element of the range of entities.

Definition at line 656 of file group.hpp.

◆ storage() [1/2]

template<typename... Get, typename... Exclude>
template<typename Type >
auto * entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::storage ( ) const
inlinenoexcept

Returns the storage for a given component type, if any.

Template Parameters
TypeType of component of which to return the storage.
Returns
The storage for the given component type.

Definition at line 343 of file group.hpp.

◆ storage() [2/2]

template<typename... Get, typename... Exclude>
template<std::size_t Index>
auto * entt::basic_group< owned_t<>, get_t< Get... >, exclude_t< Exclude... > >::storage ( ) const
inlinenoexcept

Returns the storage for a given index, if any.

Template Parameters
IndexIndex of the storage to return.
Returns
The storage for the given index.

Definition at line 353 of file group.hpp.


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