EnTT 4.0.0
Loading...
Searching...
No Matches
entt::basic_handle< Registry, Scope > Class Template Reference

Non-owning handle to an entity. More...

#include <handle.hpp>

Public Types

using registry_type = Registry
 Type of registry accepted by the handle.
using entity_type = traits_type::value_type
 Underlying entity identifier.
using version_type = traits_type::version_type
 Underlying version type.
using size_type = stl::size_t
 Unsigned integer type.
using iterable = iterable_adaptor<internal::handle_storage_iterator<typename decltype(stl::declval<registry_type>().storage())::iterator>>
 Iterable handle type.

Public Member Functions

 basic_handle () noexcept
 Constructs an invalid handle.
 basic_handle (registry_type &ref, entity_type value) noexcept
 Constructs a handle from a given registry and entity.
iterable storage () const noexcept
 Returns an iterable object to use to visit a handle.
 operator bool () const noexcept
 Checks if a handle refers to a valid registry and entity.
bool valid () const
 Checks if a handle refers to a valid registry and entity.
registry_typeregistry () const noexcept
 Returns a pointer to the underlying registry, if any.
entity_type entity () const noexcept
 Returns the entity associated with a handle.
 operator entity_type () const noexcept
 Returns the entity associated with a handle.
void destroy ()
 Destroys the entity associated with a handle.
void destroy (const version_type version)
 Destroys the entity associated with a handle.
template<typename Type, typename... Args>
decltype(auto) emplace (Args &&...args) const
 Assigns the given element to a handle.
template<typename Type, typename... Args>
decltype(auto) emplace_or_replace (Args &&...args) const
 Assigns or replaces the given element for a handle.
template<typename Type, typename... Func>
decltype(auto) patch (Func &&...func) const
 Patches the given element for a handle.
template<typename Type, typename... Args>
decltype(auto) replace (Args &&...args) const
 Replaces the given element for a handle.
template<typename... Type>
size_type remove () const
 Removes the given elements from a handle.
template<typename... Type>
void erase () const
 Erases the given elements from a handle.
template<typename... Type>
decltype(auto) all_of () const
 Checks if a handle has all the given elements.
template<typename... Type>
decltype(auto) any_of () const
 Checks if a handle has at least one of the given elements.
template<typename... Type>
decltype(auto) get () const
 Returns references to the given elements for a handle.
template<typename Type, typename... Args>
decltype(auto) get_or_emplace (Args &&...args) const
 Returns a reference to the given element for a handle.
template<typename... Type>
auto try_get () const
 Returns pointers to the given elements for a handle.
bool orphan () const
 Checks if a handle has elements assigned.
template<typename... Other>
bool operator== (const basic_handle< Other... > &other) const noexcept
 Compares two handles.
constexpr bool operator== (const null_t other) const noexcept
 Compares a handle with the null object.
template<typename Other, typename... Args>
 operator basic_handle< Other, Args... > () const noexcept
 Returns a const handle from a non-const one.

Detailed Description

template<typename Registry, typename... Scope>
class entt::basic_handle< Registry, Scope >

Non-owning handle to an entity.

Tiny wrapper around a registry and an entity.

Template Parameters
RegistryBasic registry type.
ScopeTypes to which to restrict the scope of a handle.

Definition at line 90 of file handle.hpp.

Member Typedef Documentation

◆ entity_type

template<typename Registry, typename... Scope>
using entt::basic_handle< Registry, Scope >::entity_type = traits_type::value_type

Underlying entity identifier.

Definition at line 102 of file handle.hpp.

◆ iterable

template<typename Registry, typename... Scope>
using entt::basic_handle< Registry, Scope >::iterable = iterable_adaptor<internal::handle_storage_iterator<typename decltype(stl::declval<registry_type>().storage())::iterator>>

Iterable handle type.

Definition at line 108 of file handle.hpp.

◆ registry_type

template<typename Registry, typename... Scope>
using entt::basic_handle< Registry, Scope >::registry_type = Registry

Type of registry accepted by the handle.

Definition at line 100 of file handle.hpp.

◆ size_type

template<typename Registry, typename... Scope>
using entt::basic_handle< Registry, Scope >::size_type = stl::size_t

Unsigned integer type.

Definition at line 106 of file handle.hpp.

◆ version_type

template<typename Registry, typename... Scope>
using entt::basic_handle< Registry, Scope >::version_type = traits_type::version_type

Underlying version type.

Definition at line 104 of file handle.hpp.

Constructor & Destructor Documentation

◆ basic_handle() [1/2]

