EnTT: entt::basic_runtime_view< Type, Allocator > Class Template Reference

EnTT 3.15.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=default
| Default move constructor.
| basic_runtime_view (basic_runtime_view &&other, const allocator_type &allocator)
| Allocator-extended move constructor.
| ~basic_runtime_view ()=default
| Default destructor.
basic_runtime_view & | operator= (const basic_runtime_view &)=default
| Default copy assignment operator.
basic_runtime_view & | operator= (basic_runtime_view &&) noexcept=default
| Default move assignment operator.
void | swap (basic_runtime_view &other) noexcept
| 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_view & | iterate (common_type &base)
| Appends an opaque storage object to a runtime view.
basic_runtime_view & | exclude (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 elements.
iterator | end () const
| Returns an iterator that is past the last entity that has the given elements.
| operator bool () const noexcept
| Checks whether a view is initialized or not.
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 element and uses the smallest set in order to get a performance boost when iterating.

Important

Iterators aren't invalidated if:

- New elements are added to the storage.
- The entity currently pointed is modified (for example, elements are added or removed from it).
- The entity currently pointed is destroyed.

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

Template Parameters

  Type | Common base type.
  Allocator | Type of allocator used to manage memory and elements.

Definition at line 124 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 131 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 137 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 133 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 139 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 135 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 142 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

  allocator | The allocator to use.

Definition at line 149 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

  other | The instance to copy from.
  allocator | The allocator to use.

Definition at line 161 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

  other | The instance to move from.
  allocator | The allocator to use.

Definition at line 173 of file runtime_view.hpp.

## Member Function Documentation

## ◆ begin()

template<typename Type, typename Allocator>

iterator entt::basic_runtime_view< Type, Allocator >::begin | ( |  | ) | const
| inlinenodiscard

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

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

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

Definition at line 257 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 211 of file runtime_view.hpp.

## ◆ contains()

template<typename Type, typename Allocator>

bool entt::basic_runtime_view< Type, Allocator >::contains | ( | const entity_type | entt | ) | const
| inlinenodiscard

Checks if a view contains an entity.

Parameters

  entt | A valid identifier.

Returns
  True if the view contains the given entity, false otherwise.

Definition at line 284 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);
entt::basic_runtime_view::entity_type
typename Type::entity_type entity_type
Underlying entity identifier.
Definition runtime_view.hpp:133

Template Parameters

  Func | Type of the function object to invoke.

Parameters

  func | A valid function object.

Definition at line 305 of file runtime_view.hpp.

## ◆ end()

template<typename Type, typename Allocator>

iterator entt::basic_runtime_view< Type, Allocator >::end | ( |  | ) | const
| inlinenodiscard

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

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

Definition at line 267 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

  base | An opaque reference to a storage object.

Returns
  This runtime view.

Definition at line 236 of file runtime_view.hpp.

## ◆ get_allocator()

template<typename Type, typename Allocator>

allocator_type entt::basic_runtime_view< Type, Allocator >::get_allocator | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the associated allocator.

Returns
  The associated allocator.

Definition at line 206 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

  base | An opaque reference to a storage object.

Returns
  This runtime view.

Definition at line 221 of file runtime_view.hpp.

## ◆ operator bool()

template<typename Type, typename Allocator>

entt::basic_runtime_view< Type, Allocator >::operator bool | ( |  | ) | const
| inlineexplicitnodiscardnoexcept

Checks whether a view is initialized or not.

Returns
  True if the view is initialized, false otherwise.

Definition at line 275 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 runtime view.

## ◆ 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 runtime view.

## ◆ size_hint()

template<typename Type, typename Allocator>

size_type entt::basic_runtime_view< Type, Allocator >::size_hint | ( |  | ) | const
| inlinenodiscard

Estimates the number of entities iterated by the view.

Returns
  Estimated number of entities iterated by the view.

Definition at line 245 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 | ) |
| inlinenoexcept

Exchanges the contents with those of a given view.

Parameters

  other | View to exchange the content with.

Definition at line 196 of file runtime_view.hpp.

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

- src/entt/entity/fwd.hpp
- src/entt/entity/runtime_view.hpp