NAP
Public Member Functions | List of all members
SafePtr< T > Class Template Reference

#include <audio/utility/safeptr.h>

Public Member Functions

 SafePtr ()=default
 
 SafePtr (SafeOwner< T > &owner)
 
 ~SafePtr ()
 
 SafePtr (const SafePtr< T > &other)
 
SafePtroperator= (const SafePtr< T > &other)
 
template<typename OTHER >
 SafePtr (const SafePtr< OTHER > &other)
 
template<typename OTHER >
SafePtroperator= (const SafePtr< OTHER > &other)
 
 SafePtr (const std::nullptr_t)
 
SafePtroperator= (const std::nullptr_t)
 
 SafePtr (SafePtr< T > &&other)
 
SafePtr< T > & operator= (SafePtr< T > &&other)
 
template<typename OTHER >
 SafePtr (SafePtr< OTHER > &&other)
 
template<typename OTHER >
SafePtr< T > & operator= (SafePtr< OTHER > &&other)
 
const T & operator* () const
 
T & operator* ()
 
T * operator-> () const
 
T * operator-> ()
 
template<typename OTHER >
bool operator== (const OTHER *ptr) const
 
template<typename OTHER >
bool operator!= (const OTHER *ptr) const
 
bool operator== (const std::nullptr_t) const
 
bool operator!= (const std::nullptr_t) const
 
T * get () const
 
T * get ()
 

Description

template<typename T>
class nap::audio::SafePtr< T >

A SafePtr points to an object that is owned by a SafeOwner somewhere. When the owner goes out of scope and the pointed object will be moved into the DeletionQueue the SafePtr will return true when checked if it equals nullptr. However the object it points to can still be used and safely accessed using the * and -> operators and the get() method until the next time the DeletionQueue is cleared. This way SafePtr guarantees that it can be safely used on both the thread where the SafeOwner went out of scope AND the thread that periodically empties the DeletionQueue, as long as you check if the SafePtr != nullptr before use.

Constructor & Destructor Documentation

◆ SafePtr() [1/7]

SafePtr ( )
default

◆ SafePtr() [2/7]

SafePtr ( SafeOwner< T > &  owner)

Constructs a SafePtr pointing to an object owned by a SafeOwner.

◆ ~SafePtr()

~SafePtr ( )

The destructor removes this Safeptr from the list of SafePtrs that will be mNotified when the object is destroyed.

◆ SafePtr() [3/7]

SafePtr ( const SafePtr< T > &  other)

◆ SafePtr() [4/7]

SafePtr ( const SafePtr< OTHER > &  other)

◆ SafePtr() [5/7]

SafePtr ( const std::nullptr_t  )

◆ SafePtr() [6/7]

SafePtr ( SafePtr< T > &&  other)

◆ SafePtr() [7/7]

SafePtr ( SafePtr< OTHER > &&  other)

Member Function Documentation

◆ get() [1/2]

T* get ( )

◆ get() [2/2]

T* get ( ) const

◆ operator!=() [1/2]

bool operator!= ( const OTHER *  ptr) const

◆ operator!=() [2/2]

bool operator!= ( const std::nullptr_t  ) const

◆ operator*() [1/2]

T& operator* ( )

◆ operator*() [2/2]

const T& operator* ( ) const

◆ operator->() [1/2]

T* operator-> ( )

◆ operator->() [2/2]

T* operator-> ( ) const

◆ operator=() [1/5]

SafePtr& operator= ( const SafePtr< OTHER > &  other)

◆ operator=() [2/5]

SafePtr& operator= ( const SafePtr< T > &  other)

◆ operator=() [3/5]

SafePtr& operator= ( const std::nullptr_t  )

◆ operator=() [4/5]

SafePtr<T>& operator= ( SafePtr< OTHER > &&  other)

◆ operator=() [5/5]

SafePtr<T>& operator= ( SafePtr< T > &&  other)

◆ operator==() [1/2]

bool operator== ( const OTHER *  ptr) const

◆ operator==() [2/2]

bool operator== ( const std::nullptr_t  ) const