EnTT  3.10.0
Public Types | Public Member Functions | List of all members
entt::basic_handle< Entity, Type > Struct Template Reference

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

#include <handle.hpp>

Public Types

using registry_type = constness_as_t< basic_registry< std::remove_const_t< Entity > >, Entity >
 Type of registry accepted by the handle.
 
using entity_type = typename registry_type::entity_type
 Underlying entity identifier.
 
using version_type = typename registry_type::version_type
 Underlying version type.
 
using size_type = typename registry_type::size_type
 Unsigned integer type.
 

Public Member Functions

 basic_handle ()
 Constructs an invalid handle.
 
 basic_handle (registry_type &ref, entity_type value)
 Constructs a handle from a given registry and entity. More...
 
template<typename Other , typename... Args>
 operator basic_handle< Other, Args... > () const
 Constructs a const handle from a non-const one. More...
 
 operator entity_type () const
 Converts a handle to its underlying entity. More...
 
 operator bool () const
 Checks if a handle refers to non-null registry pointer and entity. More...
 
bool valid () const
 Checks if a handle refers to a valid entity or not. More...
 
registry_typeregistry () const
 Returns a pointer to the underlying registry, if any. More...
 
entity_type entity () const
 Returns the entity associated with a handle. More...
 
void destroy ()
 Destroys the entity associated with a handle. More...
 
void destroy (const version_type version)
 Destroys the entity associated with a handle. More...
 
template<typename Component , typename... Args>
decltype(auto) emplace (Args &&...args) const
 Assigns the given component to a handle. More...
 
template<typename Component , typename... Args>
decltype(auto) emplace_or_replace (Args &&...args) const
 Assigns or replaces the given component for a handle. More...
 
template<typename Component , typename... Func>
decltype(auto) patch (Func &&...func) const
 Patches the given component for a handle. More...
 
template<typename Component , typename... Args>
decltype(auto) replace (Args &&...args) const
 Replaces the given component for a handle. More...
 
template<typename... Component>
size_type remove () const
 Removes the given components from a handle. More...
 
template<typename... Component>
void erase () const
 Erases the given components from a handle. More...
 
template<typename... Component>
decltype(auto) all_of () const
 Checks if a handle has all the given components. More...
 
template<typename... Component>
decltype(auto) any_of () const
 Checks if a handle has at least one of the given components. More...
 
template<typename... Component>
decltype(auto) get () const
 Returns references to the given components for a handle. More...
 
template<typename Component , typename... Args>
decltype(auto) get_or_emplace (Args &&...args) const
 Returns a reference to the given component for a handle. More...
 
template<typename... Component>
auto try_get () const
 Returns pointers to the given components for a handle. More...
 
bool orphan () const
 Checks if a handle has components assigned. More...
 
template<typename Func >
void visit (Func &&func) const
 Visits a handle and returns the pools for its components. More...
 

Detailed Description

template<typename Entity, typename... Type>
struct entt::basic_handle< Entity, Type >

Non-owning handle to an entity.

Tiny wrapper around a registry and an entity.

Template Parameters
EntityA valid entity type (see entt_traits for more details).
TypeTypes to which to restrict the scope of a handle.

Definition at line 23 of file handle.hpp.

Constructor & Destructor Documentation

◆ basic_handle()

template<typename Entity , typename... Type>
entt::basic_handle< Entity, Type >::basic_handle ( registry_type ref,
entity_type  value 
)
inline

Constructs a handle from a given registry and entity.

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

Definition at line 43 of file handle.hpp.

Member Function Documentation

◆ all_of()

template<typename Entity , typename... Type>
template<typename... Component>
decltype(auto) entt::basic_handle< Entity, Type >::all_of ( ) const
inline

Checks if a handle has all the given components.

See also
basic_registry::all_of
Template Parameters
ComponentComponents for which to perform the check.
Returns
True if the handle has all the components, false otherwise.

Definition at line 205 of file handle.hpp.

◆ any_of()

template<typename Entity , typename... Type>
template<typename... Component>
decltype(auto) entt::basic_handle< Entity, Type >::any_of ( ) const
inline

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

See also
basic_registry::any_of
Template Parameters
ComponentComponents for which to perform the check.
Returns
True if the handle has at least one of the given components, false otherwise.

Definition at line 217 of file handle.hpp.

◆ destroy() [1/2]

template<typename Entity , typename... Type>
void entt::basic_handle< Entity, Type >::destroy ( )
inline

Destroys the entity associated with a handle.

See also
basic_registry::destroy

Definition at line 106 of file handle.hpp.

◆ destroy() [2/2]

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

Destroys the entity associated with a handle.

See also
basic_registry::destroy
Parameters
versionA desired version upon destruction.

Definition at line 115 of file handle.hpp.

◆ emplace()

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

Assigns the given component to a handle.

See also
basic_registry::emplace
Template Parameters
ComponentType of component to create.
ArgsTypes of arguments to use to construct the component.
Parameters
argsParameters to use to initialize the component.
Returns
A reference to the newly created component.

Definition at line 128 of file handle.hpp.

◆ emplace_or_replace()

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

Assigns or replaces the given component for a handle.

