|
EnTT 3.14.0
|
Basic resource handle. More...
#include <resource.hpp>
Public Types | |
| using | element_type = Type |
| Resource type. | |
| using | handle_type = std::shared_ptr<element_type> |
| Handle type. | |
Public Member Functions | |
| resource () noexcept | |
| Default constructor. | |
| resource (handle_type res) noexcept | |
| Creates a new resource handle. | |
| resource (const resource &) noexcept=default | |
| Default copy constructor. | |
| resource (resource &&) noexcept=default | |
| Default move constructor. | |
| template<typename Other > | |
| resource (const resource< Other > &other, element_type &res) noexcept | |
| Aliasing constructor. | |
| template<typename Other , typename = std::enable_if_t<is_acceptable_v<Other>>> | |
| resource (const resource< Other > &other) noexcept | |
| Copy constructs a handle which shares ownership of the resource. | |
| template<typename Other , typename = std::enable_if_t<is_acceptable_v<Other>>> | |
| resource (resource< Other > &&other) noexcept | |
| Move constructs a handle which takes ownership of the resource. | |
| ~resource ()=default | |
| Default destructor. | |
| resource & | operator= (const resource &) noexcept=default |
| Default copy assignment operator. | |
| resource & | operator= (resource &&) noexcept=default |
| Default move assignment operator. | |
| template<typename Other , typename = std::enable_if_t<is_acceptable_v<Other>>> | |
| resource & | operator= (const resource< Other > &other) noexcept |
| Copy assignment operator from foreign handle. | |
| template<typename Other , typename = std::enable_if_t<is_acceptable_v<Other>>> | |
| resource & | operator= (resource< Other > &&other) noexcept |
| Move assignment operator from foreign handle. | |
| void | swap (resource &other) noexcept |
| Exchanges the content with that of a given resource. | |
| element_type & | operator* () const noexcept |
| Returns a reference to the managed resource. | |
| operator element_type & () const noexcept | |
| Returns a reference to the managed resource. | |
| element_type * | operator-> () const noexcept |
| Returns a pointer to the managed resource. | |
| operator bool () const noexcept | |
| Returns true if a handle contains a resource, false otherwise. | |
| void | reset () |
| Releases the ownership of the managed resource. | |
| void | reset (handle_type other) |
| Replaces the managed resource. | |
| const handle_type & | handle () const noexcept |
| Returns the underlying resource handle. | |
Basic resource handle.
A handle wraps a resource and extends its lifetime. It also shares the same resource with all other handles constructed from the same element.
As a rule of thumb, resources should never be copied nor moved. Handles are the way to go to push references around.
| Type | Type of resource managed by a handle. |
Definition at line 22 of file resource.hpp.
| using entt::resource< Type >::element_type = Type |
Resource type.
Definition at line 31 of file resource.hpp.
| using entt::resource< Type >::handle_type = std::shared_ptr<element_type> |
Handle type.
Definition at line 33 of file resource.hpp.
|
inlinenoexcept |
Default constructor.
Definition at line 36 of file resource.hpp.
|
inlineexplicitnoexcept |
Creates a new resource handle.
| res | A handle to a resource. |
Definition at line 43 of file resource.hpp.
|
inlinenoexcept |
Aliasing constructor.
| Other | Type of resource managed by the received handle. |
| other | The handle with which to share ownership information. |
| res | Unrelated and unmanaged resources. |
Definition at line 59 of file resource.hpp.
|
inlinenoexcept |
Copy constructs a handle which shares ownership of the resource.
| Other | Type of resource managed by the received handle. |
| other | The handle to copy from. |
Definition at line 68 of file resource.hpp.
|
inlinenoexcept |
Move constructs a handle which takes ownership of the resource.
| Other | Type of resource managed by the received handle. |
| other | The handle to move from. |
Definition at line 77 of file resource.hpp.
|
inlinenodiscardnoexcept |
Returns the underlying resource handle.
Definition at line 178 of file resource.hpp.
|
inlineexplicitnodiscardnoexcept |
Returns true if a handle contains a resource, false otherwise.
Definition at line 157 of file resource.hpp.
|
inlinenodiscardnoexcept |
Returns a reference to the managed resource.
Definition at line 141 of file resource.hpp.
|
inlinenodiscardnoexcept |
Returns a reference to the managed resource.
Definition at line 136 of file resource.hpp.
|
inlinenodiscardnoexcept |
Returns a pointer to the managed resource.
Definition at line 149 of file resource.hpp.
|
defaultnoexcept |
Default copy assignment operator.
|
inlinenoexcept |
Copy assignment operator from foreign handle.
| Other | Type of resource managed by the received handle. |
| other | The handle to copy from. |
Definition at line 102 of file resource.hpp.
|
defaultnoexcept |
Default move assignment operator.
|
inlinenoexcept |
Move assignment operator from foreign handle.
| Other | Type of resource managed by the received handle. |
| other | The handle to move from. |
Definition at line 114 of file resource.hpp.
|
inline |
Releases the ownership of the managed resource.
Definition at line 162 of file resource.hpp.
|
inline |
Replaces the managed resource.
| other | A handle to a resource. |
Definition at line 170 of file resource.hpp.
|
inlinenoexcept |
Exchanges the content with that of a given resource.
| other | Resource to exchange the content with. |
Definition at line 123 of file resource.hpp.
Definition at line 24 of file resource.hpp.