Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
roc::core::SharedPtr< T, OwnershipPolicy > 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, OwnershipPolicy > &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 (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 OwnershipPolicy = RefCountedOwnership>
class roc::core::SharedPtr< T, OwnershipPolicy >

Shared ownership intrusive pointer.

Template Parameters
Tdefines pointee type. It may be const.
OwnershipPolicydefines ownwership policy. It provides methods to increase and decrease the reference counter embedded into object.

If RefCountedOwnership is used, T should inherit RefCounted. A template parameter of RefCounted defines its (de)allocation policy.

Definition at line 32 of file shared_ptr.h.

Constructor & Destructor Documentation

◆ SharedPtr() [1/4]

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
roc::core::SharedPtr< T, OwnershipPolicy >::SharedPtr ( )
inline

Create empty shared pointer.

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

Definition at line 37 of file shared_ptr.h.

◆ SharedPtr() [2/4]

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

Create shared pointer from raw pointer.

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

Definition at line 44 of file shared_ptr.h.

◆ SharedPtr() [3/4]

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

Create shared pointer from shared pointer of the same type.

Remarks
This is a copy constructor.

Definition at line 52 of file shared_ptr.h.

◆ SharedPtr() [4/4]

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
template<class TT >
roc::core::SharedPtr< T, OwnershipPolicy >::SharedPtr ( const SharedPtr< TT, OwnershipPolicy > &  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 62 of file shared_ptr.h.

◆ ~SharedPtr()

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

Destroy shared pointer.

Definition at line 68 of file shared_ptr.h.

Member Function Documentation

◆ get()

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

Get underlying pointer.

Definition at line 93 of file shared_ptr.h.

◆ operator const struct unspecified_bool *()

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

Convert to bool.

Definition at line 114 of file shared_ptr.h.

◆ operator*()

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

Get underlying reference.

Definition at line 106 of file shared_ptr.h.

◆ operator->()

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

Get underlying pointer.

Definition at line 98 of file shared_ptr.h.

◆ operator=()

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

Reset shared pointer and attach it to another object.

Definition at line 73 of file shared_ptr.h.

◆ reset() [1/2]

template<class T , template< class TT > class OwnershipPolicy = RefCountedOwnership>
void roc::core::SharedPtr< T, OwnershipPolicy >::reset ( const SharedPtr< T, OwnershipPolicy > &  other)
inline

Reset shared pointer and attach it to another object.

Definition at line 79 of file shared_ptr.h.

◆ reset() [2/2]

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

Reset shared pointer and attach it to another object.

Definition at line 84 of file shared_ptr.h.


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