OpenLexocad  27.1
entt::basic_runtime_view< Entity > Class Template Reference

Runtime view. More...

#include <entt.hpp>

Public Types

using entity_type = Entity
 Underlying entity identifier. More...
 
using size_type = std::size_t
 Unsigned integer type. More...
 
using iterator_type = iterator
 Input iterator type. More...
 

Public Member Functions

size_type size () const ENTT_NOEXCEPT
 Estimates the number of entities that have the given components. More...
 
bool empty () const ENTT_NOEXCEPT
 Checks if the view is definitely empty. More...
 
iterator_type begin () const ENTT_NOEXCEPT
 Returns an iterator to the first entity that has the given components. More...
 
iterator_type end () const ENTT_NOEXCEPT
 Returns an iterator that is past the last entity that has the given components. More...
 
bool contains (const entity_type entt) const ENTT_NOEXCEPT
 Checks if a view contains an entity. More...
 
template<typename Func >
void each (Func func) const
 Iterates entities and applies the given function object to them. More...
 

Friends

class basic_registry< Entity >
 A registry is allowed to create views. More...
 

Detailed Description

template<typename Entity>
class entt::basic_runtime_view< Entity >

Runtime view.

Runtime views iterate over those entities that have at least all the given components in their bags. During initialization, a runtime view looks at the number of entities available for each component and picks up a reference to the smallest set of candidate entities in order to get a performance boost when iterate.
Order of elements during iterations are highly dependent on the order of the underlying data structures. See sparse_set and its specializations for more details.

Important

Iterators aren't invalidated if:

  • New instances of the given components are created and assigned to entities.
  • The entity currently pointed is modified (as an example, if one of the given components is removed from the entity to which the iterator points).
  • The entity currently pointed is destroyed.

In all the other cases, modifying the pools of the given components in any way invalidates all the iterators and using them results in undefined behavior.

Note
Views share references to the underlying data structures of the registry that generated them. Therefore any change to the entities and to the components made by means of the registry are immediately reflected by the views, unless a pool was missing when the view was built (in this case, the view won't have a valid reference and won't be updated accordingly).
Warning
Lifetime of a view must overcome the one of the registry that generated it. In any other case, attempting to use a view results in undefined behavior.
Template Parameters
EntityA valid entity type (see entt_traits for more details).

Member Typedef Documentation

◆ entity_type

template<typename Entity >
using entt::basic_runtime_view< Entity >::entity_type = Entity

Underlying entity identifier.

◆ iterator_type

template<typename Entity >
using entt::basic_runtime_view< Entity >::iterator_type = iterator

Input iterator type.

◆ size_type

template<typename Entity >
using entt::basic_runtime_view< Entity >::size_type = std::size_t

Unsigned integer type.

Member Function Documentation

◆ begin()

template<typename Entity >
iterator_type entt::basic_runtime_view< Entity >::begin ( ) const
inline

Returns an iterator to the first entity that has the given components.

The returned iterator points to the first entity that has the given components. If the view is empty, the returned iterator will be equal to end().

Note
Input iterators stay true to the order imposed to the underlying data structures.
Returns
An iterator to the first entity that has the given components.

◆ contains()

template<typename Entity >
bool entt::basic_runtime_view< Entity >::contains ( const entity_type  entt) const
inline

Checks if a view contains an entity.

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

◆ each()

template<typename Entity >
template<typename Func >
void entt::basic_runtime_view< Entity >::each ( Func  func) const
inline

Iterates entities and applies the given function object to them.

The function object is invoked for each entity. It is provided only with the entity itself. To get the components, users can use the registry with which the view was built.
The signature of the function should be equivalent to the following:

void(const entity_type);
Template Parameters
FuncType of the function object to invoke.
Parameters
funcA valid function object.

◆ empty()

template<typename Entity >
bool entt::basic_runtime_view< Entity >::empty ( ) const
inline

Checks if the view is definitely empty.

Returns
True if the view is definitely empty, false otherwise.

◆ end()

template<typename Entity >
iterator_type entt::basic_runtime_view< Entity >::end ( ) const
inline

Returns an iterator that is past the last entity that has the given components.

The returned iterator points to the entity following the last entity that has the given components. Attempting to dereference the returned iterator results in undefined behavior.

Note
Input iterators stay true to the order imposed to the underlying data structures.
Returns
An iterator to the entity following the last entity that has the given components.

◆ size()

template<typename Entity >
size_type entt::basic_runtime_view< Entity >::size ( ) const
inline

Estimates the number of entities that have the given components.

Returns
Estimated number of entities that have the given components.

Friends And Related Function Documentation

◆ basic_registry< Entity >

template<typename Entity >
friend class basic_registry< Entity >
friend

A registry is allowed to create views.


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