EnTT 3.13.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::basic_runtime_view< Type, Allocator > Class Template Reference

Generic runtime view. More...

#include <runtime_view.hpp>

Public Types

using allocator_type = Allocator
 Allocator type.
 
using entity_type = typename Type::entity_type
 Underlying entity identifier.
 
using size_type = std::size_t
 Unsigned integer type.
 
using common_type = Type
 Common type among all storage types.
 
using iterator = internal::runtime_view_iterator< common_type >
 Bidirectional iterator type.
 

Public Member Functions

 basic_runtime_view () noexcept
 Default constructor to use to create empty, invalid views.
 
 basic_runtime_view (const allocator_type &allocator)
 Constructs an empty, invalid view with a given allocator.
 
 basic_runtime_view (const basic_runtime_view &)=default
 Default copy constructor.
 
 basic_runtime_view (const basic_runtime_view &other, const allocator_type &allocator)
 Allocator-extended copy constructor.
 
 basic_runtime_view (basic_runtime_view &&) noexcept(std::is_nothrow_move_constructible_v< container_type >)=default
 Default move constructor.
 
 basic_runtime_view (basic_runtime_view &&other, const allocator_type &allocator)
 Allocator-extended move constructor.
 
basic_runtime_viewoperator= (const basic_runtime_view &)=default
 Default copy assignment operator.
 
basic_runtime_viewoperator= (basic_runtime_view &&) noexcept(std::is_nothrow_move_assignable_v< container_type >)=default
 Default move assignment operator.
 
void swap (basic_runtime_view &other)
 Exchanges the contents with those of a given view.
 
constexpr allocator_type get_allocator () const noexcept
 Returns the associated allocator.
 
void clear ()
 Clears the view.
 
basic_runtime_viewiterate (common_type &base)
 Appends an opaque storage object to a runtime view.
 
basic_runtime_viewexclude (common_type &base)
 Adds an opaque storage object as a filter of a runtime view.
 
size_type size_hint () const
 Estimates the number of entities iterated by the view.
 
iterator begin () const
 Returns an iterator to the first entity that has the given components.
 
iterator end () const
 Returns an iterator that is past the last entity that has the given components.
 
bool contains (const entity_type entt) const
 Checks if a view contains an entity.
 
template<typename Func >
void each (Func func) const
 Iterates entities and applies the given function object to them.
 

Detailed Description

template<typename Type, typename Allocator>
class entt::basic_runtime_view< Type, Allocator >

Generic runtime view.

Runtime views iterate over those entities that are at least in the given storage. During initialization, a runtime view looks at the number of entities available for each component and uses the smallest set in order to get a performance boost when iterating.

Important

Iterators aren't invalidated if:

In all other cases, modifying the storage iterated by the view in any way invalidates all the iterators.

Template Parameters
TypeCommon base type.
AllocatorType of allocator used to manage memory and elements.

Definition at line 120 of file runtime_view.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Type , typename Allocator >
using entt::basic_runtime_view< Type, Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 127 of file runtime_view.hpp.

◆ common_type

template<typename Type , typename Allocator >
using entt::basic_runtime_view< Type, Allocator >::common_type = Type

Common type among all storage types.

Definition at line 133 of file runtime_view.hpp.

◆ entity_type

template<typename Type , typename Allocator >
using entt::basic_runtime_view< Type, Allocator >::entity_type = typename Type::entity_type

Underlying entity identifier.

Definition at line 129 of file runtime_view.hpp.

◆ iterator

template<typename Type , typename Allocator >
using entt::basic_runtime_view< Type, Allocator >::iterator = internal::runtime_view_iterator<common_type>

Bidirectional iterator type.

Definition at line 135 of file runtime_view.hpp.

◆ size_type

template<typename Type , typename Allocator >
using entt::basic_runtime_view< Type, Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 131 of file runtime_view.hpp.

Constructor & Destructor Documentation

◆ basic_runtime_view() [1/4]

template<typename Type , typename Allocator >
entt::basic_runtime_view< Type, Allocator >::basic_runtime_view ( )
inlinenoexcept

Default constructor to use to create empty, invalid views.

Definition at line 138 of file runtime_view.hpp.

◆ basic_runtime_view() [2/4]

template<typename Type , typename Allocator >
entt::basic_runtime_view< Type, Allocator >::basic_runtime_view ( const allocator_type allocator)
inlineexplicit

Constructs an empty, invalid view with a given allocator.

Parameters
allocatorThe allocator to use.

