i6engine  1.0
i6e::utils::sharedPtr< T, U > Class Template Reference

A shared pointer counting references and adds objects being not referenced any more to an internal list required external call of clear to delete all objects, no automatic deletion to stay threadsafe T = type of the pointer, U = base type of the pointer. More...

#include <D:/Projekte/i6engine/libs/i6engine-utils/include/i6engine/utils/sharedPtr.h>

Public Member Functions

 sharedPtr ()
 default constructor creating a sharedPtr containing a nullptr More...
 
 sharedPtr (T *ptr)
 normal constructor taking pointer to object to be stored More...
 
 sharedPtr (const sharedPtr &other)
 copy constructor sharing reference and incrementing refCounter More...
 
 sharedPtr (sharedPtr &&other)
 move constructor More...
 
template<typename V >
 sharedPtr (const sharedPtr< V, U > &other)
 upcast derived => base More...
 
 ~sharedPtr ()
 destructor, adding pointer of object to clearList if last reference was deleted More...
 
const sharedPtroperator= (const sharedPtr &other)
 assignment operator More...
 
const sharedPtroperator= (sharedPtr &&other)
 move assignment operator More...
 
template<typename V >
const sharedPtroperator= (const sharedPtr< V, U > &other)
 upcast, derived => base More...
 
T * operator-> () const
 -> operator returning stored pointer More...
 
bool operator== (const sharedPtr &other) const
 comparison between two shared pointer More...
 
bool operator== (const T *other) const
 comparison between shared and normal pointer More...
 
bool operator!= (const sharedPtr &other) const
 
bool operator!= (const T *other) const
 
T * get () const
 returns the contained pointer More...
 

Static Public Member Functions

static void clear ()
 deletes all pointers in clearList More...
 

Friends

class weakPtr< T, U >
 
template<typename V , typename W >
class sharedPtr
 
template<typename V , typename W >
class weakPtr
 
struct sharedPtrWrapper< T >
 
template<typename T1 , typename T2 , typename U1 >
sharedPtr< T1, U1 > dynamic_pointer_cast (const sharedPtr< T2, U1 > &)
 
template<typename T1 , typename U2 , typename... Args>
sharedPtr< T1, U2 > make_shared (Args &&...)
 
bool operator== (const T *other, const sharedPtr &self)
 
bool operator!= (const T *other, const sharedPtr &self)
 

Detailed Description

template<typename T, typename U>
class i6e::utils::sharedPtr< T, U >

A shared pointer counting references and adds objects being not referenced any more to an internal list required external call of clear to delete all objects, no automatic deletion to stay threadsafe T = type of the pointer, U = base type of the pointer.

Definition at line 50 of file sharedPtr.h.

Constructor & Destructor Documentation

template<typename T, typename U>
i6e::utils::sharedPtr< T, U >::sharedPtr ( )
inline

default constructor creating a sharedPtr containing a nullptr

Definition at line 84 of file sharedPtr.h.

template<typename T, typename U>
i6e::utils::sharedPtr< T, U >::sharedPtr ( T *  ptr)
inlineexplicit

normal constructor taking pointer to object to be stored

Definition at line 90 of file sharedPtr.h.

template<typename T, typename U>
i6e::utils::sharedPtr< T, U >::sharedPtr ( const sharedPtr< T, U > &  other)
inline

copy constructor sharing reference and incrementing refCounter

Definition at line 97 of file sharedPtr.h.

template<typename T, typename U>
i6e::utils::sharedPtr< T, U >::sharedPtr ( sharedPtr< T, U > &&  other)
inline

move constructor

Definition at line 103 of file sharedPtr.h.

template<typename T, typename U>
template<typename V >
i6e::utils::sharedPtr< T, U >::sharedPtr ( const sharedPtr< V, U > &  other)
inline

upcast derived => base

Definition at line 112 of file sharedPtr.h.

template<typename T, typename U>
i6e::utils::sharedPtr< T, U >::~sharedPtr ( )
inline

destructor, adding pointer of object to clearList if last reference was deleted

Definition at line 118 of file sharedPtr.h.

Member Function Documentation

template<typename T, typename U>
static void i6e::utils::sharedPtr< T, U >::clear ( )
inlinestatic

deletes all pointers in clearList

Definition at line 203 of file sharedPtr.h.

template<typename T, typename U>
T* i6e::utils::sharedPtr< T, U >::get ( ) const
inline

returns the contained pointer

Definition at line 214 of file sharedPtr.h.

template<typename T, typename U>
bool i6e::utils::sharedPtr< T, U >::operator!= ( const sharedPtr< T, U > &  other) const
inline

Definition at line 188 of file sharedPtr.h.

template<typename T, typename U>
bool i6e::utils::sharedPtr< T, U >::operator!= ( const T *  other) const
inline

Definition at line 196 of file sharedPtr.h.

template<typename T, typename U>
T* i6e::utils::sharedPtr< T, U >::operator-> ( ) const
inline

-> operator returning stored pointer

Definition at line 166 of file sharedPtr.h.

template<typename T, typename U>
const sharedPtr& i6e::utils::sharedPtr< T, U >::operator= ( const sharedPtr< T, U > &  other)
inline

assignment operator

Definition at line 124 of file sharedPtr.h.

template<typename T, typename U>
const sharedPtr& i6e::utils::sharedPtr< T, U >::operator= ( sharedPtr< T, U > &&  other)
inline

move assignment operator

Definition at line 137 of file sharedPtr.h.

template<typename T, typename U>
template<typename V >
const sharedPtr& i6e::utils::sharedPtr< T, U >::operator= ( const sharedPtr< V, U > &  other)
inline

upcast, derived => base

Definition at line 153 of file sharedPtr.h.

template<typename T, typename U>
bool i6e::utils::sharedPtr< T, U >::operator== ( const sharedPtr< T, U > &  other) const
inline

comparison between two shared pointer

Definition at line 173 of file sharedPtr.h.

template<typename T, typename U>
bool i6e::utils::sharedPtr< T, U >::operator== ( const T *  other) const
inline

comparison between shared and normal pointer

Definition at line 180 of file sharedPtr.h.

Friends And Related Function Documentation

template<typename T, typename U>
template<typename T1 , typename T2 , typename U1 >
sharedPtr<T1, U1> dynamic_pointer_cast ( const sharedPtr< T2, U1 > &  )
friend
template<typename T, typename U>
template<typename T1 , typename U2 , typename... Args>
sharedPtr<T1, U2> make_shared ( Args &&  ...)
friend
template<typename T, typename U>
bool operator!= ( const T *  other,
const sharedPtr< T, U > &  self 
)
friend

Definition at line 192 of file sharedPtr.h.

template<typename T, typename U>
bool operator== ( const T *  other,
const sharedPtr< T, U > &  self 
)
friend

Definition at line 184 of file sharedPtr.h.

template<typename T, typename U>
template<typename V , typename W >
friend class sharedPtr
friend

Definition at line 75 of file sharedPtr.h.

template<typename T, typename U>
friend struct sharedPtrWrapper< T >
friend

Definition at line 78 of file sharedPtr.h.

template<typename T, typename U>
template<typename V , typename W >
friend class weakPtr
friend

Definition at line 77 of file sharedPtr.h.

template<typename T, typename U>
friend class weakPtr< T, U >
friend

Definition at line 73 of file sharedPtr.h.


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