EnTT  3.5.0
Public Types | Public Member Functions | List of all members
entt::basic_actor< Entity > Struct Template Reference

Dedicated to those who aren't confident with the entity-component-system architecture. More...

#include <actor.hpp>

Public Types

using registry_type = basic_registry< Entity >
 Type of registry used internally.
 
using entity_type = Entity
 Underlying entity identifier.
 

Public Member Functions

 basic_actor (basic_actor &&other) noexcept
 Move constructor. More...
 
 basic_actor (registry_type &ref)
 Constructs an actor from a given registry. More...
 
 basic_actor (entity_type entity, registry_type &ref) noexcept
 Constructs an actor from a given entity. More...
 
virtual ~basic_actor ()
 Default destructor.
 
basic_actoroperator= (basic_actor &&other) noexcept
 Move assignment operator. More...
 
template<typename Component , typename... Args>
decltype(auto) assign (Args &&... args)
 Assigns the given component to an actor. More...
 
template<typename Component >
void remove ()
 Removes the given component from an actor. More...
 
template<typename... Component>
bool has () const
 Checks if an actor has the given components. More...
 
template<typename... Component>
decltype(auto) get () const
 Returns references to the given components for an actor. More...
 
template<typename... Component>
decltype(auto) get ()
 Returns references to the given components for an actor. More...
 
template<typename... Component>
auto try_get () const
 Returns pointers to the given components for an actor. More...
 
template<typename... Component>
auto try_get ()
 Returns pointers to the given components for an actor. More...
 
const registry_typebackend () const noexcept
 Returns a reference to the underlying registry. More...
 
registry_typebackend () noexcept
 Returns a reference to the underlying registry. More...
 
entity_type entity () const noexcept
 Returns the entity associated with an actor. More...
 
 operator bool () const
 Checks if an actor refers to a valid entity or not. More...
 

Detailed Description

template<typename Entity>
struct entt::basic_actor< Entity >

Dedicated to those who aren't confident with the entity-component-system architecture.

Tiny wrapper around a registry, for all those users that aren't confident with entity-component-system architecture and prefer to iterate objects directly.

Template Parameters
EntityA valid entity type (see entt_traits for more details).

Definition at line 27 of file actor.hpp.

Constructor & Destructor Documentation

◆ basic_actor() [1/3]

template<typename Entity >
entt::basic_actor< Entity >::basic_actor ( basic_actor< Entity > &&  other)
inlinenoexcept

Move constructor.

After actor move construction, instances that have been moved from are placed in a valid but unspecified state. It's highly discouraged to continue using them.

Parameters
otherThe instance to move from.

Definition at line 46 of file actor.hpp.

◆ basic_actor() [2/3]

template<typename Entity >
entt::basic_actor< Entity >::basic_actor ( registry_type ref)
inlineexplicit

Constructs an actor from a given registry.

Parameters
refAn instance of the registry class.

Definition at line 56 of file actor.hpp.

◆ basic_actor() [3/3]

template<typename Entity >
entt::basic_actor< Entity >::basic_actor ( entity_type  entity,
registry_type ref 
)
inlineexplicitnoexcept

Constructs an actor from a given entity.

Parameters
entityA valid entity identifier.
refAn instance of the registry class.

Definition at line 65 of file actor.hpp.

Member Function Documentation

◆ assign()

template<typename Entity >
template<typename Component , typename... Args>
decltype(auto) entt::basic_actor< Entity >::assign ( Args &&...  args)
inline

Assigns the given component to an actor.

A new instance of the given component is created and initialized with the arguments provided (the component must have a proper constructor or be of aggregate type). Then the component is assigned to the actor.
In case the actor already has a component of the given type, it's replaced with the new one.

Template Parameters
ComponentType of the 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 113 of file actor.hpp.

◆ backend() [1/2]

template<typename Entity >
const registry_type& entt::basic_actor< Entity >::backend ( ) const
inlinenoexcept

Returns a reference to the underlying registry.

Returns
A reference to the underlying registry.

Definition at line 172 of file actor.hpp.

◆ backend() [2/2]

template<typename Entity >
registry_type& entt::basic_actor< Entity >::backend ( )
inlinenoexcept

Returns a reference to the underlying registry.

Returns
A reference to the underlying registry.

Definition at line 177 of file actor.hpp.

◆ entity()

template<typename Entity >
entity_type entt::basic_actor< Entity >::entity ( ) const
inlinenoexcept

Returns the entity associated with an actor.

Returns
The entity associated with the actor.

Definition at line 185 of file actor.hpp.

◆ get() [1/2]

template<typename Entity >
template<typename... Component>
decltype(auto) entt::basic_actor< Entity >::get ( )
inline

Returns references to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
References to the components owned by the actor.

Definition at line 148 of file actor.hpp.

◆ get() [2/2]

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

Returns references to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
References to the components owned by the actor.

Definition at line 142 of file actor.hpp.

◆ has()

template<typename Entity >
template<typename... Component>
bool entt::basic_actor< Entity >::has ( ) const
inline

Checks if an actor has the given components.

Template Parameters
ComponentComponents for which to perform the check.
Returns
True if the actor has all the components, false otherwise.

Definition at line 132 of file actor.hpp.

◆ operator bool()

template<typename Entity >
entt::basic_actor< Entity >::operator bool ( ) const
inlineexplicit

Checks if an actor refers to a valid entity or not.

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

Definition at line 193 of file actor.hpp.

◆ operator=()

template<typename Entity >
basic_actor& entt::basic_actor< Entity >::operator= ( basic_actor< Entity > &&  other)
inlinenoexcept

Move assignment operator.

After actor move assignment, instances that have been moved from are placed in a valid but unspecified state. It's highly discouraged to continue using them.

Parameters
otherThe instance to move from.
Returns
This actor.

Definition at line 88 of file actor.hpp.

◆ remove()

template<typename Entity >
template<typename Component >
void entt::basic_actor< Entity >::remove ( )
inline

Removes the given component from an actor.

Template Parameters
ComponentType of the component to remove.

Definition at line 122 of file actor.hpp.

◆ try_get() [1/2]

template<typename Entity >
template<typename... Component>
auto entt::basic_actor< Entity >::try_get ( )
inline

Returns pointers to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
Pointers to the components owned by the actor.

Definition at line 164 of file actor.hpp.

◆ try_get() [2/2]

template<typename Entity >
template<typename... Component>
auto entt::basic_actor< Entity >::try_get ( ) const
inline

Returns pointers to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
Pointers to the components owned by the actor.

Definition at line 158 of file actor.hpp.


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