Definition at line 145 of file runtime_view.hpp.

◆ basic_runtime_view() [3/4]

template<typename Type , typename Allocator >
entt::basic_runtime_view< Type, Allocator >::basic_runtime_view ( const basic_runtime_view< Type, Allocator > &  other,
const allocator_type allocator 
)
inline

Allocator-extended copy constructor.

Parameters
otherThe instance to copy from.
allocatorThe allocator to use.

Definition at line 157 of file runtime_view.hpp.

◆ basic_runtime_view() [4/4]

template<typename Type , typename Allocator >
entt::basic_runtime_view< Type, Allocator >::basic_runtime_view ( basic_runtime_view< Type, Allocator > &&  other,
const allocator_type allocator 
)
inline

Allocator-extended move constructor.

Parameters
otherThe instance to move from.
allocatorThe allocator to use.

Definition at line 169 of file runtime_view.hpp.

Member Function Documentation

◆ begin()

template<typename Type , typename Allocator >
iterator entt::basic_runtime_view< Type, Allocator >::begin ( ) const
inline

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

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

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

Definition at line 250 of file runtime_view.hpp.

◆ clear()

template<typename Type , typename Allocator >
void entt::basic_runtime_view< Type, Allocator >::clear ( )
inline

Clears the view.

Definition at line 204 of file runtime_view.hpp.

◆ contains()

template<typename Type , typename Allocator >
bool entt::basic_runtime_view< Type, Allocator >::contains ( const entity_type  entt) const
inline

Checks if a view contains an entity.

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

Definition at line 269 of file runtime_view.hpp.

◆ each()

template<typename Type , typename Allocator >
template<typename Func >
void entt::basic_runtime_view< Type, Allocator >::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.
The signature of the function should be equivalent to the following:

void(const entity_type);
typename Type::entity_type entity_type
Underlying entity identifier.
Template Parameters
FuncType of the function object to invoke.
Parameters
funcA valid function object.

Definition at line 290 of file runtime_view.hpp.

◆ end()

template<typename Type , typename Allocator >
iterator entt::basic_runtime_view< Type, Allocator >::end ( ) const
inline

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

Returns
An iterator to the entity following the last entity that has the given components.

Definition at line 260 of file runtime_view.hpp.

◆ exclude()

template<typename Type , typename Allocator >
basic_runtime_view & entt::basic_runtime_view< Type, Allocator >::exclude ( common_type base)
inline

Adds an opaque storage object as a filter of a runtime view.

Parameters
baseAn opaque reference to a storage object.
Returns
This runtime view.

Definition at line 229 of file runtime_view.hpp.

◆ get_allocator()

template<typename Type , typename Allocator >
constexpr allocator_type entt::basic_runtime_view< Type, Allocator >::get_allocator ( ) const
inlineconstexprnoexcept

Returns the associated allocator.

Returns
The associated allocator.

Definition at line 199 of file runtime_view.hpp.

◆ iterate()

template<typename Type , typename Allocator >
basic_runtime_view & entt::basic_runtime_view< Type, Allocator >::iterate ( common_type base)
inline

Appends an opaque storage object to a runtime view.

Parameters
baseAn opaque reference to a storage object.
Returns
This runtime view.

Definition at line 214 of file runtime_view.hpp.

◆ operator=() [1/2]

template<typename Type , typename Allocator >
basic_runtime_view & entt::basic_runtime_view< Type, Allocator >::operator= ( basic_runtime_view< Type, Allocator > &&  )
defaultnoexcept

Default move assignment operator.

Returns
This container.

◆ operator=() [2/2]

template<typename Type , typename Allocator >
basic_runtime_view & entt::basic_runtime_view< Type, Allocator >::operator= ( const basic_runtime_view< Type, Allocator > &  )
default

Default copy assignment operator.

Returns
This container.

◆ size_hint()

template<typename Type , typename Allocator >
size_type entt::basic_runtime_view< Type, Allocator >::size_hint ( ) const
inline

Estimates the number of entities iterated by the view.

Returns
Estimated number of entities iterated by the view.

Definition at line 238 of file runtime_view.hpp.

◆ swap()

template<typename Type , typename Allocator >
void entt::basic_runtime_view< Type, Allocator >::swap ( basic_runtime_view< Type, Allocator > &  other)
inline

Exchanges the contents with those of a given view.

Parameters
otherView to exchange the content with.

Definition at line 189 of file runtime_view.hpp.


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