template<typename Registry, typename... Scope>
entt::basic_handle< Registry, Scope >::basic_handle ( )
inlinenoexcept

Constructs an invalid handle.

Definition at line 111 of file handle.hpp.

◆ basic_handle() [2/2]

template<typename Registry, typename... Scope>
entt::basic_handle< Registry, Scope >::basic_handle ( registry_type & ref,
entity_type value )
inlinenoexcept

Constructs a handle from a given registry and entity.

Parameters
refAn instance of the registry class.
valueA valid identifier.

Definition at line 120 of file handle.hpp.

Member Function Documentation

◆ all_of()

template<typename Registry, typename... Scope>
template<typename... Type>
decltype(auto) entt::basic_handle< Registry, Scope >::all_of ( ) const
inlinenodiscard

Checks if a handle has all the given elements.

Template Parameters
TypeElements for which to perform the check.
Returns
True if the handle has all the elements, false otherwise.

Definition at line 268 of file handle.hpp.

◆ any_of()

template<typename Registry, typename... Scope>
template<typename... Type>
decltype(auto) entt::basic_handle< Registry, Scope >::any_of ( ) const
inlinenodiscard

Checks if a handle has at least one of the given elements.

Template Parameters
TypeElements for which to perform the check.
Returns
True if the handle has at least one of the given elements, false otherwise.

Definition at line 279 of file handle.hpp.

◆ destroy() [1/2]

template<typename Registry, typename... Scope>
void entt::basic_handle< Registry, Scope >::destroy ( )
inline

Destroys the entity associated with a handle.

Definition at line 175 of file handle.hpp.

◆ destroy() [2/2]

template<typename Registry, typename... Scope>
void entt::basic_handle< Registry, Scope >::destroy ( const version_type version)
inline

Destroys the entity associated with a handle.

Parameters
versionA desired version upon destruction.

Definition at line 183 of file handle.hpp.

◆ emplace()

template<typename Registry, typename... Scope>
template<typename Type, typename... Args>
decltype(auto) entt::basic_handle< Registry, Scope >::emplace ( Args &&... args) const
inline

Assigns the given element to a handle.

Template Parameters
TypeType of element to create.
ArgsTypes of arguments to use to construct the element.
Parameters
argsParameters to use to initialize the element.
Returns
A reference to the newly created element.

Definition at line 196 of file handle.hpp.

◆ emplace_or_replace()

template<typename Registry, typename... Scope>
template<typename Type, typename... Args>
decltype(auto) entt::basic_handle< Registry, Scope >::emplace_or_replace ( Args &&... args) const
inline

Assigns or replaces the given element for a handle.

Template Parameters
TypeType of element to assign or replace.
ArgsTypes of arguments to use to construct the element.
Parameters
argsParameters to use to initialize the element.
Returns
A reference to the newly created element.

Definition at line 209 of file handle.hpp.

◆ entity()

template<typename Registry, typename... Scope>
entity_type entt::basic_handle< Registry, Scope >::entity ( ) const
inlinenodiscardnoexcept

Returns the entity associated with a handle.

Returns
The entity associated with the handle.

Definition at line 165 of file handle.hpp.

◆ erase()

template<typename Registry, typename... Scope>
template<typename... Type>
void entt::basic_handle< Registry, Scope >::erase ( ) const
inline

Erases the given elements from a handle.

Template Parameters
TypeTypes of elements to erase.

Definition at line 257 of file handle.hpp.

◆ get()

template<typename Registry, typename... Scope>
template<typename... Type>
decltype(auto) entt::basic_handle< Registry, Scope >::get ( ) const
inlinenodiscard

Returns references to the given elements for a handle.

Template Parameters
TypeTypes of elements to get.
Returns
References to the elements owned by the handle.

Definition at line 289 of file handle.hpp.

◆ get_or_emplace()

template<typename Registry, typename... Scope>
template<typename Type, typename... Args>
decltype(auto) entt::basic_handle< Registry, Scope >::get_or_emplace ( Args &&... args) const
inlinenodiscard

Returns a reference to the given element for a handle.

Template Parameters
TypeType of element to get.
ArgsTypes of arguments to use to construct the element.
Parameters
argsParameters to use to initialize the element.
Returns
Reference to the element owned by the handle.

Definition at line 302 of file handle.hpp.

◆ operator basic_handle< Other, Args... >()

template<typename Registry, typename... Scope>
template<typename Other, typename... Args>
entt::basic_handle< Registry, Scope >::operator basic_handle< Other, Args... > ( ) const
inlinenoexcept

Returns a const handle from a non-const one.

