OpenLexocad  28.0
entt::handle Class 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

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()

entt::handle::handle ( )
default

Default constructor.

Member Function Documentation

◆ get() [1/2]

const Resource& entt::handle::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]

Resource& entt::handle::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 bool()

entt::handle::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 &()

entt::handle::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 &()

entt::handle::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]

const Resource& entt::handle::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]

Resource& entt::handle::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->() [1/2]

const Resource* entt::handle::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]

Resource* entt::handle::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 >

friend struct cache< Resource >
friend

Resource handles are friends of their caches.


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