LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::PimplPtr< pImpl > Class Template Reference

A smart pointer that manages an implementation instance for a public interface class. More...

#include <containers.hpp>

Public Member Functions

 PimplPtr () noexcept=default
 Initializes a new pointer to an uninitialized implementation instance. More...
 
 PimplPtr (const PimplPtr &src) noexcept
 Initializes a new pointer to a copy of the implementation instance managed by src . More...
 
 PimplPtr (PimplPtr &&src) noexcept=default
 Initializes a new pointer by taking over the implementation instance managed by src . More...
 
PimplPtroperator= (const PimplPtr &src) noexcept
 Initializes a new pointer to a copy of the implementation instance managed by src . More...
 
PimplPtroperator= (PimplPtr &&src) noexcept=default
 Initializes a new pointer by taking over the implementation instance managed by src . More...
 
 ~PimplPtr () noexcept=default
 
void destroy ()
 Destroys the implementation instance managed by this pointer. More...
 
pImpl * release () noexcept
 Releases the implementation instance managed by this pointer and returns it. More...
 
pImpl & operator* () const noexcept
 Returns a reference to the managed implementation instance. More...
 
pImpl * operator-> () const noexcept
 Returns a pointer to the managed implementation instance. More...
 

Friends

template<class T , class... Arg>
PimplPtr< T > makePimpl (Arg &&... arg)
 Creates a pointer to an implementation. More...
 

Detailed Description

template<class pImpl>
class LiteFX::PimplPtr< pImpl >

A smart pointer that manages an implementation instance for a public interface class.

Template Parameters
pImplThe type of the implementaion class.

Constructor & Destructor Documentation

◆ PimplPtr() [1/3]

template<class pImpl >
LiteFX::PimplPtr< pImpl >::PimplPtr ( )
defaultnoexcept

Initializes a new pointer to an uninitialized implementation instance.

◆ PimplPtr() [2/3]

template<class pImpl >
LiteFX::PimplPtr< pImpl >::PimplPtr ( const PimplPtr< pImpl > &  src)
inlinenoexcept

Initializes a new pointer to a copy of the implementation instance managed by src .

Note that this will share ownership between this instance and src . Only use this method, if you release either of both implementation pointers manually!

Parameters
srcThe source pointer to copy the implementation instance from.

◆ PimplPtr() [3/3]

template<class pImpl >
LiteFX::PimplPtr< pImpl >::PimplPtr ( PimplPtr< pImpl > &&  src)
defaultnoexcept

Initializes a new pointer by taking over the implementation instance managed by src .

Parameters
srcThe source pointer to take over.

◆ ~PimplPtr()

template<class pImpl >
LiteFX::PimplPtr< pImpl >::~PimplPtr ( )
defaultnoexcept

Member Function Documentation

◆ destroy()

template<class pImpl >
void LiteFX::PimplPtr< pImpl >::destroy ( )
inline

Destroys the implementation instance managed by this pointer.

◆ operator*()

template<class pImpl >
pImpl & LiteFX::PimplPtr< pImpl >::operator* ( ) const
inlinenoexcept

Returns a reference to the managed implementation instance.

Returns
A reference to the managed implementation instance.

◆ operator->()

template<class pImpl >
pImpl * LiteFX::PimplPtr< pImpl >::operator-> ( ) const
inlinenoexcept

Returns a pointer to the managed implementation instance.

Returns
A pointer to the managed implementation instance.

◆ operator=() [1/2]

template<class pImpl >
PimplPtr & LiteFX::PimplPtr< pImpl >::operator= ( const PimplPtr< pImpl > &  src)
inlinenoexcept

Initializes a new pointer to a copy of the implementation instance managed by src .

Note that this will share ownership between this instance and src . Only use this method, if you release either of both implementation pointers manually!

Parameters
srcThe source pointer to copy the implementation instance from.
Returns
A new pointer to the provided implementation instance.

◆ operator=() [2/2]

template<class pImpl >
PimplPtr & LiteFX::PimplPtr< pImpl >::operator= ( PimplPtr< pImpl > &&  src)
defaultnoexcept

Initializes a new pointer by taking over the implementation instance managed by src .

Parameters
srcThe source pointer to take over.

///

Returns
A new pointer to the provided implementation instance.

◆ release()

template<class pImpl >
pImpl * LiteFX::PimplPtr< pImpl >::release ( )
inlinenoexcept

Releases the implementation instance managed by this pointer and returns it.

Returns
The pointer to the managed implementation instance.

Friends And Related Function Documentation

◆ makePimpl

template<class pImpl >
template<class T , class... Arg>
PimplPtr< T > makePimpl ( Arg &&...  arg)
friend

Creates a pointer to an implementation.

Template Parameters
TThe type of the implementation class.
...ArgThe variadic argument types forwarded to the implementation classes' constructor.
Parameters
...argThe arguments forwarded to the implementation classes' constructor.
Returns
The pointer to the implementation class instance.