Minetest  5.4.0
irr_ptr< ReferenceCounted, class > Class Template Reference

Shared pointer for IrrLicht objects. More...

#include <irr_ptr.h>

Public Member Functions

 irr_ptr ()
 
 irr_ptr (std::nullptr_t) noexcept
 
 irr_ptr (const irr_ptr &b) noexcept
 
 irr_ptr (irr_ptr &&b) noexcept
 
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
 irr_ptr (const irr_ptr< B > &b) noexcept
 
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
 irr_ptr (irr_ptr< B > &&b) noexcept
 
 irr_ptr (ReferenceCounted *object) noexcept
 Constructs a shared pointer out of a plain one to control object lifetime. More...
 
 ~irr_ptr ()
 
irr_ptroperator= (const irr_ptr &b) noexcept
 
irr_ptroperator= (irr_ptr &&b) noexcept
 
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptroperator= (const irr_ptr< B > &b) noexcept
 
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptroperator= (irr_ptr< B > &&b) noexcept
 
ReferenceCounted & operator* () const noexcept
 
ReferenceCounted * operator-> () const noexcept
 
 operator ReferenceCounted * () const noexcept
 
 operator bool () const noexcept
 
ReferenceCounted * get () const noexcept
 Returns the stored pointer. More...
 
ReferenceCounted * release () noexcept
 Returns the stored pointer, erasing it from this class. More...
 
void reset (ReferenceCounted *object=nullptr) noexcept
 Drops stored pointer replacing it with the given one. More...
 
void grab (ReferenceCounted *object) noexcept
 Drops stored pointer replacing it with the given one. More...
 

Private Attributes

ReferenceCounted * value = nullptr
 

Detailed Description

template<class ReferenceCounted, class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
class irr_ptr< ReferenceCounted, class >

Shared pointer for IrrLicht objects.

It should only be used for user-managed objects, i.e. those created with the new operator or create* functions, like: irr_ptr<scene::IMeshBuffer> buf{new scene::SMeshBuffer()}; The reference counting is not balanced as new objects have reference count set to one, and the irr_ptr constructor (and reset) assumes ownership of that reference.

It shouldn’t be used for engine-managed objects, including those created with addTexture and similar methods. Constructing irr_ptr directly from such object is a bug and may lead to a crash. Indirect construction is possible though; see the grab free function for details and use cases.

Constructor & Destructor Documentation

◆ irr_ptr() [1/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( )
inline

◆ irr_ptr() [2/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( std::nullptr_t  )
inlinenoexcept

◆ irr_ptr() [3/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( const irr_ptr< ReferenceCounted, class > &  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::grab().

+ Here is the call graph for this function:

◆ irr_ptr() [4/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( irr_ptr< ReferenceCounted, class > &&  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

◆ irr_ptr() [5/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( const irr_ptr< B > &  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::grab().

+ Here is the call graph for this function:

◆ irr_ptr() [6/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( irr_ptr< B > &&  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

◆ irr_ptr() [7/7]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::irr_ptr ( ReferenceCounted *  object)
inlineexplicitnoexcept

Constructs a shared pointer out of a plain one to control object lifetime.

Parameters
objectThe object, usually returned by some create* function.
Note
Move semantics: reference counter is not increased.
Warning
Never wrap any add* function with this!

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

◆ ~irr_ptr()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::~irr_ptr ( )
inline

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

Member Function Documentation

◆ get()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
ReferenceCounted* irr_ptr< ReferenceCounted, class >::get ( ) const
inlinenoexcept

Returns the stored pointer.

References irr_ptr< ReferenceCounted, class >::value.

Referenced by Sky::draw_stars().

+ Here is the caller graph for this function:

◆ grab()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
void irr_ptr< ReferenceCounted, class >::grab ( ReferenceCounted *  object)
inlinenoexcept

Drops stored pointer replacing it with the given one.

Note
Copy semantics: reference counter is increased.

References irr_ptr< ReferenceCounted, class >::reset().

Referenced by irr_ptr< ReferenceCounted, class >::irr_ptr(), grab(), irr_ptr< ReferenceCounted, class >::operator=(), and GUIModalMenu::preprocessEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator bool()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::operator bool ( ) const
inlineexplicitnoexcept

◆ operator ReferenceCounted *()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr< ReferenceCounted, class >::operator ReferenceCounted * ( ) const
inlineexplicitnoexcept

◆ operator*()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
ReferenceCounted& irr_ptr< ReferenceCounted, class >::operator* ( ) const
inlinenoexcept

◆ operator->()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
ReferenceCounted* irr_ptr< ReferenceCounted, class >::operator-> ( ) const
inlinenoexcept

◆ operator=() [1/4]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr& irr_ptr< ReferenceCounted, class >::operator= ( const irr_ptr< ReferenceCounted, class > &  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::grab().

+ Here is the call graph for this function:

◆ operator=() [2/4]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptr& irr_ptr< ReferenceCounted, class >::operator= ( const irr_ptr< B > &  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::grab().

+ Here is the call graph for this function:

◆ operator=() [3/4]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
irr_ptr& irr_ptr< ReferenceCounted, class >::operator= ( irr_ptr< ReferenceCounted, class > &&  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

◆ operator=() [4/4]

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
template<typename B , class = typename std::enable_if<std::is_convertible<B *, ReferenceCounted *>::value>::type>
irr_ptr& irr_ptr< ReferenceCounted, class >::operator= ( irr_ptr< B > &&  b)
inlinenoexcept

References irr_ptr< ReferenceCounted, class >::reset().

+ Here is the call graph for this function:

◆ release()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
ReferenceCounted* irr_ptr< ReferenceCounted, class >::release ( )
inlinenoexcept

Returns the stored pointer, erasing it from this class.

Note
Move semantics: reference counter is not changed.

References irr_ptr< ReferenceCounted, class >::value.

◆ reset()

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
void irr_ptr< ReferenceCounted, class >::reset ( ReferenceCounted *  object = nullptr)
inlinenoexcept

Drops stored pointer replacing it with the given one.

Note
Move semantics: reference counter is not increased.

References irr_ptr< ReferenceCounted, class >::value.

Referenced by irr_ptr< ReferenceCounted, class >::irr_ptr(), irr_ptr< ReferenceCounted, class >::~irr_ptr(), irr_ptr< ReferenceCounted, class >::grab(), irr_ptr< ReferenceCounted, class >::operator=(), and Sky::updateStars().

+ Here is the caller graph for this function:

Member Data Documentation

◆ value

template<class ReferenceCounted , class = typename std::enable_if<std::is_base_of<IReferenceCounted, ReferenceCounted>::value>::type>
ReferenceCounted* irr_ptr< ReferenceCounted, class >::value = nullptr
private

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