Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::SharedPtr< T, Ownership > Class Template Reference

Shared ownership intrusive pointer. More...

#include <shared_ptr.h>

Public Member Functions

 SharedPtr ()
 Create empty shared pointer. More...
 
 SharedPtr (T *ptr)
 Create shared pointer from raw pointer. More...
 
 SharedPtr (const SharedPtr &other)
 Create shared pointer from shared pointer of the same type. More...
 
template<class TT >
 SharedPtr (const SharedPtr< TT, Ownership > &other)
 Create shared pointer from shared pointer of another type. More...
 
 ~SharedPtr ()
 Destroy shared pointer. More...
 
SharedPtroperator= (const SharedPtr &other)
 Reset shared pointer and attach it to another object. More...
 
void reset (T *ptr=NULL)
 Reset shared pointer and attach it to another object. More...
 
T * get () const
 Get underlying pointer. More...
 
T * operator-> () const
 Get underlying pointer. More...
 
T & operator* () const
 Get underlying reference. More...
 
 operator const struct unspecified_bool * () const
 Convert to bool. More...
 

Detailed Description

template<class T, template< class TT > class Ownership = RefCntOwnership>
class roc::core::SharedPtr< T, Ownership >

Shared ownership intrusive pointer.

Template Parameters
Tdefines pointee type. It may be const.
Ownershipdefines methods to increase and decrease the reference counter embedded into object. If RefCntOwnership is used, T should inherit RefCnt.

Definition at line 18 of file ownership.h.

Constructor & Destructor Documentation

template<class T, template< class TT > class Ownership = RefCntOwnership>
roc::core::SharedPtr< T, Ownership >::SharedPtr ( )
inline

Create empty shared pointer.

Remarks
This overload is a bit faster than SharedPtr(NULL).

Definition at line 33 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
roc::core::SharedPtr< T, Ownership >::SharedPtr ( T *  ptr)
inline

Create shared pointer from raw pointer.

Remarks
This overload hits SharedPtr(NULL) and SharedPtr(T).

Definition at line 40 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
roc::core::SharedPtr< T, Ownership >::SharedPtr ( const SharedPtr< T, Ownership > &  other)
inline

Create shared pointer from shared pointer of the same type.

Remarks
This is a copy constructor.

Definition at line 48 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
template<class TT >
roc::core::SharedPtr< T, Ownership >::SharedPtr ( const SharedPtr< TT, Ownership > &  other)
inline

Create shared pointer from shared pointer of another type.

Remarks
  • This overload hits SharedPtr(SharedPtr<ConvertibleToT>).
  • This doesn't work as a copy constructor since it's template.

Definition at line 58 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
roc::core::SharedPtr< T, Ownership >::~SharedPtr ( )
inline

Destroy shared pointer.

Definition at line 64 of file shared_ptr.h.

Member Function Documentation

template<class T, template< class TT > class Ownership = RefCntOwnership>
T* roc::core::SharedPtr< T, Ownership >::get ( ) const
inline

Get underlying pointer.

Definition at line 84 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
roc::core::SharedPtr< T, Ownership >::operator const struct unspecified_bool * ( ) const
inline

Convert to bool.

Definition at line 102 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
T& roc::core::SharedPtr< T, Ownership >::operator* ( ) const
inline

Get underlying reference.

Definition at line 94 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
T* roc::core::SharedPtr< T, Ownership >::operator-> ( ) const
inline

Get underlying pointer.

Definition at line 89 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
SharedPtr& roc::core::SharedPtr< T, Ownership >::operator= ( const SharedPtr< T, Ownership > &  other)
inline

Reset shared pointer and attach it to another object.

Definition at line 69 of file shared_ptr.h.

template<class T, template< class TT > class Ownership = RefCntOwnership>
void roc::core::SharedPtr< T, Ownership >::reset ( T *  ptr = NULL)
inline

Reset shared pointer and attach it to another object.

Definition at line 75 of file shared_ptr.h.


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