OpenLexocad  27.1
entt::handle< Resource > Class Template Reference

Shared resource handle. More...

#include <entt.hpp>

Public Member Functions

 handle () ENTT_NOEXCEPT=default
 Default constructor. More...
 
const Resource & get () const ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
Resource & get () ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
 operator const Resource & () const ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
 operator Resource & () ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
const Resource & operator * () const ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
Resource & operator * () ENTT_NOEXCEPT
 Gets a reference to the managed resource. More...
 
const Resource * operator-> () const ENTT_NOEXCEPT
 Gets a pointer to the managed resource. More...
 
Resource * operator-> () ENTT_NOEXCEPT
 Gets a pointer to the managed resource. More...
 
 operator bool () const
 Returns true if a handle contains a resource, false otherwise. More...
 

Friends

struct cache< Resource >
 Resource handles are friends of their caches. More...
 

Detailed Description

template<typename Resource>
class entt::handle< Resource >

Shared resource handle.

A shared resource handle is a small class that wraps a resource and keeps it alive even if it's deleted from the cache. It can be either copied or moved. A handle shares a reference to the same resource with all the other handles constructed for the same identifier.
As a rule of thumb, resources should never be copied nor moved. Handles are the way to go to keep references to them.

Template Parameters
ResourceType of resource managed by a handle.

Constructor & Destructor Documentation

◆ handle()

template<typename Resource >
entt::handle< Resource >::handle ( )
default

Default constructor.

Member Function Documentation

◆ get() [1/2]

template<typename Resource >
const Resource& entt::handle< Resource >::get ( ) const
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ get() [2/2]

template<typename Resource >
Resource& entt::handle< Resource >::get ( )
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ operator *() [1/2]

template<typename Resource >
const Resource& entt::handle< Resource >::operator * ( ) const
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ operator *() [2/2]

template<typename Resource >
Resource& entt::handle< Resource >::operator * ( )
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ operator bool()

template<typename Resource >
entt::handle< Resource >::operator bool ( ) const
inlineexplicit

Returns true if a handle contains a resource, false otherwise.

Returns
True if the handle contains a resource, false otherwise.

◆ operator const Resource &()

template<typename Resource >
entt::handle< Resource >::operator const Resource & ( ) const
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ operator Resource &()

template<typename Resource >
entt::handle< Resource >::operator Resource & ( )
inline

Gets a reference to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A reference to the managed resource.

◆ operator->() [1/2]

template<typename Resource >
const Resource* entt::handle< Resource >::operator-> ( ) const
inline

Gets a pointer to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A pointer to the managed resource or nullptr if the handle contains no resource at all.

◆ operator->() [2/2]

template<typename Resource >
Resource* entt::handle< Resource >::operator-> ( )
inline

Gets a pointer to the managed resource.

Warning
The behavior is undefined if the handle doesn't contain a resource.
An assertion will abort the execution at runtime in debug mode if the handle is empty.
Returns
A pointer to the managed resource or nullptr if the handle contains no resource at all.

Friends And Related Function Documentation

◆ cache< Resource >

template<typename Resource >
friend struct cache< Resource >
friend

Resource handles are friends of their caches.


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