Template Parameters
OtherA valid entity type.
ArgsScope of the handle to construct.
Returns
A const handle referring to the same registry and the same entity.

Definition at line 355 of file handle.hpp.

◆ operator bool()

template<typename Registry, typename... Scope>
entt::basic_handle< Registry, Scope >::operator bool ( ) const
inlineexplicitnodiscardnoexcept

Checks if a handle refers to a valid registry and entity.

Returns
True if the handle refers to a valid registry and entity, false otherwise.

Definition at line 140 of file handle.hpp.

◆ operator entity_type()

template<typename Registry, typename... Scope>
entt::basic_handle< Registry, Scope >::operator entity_type ( ) const
inlinenodiscardnoexcept

Returns the entity associated with a handle.

Returns
The entity associated with the handle.

Definition at line 170 of file handle.hpp.

◆ operator==() [1/2]

template<typename Registry, typename... Scope>
template<typename... Other>
bool entt::basic_handle< Registry, Scope >::operator== ( const basic_handle< Other... > & other) const
inlinenodiscardnoexcept

Compares two handles.

Template Parameters
OtherScope of the other handle.
Parameters
otherA valid handle.
Returns
True if both handles refer to the same registry and the same entity, false otherwise.

Definition at line 334 of file handle.hpp.

◆ operator==() [2/2]

template<typename Registry, typename... Scope>
bool entt::basic_handle< Registry, Scope >::operator== ( const null_t other) const
inlinenodiscardconstexprnoexcept

Compares a handle with the null object.

Parameters
otherA null object yet to be converted.
Returns
False if the two elements differ, true otherwise.

Definition at line 343 of file handle.hpp.

◆ orphan()

template<typename Registry, typename... Scope>
bool entt::basic_handle< Registry, Scope >::orphan ( ) const
inlinenodiscard

Checks if a handle has elements assigned.

Returns
True if the handle has no elements assigned, false otherwise.

Definition at line 322 of file handle.hpp.

◆ patch()

template<typename Registry, typename... Scope>
template<typename Type, typename... Func>
decltype(auto) entt::basic_handle< Registry, Scope >::patch ( Func &&... func) const
inline

Patches the given element for a handle.

Template Parameters
TypeType of element to patch.
FuncTypes of the function objects to invoke.
Parameters
funcValid function objects.
Returns
A reference to the patched element.

Definition at line 222 of file handle.hpp.

◆ registry()

template<typename Registry, typename... Scope>
registry_type * entt::basic_handle< Registry, Scope >::registry ( ) const
inlinenodiscardnoexcept

Returns a pointer to the underlying registry, if any.

Returns
A pointer to the underlying registry, if any.

Definition at line 157 of file handle.hpp.

◆ remove()

template<typename Registry, typename... Scope>
template<typename... Type>
size_type entt::basic_handle< Registry, Scope >::remove ( ) const
inline

Removes the given elements from a handle.

Template Parameters
TypeTypes of elements to remove.
Returns
The number of elements actually removed.

Definition at line 247 of file handle.hpp.

◆ replace()

template<typename Registry, typename... Scope>
template<typename Type, typename... Args>
decltype(auto) entt::basic_handle< Registry, Scope >::replace ( Args &&... args) const
inline

Replaces the given element for a handle.

Template Parameters
TypeType of element to replace.
ArgsTypes of arguments to use to construct the element.
Parameters
argsParameters to use to initialize the element.
Returns
A reference to the element being replaced.

Definition at line 235 of file handle.hpp.

◆ storage()

template<typename Registry, typename... Scope>
iterable entt::basic_handle< Registry, Scope >::storage ( ) const
inlinenodiscardnoexcept

Returns an iterable object to use to visit a handle.

The iterable object returns a pair that contains the name and a reference to the current storage.
Returned storage are those that contain the entity associated with the handle.

Returns
An iterable object to use to visit the handle.

Definition at line 134 of file handle.hpp.

◆ try_get()

template<typename Registry, typename... Scope>
template<typename... Type>
auto entt::basic_handle< Registry, Scope >::try_get ( ) const
inlinenodiscard

Returns pointers to the given elements for a handle.

Template Parameters
TypeTypes of elements to get.
Returns
Pointers to the elements owned by the handle.

Definition at line 313 of file handle.hpp.

◆ valid()

template<typename Registry, typename... Scope>
bool entt::basic_handle< Registry, Scope >::valid ( ) const
inlinenodiscard

Checks if a handle refers to a valid registry and entity.

Returns
True if the handle refers to a valid registry and entity, false otherwise.

Definition at line 149 of file handle.hpp.


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