ADTF
Loading...
Searching...
No Matches
adtf::ucom::ant::enable_object_ptr_from_this< T > Class Template Reference

Safely retrieve a valid object_ptr<> instance to *this when all we have is *this. More...

#include <object_ptr_utilities.h>

Public Member Functions

object_ptr< T > object_ptr_from_this ()
 Retrieve an object_ptr with *this being the shared resource.
 
object_ptr< const T > object_ptr_from_this () const
 Retrieve an object_ptr with *this being the shared resource - const correct.
 

Protected Member Functions

 enable_object_ptr_from_this ()=default
 Default constructor.
 
 ~enable_object_ptr_from_this ()=default
 Default destructor.
 
 enable_object_ptr_from_this (const enable_object_ptr_from_this &)=default
 Default copy construction.
 
enable_object_ptr_from_thisoperator= (const enable_object_ptr_from_this &)=default
 Default copy assignment.
 

Friends

template<typename Implementation, bool Fuse, typename Allocator, typename... Args>
object_ptr< Implementation > vision::allocate_object_ptr (Allocator &&allocator, Args &&... args)
 

Detailed Description

template<typename T>
class adtf::ucom::ant::enable_object_ptr_from_this< T >

Safely retrieve a valid object_ptr<> instance to *this when all we have is *this.

This may be used in complete analogy to std::enable_shared_from_this, so please consult a documentation for that for further questions on the usage of this class.

Note
To make sure the only way to get a valid shared resource wrapped inside an object_ptr is from an shared resource managed by an already existing object_ptr, friend function make_object_ptr is the only possible way to assign a valid object_ptr. In other words, retrieving an object_ptr of *this from an object not managed by an object_ptr results in an empty object_ptr<T>.
Template Parameters
TType of the shared resource that is managed by the object_ptr<> to retrieve.

Member Function Documentation

◆ object_ptr_from_this() [1/2]

template<typename T>
object_ptr< T > adtf::ucom::ant::enable_object_ptr_from_this< T >::object_ptr_from_this ( )
inline

Retrieve an object_ptr with *this being the shared resource.

Returns
object_ptr with *this as the shared resource. If *this is not managed by a valid object_ptr, the returned object_ptr is empty.

◆ object_ptr_from_this() [2/2]

template<typename T>
object_ptr< const T > adtf::ucom::ant::enable_object_ptr_from_this< T >::object_ptr_from_this ( ) const
inline

Retrieve an object_ptr with *this being the shared resource - const correct.

Returns
object_ptr with *this as the shared resource. If *this is not managed by a valid object_ptr, the returned object_ptr is empty.

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