See also
basic_registry::emplace_or_replace
Template Parameters
ComponentType of component to assign or replace.
ArgsTypes of arguments to use to construct the component.
Parameters
argsParameters to use to initialize the component.
Returns
A reference to the newly created component.

Definition at line 142 of file handle.hpp.

◆ entity()

template<typename Entity , typename... Type>
entity_type entt::basic_handle< Entity, Type >::entity ( ) const
inline

Returns the entity associated with a handle.

Returns
The entity associated with the handle.

Definition at line 98 of file handle.hpp.

◆ erase()

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

Erases the given components from a handle.

See also
basic_registry::erase
Template Parameters
ComponentTypes of components to erase.

Definition at line 193 of file handle.hpp.

◆ get()

template<typename Entity , typename... Type>
template<typename... Component>
decltype(auto) entt::basic_handle< Entity, Type >::get ( ) const
inline

Returns references to the given components for a handle.

See also
basic_registry::get
Template Parameters
ComponentTypes of components to get.
Returns
References to the components owned by the handle.

Definition at line 228 of file handle.hpp.

◆ get_or_emplace()

template<typename Entity , typename... Type>
template<typename Component , typename... Args>
decltype(auto) entt::basic_handle< Entity, Type >::get_or_emplace ( Args &&...  args) const
inline

Returns a reference to the given component for a handle.

See also
basic_registry::get_or_emplace
Template Parameters
ComponentType of component to get.
ArgsTypes of arguments to use to construct the component.
Parameters
argsParameters to use to initialize the component.
Returns
Reference to the component owned by the handle.

Definition at line 242 of file handle.hpp.

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

template<typename Entity , typename... Type>
template<typename Other , typename... Args>
entt::basic_handle< Entity, Type >::operator basic_handle< Other, Args... > ( ) const
inline

Constructs a const handle from a non-const one.

Template Parameters
OtherA valid entity type (see entt_traits for more details).
ArgsScope of the handle to construct.
Returns
A const handle referring to the same registry and the same entity.

Definition at line 55 of file handle.hpp.

◆ operator bool()

template<typename Entity , typename... Type>
entt::basic_handle< Entity, Type >::operator bool ( ) const
inlineexplicit

Checks if a handle refers to non-null registry pointer and entity.

Returns
True if the handle refers to non-null registry and entity, false otherwise.

Definition at line 74 of file handle.hpp.

◆ operator entity_type()

template<typename Entity , typename... Type>
entt::basic_handle< Entity, Type >::operator entity_type ( ) const
inline

Converts a handle to its underlying entity.

Returns
The contained identifier.

Definition at line 66 of file handle.hpp.

◆ orphan()

template<typename Entity , typename... Type>
bool entt::basic_handle< Entity, Type >::orphan ( ) const
inline

Checks if a handle has components assigned.

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

Definition at line 263 of file handle.hpp.

◆ patch()

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

Patches the given component for a handle.

See also
basic_registry::patch
Template Parameters
ComponentType of component to patch.
FuncTypes of the function objects to invoke.
Parameters
funcValid function objects.
Returns
A reference to the patched component.

Definition at line 156 of file handle.hpp.

◆ registry()

template<typename Entity , typename... Type>
registry_type* entt::basic_handle< Entity, Type >::registry ( ) const
inline

Returns a pointer to the underlying registry, if any.

Returns
A pointer to the underlying registry, if any.

Definition at line 90 of file handle.hpp.

◆ remove()

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

Removes the given components from a handle.

See also
basic_registry::remove
Template Parameters
ComponentTypes of components to remove.
Returns
The number of components actually removed.

Definition at line 182 of file handle.hpp.

◆ replace()

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

Replaces the given component for a handle.

See also
basic_registry::replace
Template Parameters
ComponentType of component to replace.
ArgsTypes of arguments to use to construct the component.
Parameters
argsParameters to use to initialize the component.
Returns
A reference to the component being replaced.

Definition at line 170 of file handle.hpp.

◆ try_get()

template<typename Entity , typename... Type>
template<typename... Component>
auto entt::basic_handle< Entity, Type >::try_get ( ) const
inline

Returns pointers to the given components for a handle.

See also
basic_registry::try_get
Template Parameters
ComponentTypes of components to get.
Returns
Pointers to the components owned by the handle.

Definition at line 254 of file handle.hpp.

◆ valid()

template<typename Entity , typename... Type>
bool entt::basic_handle< Entity, Type >::valid ( ) const
inline

Checks if a handle refers to a valid entity or not.

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

Definition at line 82 of file handle.hpp.

◆ visit()

template<typename Entity , typename... Type>
template<typename Func >
void entt::basic_handle< Entity, Type >::visit ( Func &&  func) const
inline

Visits a handle and returns the pools for its components.

The signature of the function should be equivalent to the following:

void(id_type, const basic_sparse_set<entity_type> &);
std::uint32_t id_type
Alias declaration for type identifiers.
Definition: fwd.hpp:14

Returned pools are those that contain the entity associated with the handle.

Template Parameters
FuncType of the function object to invoke.
Parameters
funcA valid function object.

Definition at line 283 of file handle.hpp.


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