FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::SharedPtr< T > Class Template Reference

shared pointer implementation to provide automatic reference counting and deletion when last reference falls out of scope. More...

#include <sharedptr.h>

+ Inheritance diagram for FIFE::SharedPtr< T >:
+ Collaboration diagram for FIFE::SharedPtr< T >:

Public Member Functions

 SharedPtr ()
 Constructor default constructor creates a null shared pointer. More...
 
template<typename U >
 SharedPtr (U *ptr)
 Constructor takes over ownership of the provided pointer and will delete it automatically when last reference falls out of scope. More...
 
 SharedPtr (const SharedPtr &rhs)
 Copy Constructor provides ability to properly copy a shared resource. More...
 
template<typename U >
 SharedPtr (const SharedPtr< U > &rhs)
 Constructor shares ownership with the value passed into rhs the pointer type passed in must be convertible to this shared pointer type. More...
 
 ~SharedPtr ()
 Destructor handles deletion of underlying pointer if the reference count reaches 0. More...
 
SharedPtroperator= (const SharedPtr &rhs)
 provides functionality for the equality operator More...
 
template<typename U >
SharedPtroperator= (const SharedPtr< U > &rhs)
 provides functionality for the equality operator the passed in pointer type must be convertible to this pointer type More...
 
T & operator* () const
 allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer More...
 
T * operator-> () const
 allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer More...
 
T * get () const
 allows direct access to underlying pointer More...
 
void reset (T *ptr=0)
 reset this pointer to a null shared pointer this can be used to lower the reference count of the shared resource or set the underlying pointer to different pointer. More...
 
uint32_t useCount () const
 returns the current reference count this should only be called on a non-null shared pointer More...
 
uint32_t * useCountPtr () const
 returns the current reference count provides direct access to the user count pointer this should really only be used internally More...
 
bool unique () const
 provides the ability to see if a shared resource is currently only held by a single shared pointer this should only be called on a non-null shared pointer More...
 
 operator bool () const
 provides the ability to convert a shared pointer to a bool, this is a convenience for checking validity of a shared pointer in a conditional More...
 
bool operator! () const
 negation operator overload More...
 

Private Member Functions

void swap (SharedPtr< T > &rhs)
 provides swapping function between two shared pointers, used internally More...
 
void incRefCount ()
 increases the reference count for this shared resource, used internally More...
 
void decRefCount ()
 decreases the reference count for this shared resource, used internally More...
 

Private Attributes

T * m_ptr
 
uint32_t * m_refCount
 

Detailed Description

template<typename T>
class FIFE::SharedPtr< T >

shared pointer implementation to provide automatic reference counting and deletion when last reference falls out of scope.

Definition at line 42 of file sharedptr.h.

Constructor & Destructor Documentation

template<typename T>
FIFE::SharedPtr< T >::SharedPtr ( )
inline

Constructor default constructor creates a null shared pointer.

Definition at line 49 of file sharedptr.h.

template<typename T>
template<typename U >
FIFE::SharedPtr< T >::SharedPtr ( U *  ptr)
inlineexplicit

Constructor takes over ownership of the provided pointer and will delete it automatically when last reference falls out of scope.

Definition at line 60 of file sharedptr.h.

template<typename T>
FIFE::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  rhs)
inline

Copy Constructor provides ability to properly copy a shared resource.

Definition at line 68 of file sharedptr.h.

template<typename T>
template<typename U >
FIFE::SharedPtr< T >::SharedPtr ( const SharedPtr< U > &  rhs)
inline

Constructor shares ownership with the value passed into rhs the pointer type passed in must be convertible to this shared pointer type.

Definition at line 80 of file sharedptr.h.

template<typename T>
FIFE::SharedPtr< T >::~SharedPtr ( )
inline

Destructor handles deletion of underlying pointer if the reference count reaches 0.

Definition at line 90 of file sharedptr.h.

Member Function Documentation

template<typename T>
void FIFE::SharedPtr< T >::decRefCount ( )
inlineprivate

decreases the reference count for this shared resource, used internally

Definition at line 239 of file sharedptr.h.

Referenced by FIFE::SharedPtr< RenderTarget >::~SharedPtr().

+ Here is the caller graph for this function:

template<typename T>
void FIFE::SharedPtr< T >::incRefCount ( )
inlineprivate

increases the reference count for this shared resource, used internally

Definition at line 230 of file sharedptr.h.

Referenced by FIFE::SharedPtr< RenderTarget >::SharedPtr().

+ Here is the caller graph for this function:

template<typename T>
FIFE::SharedPtr< T >::operator bool ( ) const
inline

provides the ability to convert a shared pointer to a bool, this is a convenience for checking validity of a shared pointer in a conditional

Definition at line 207 of file sharedptr.h.

template<typename T>
bool FIFE::SharedPtr< T >::operator! ( ) const
inline

negation operator overload

Definition at line 213 of file sharedptr.h.

template<typename T>
T& FIFE::SharedPtr< T >::operator* ( ) const
inline

allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer

Definition at line 140 of file sharedptr.h.

template<typename T>
T* FIFE::SharedPtr< T >::operator-> ( ) const
inline

allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer

Definition at line 148 of file sharedptr.h.

template<typename T>
SharedPtr& FIFE::SharedPtr< T >::operator= ( const SharedPtr< T > &  rhs)
inline

provides functionality for the equality operator

Definition at line 106 of file sharedptr.h.

template<typename T>
template<typename U >
SharedPtr& FIFE::SharedPtr< T >::operator= ( const SharedPtr< U > &  rhs)
inline

provides functionality for the equality operator the passed in pointer type must be convertible to this pointer type

Definition at line 124 of file sharedptr.h.

template<typename T>
void FIFE::SharedPtr< T >::reset ( T *  ptr = 0)
inline

reset this pointer to a null shared pointer this can be used to lower the reference count of the shared resource or set the underlying pointer to different pointer.

Definition at line 164 of file sharedptr.h.

Referenced by FIFE::SoundEmitter::detachSoundClip(), FIFE::Cursor::invalidate(), FIFE::AtlasLoader::loadAtlas(), FIFE::MapLoader::MapLoader(), FIFE::ObjectLoader::ObjectLoader(), FIFE::RenderItem::reset(), FIFE::SoundEmitter::reset(), FIFE::Cursor::resetDrag(), FIFE::Camera::resetOverlayAnimation(), fcn::ResizableWindow::saveCursor(), FIFE::Cursor::set(), fcn::ResizableWindow::set(), and FIFE::Cursor::setDrag().

+ Here is the caller graph for this function:

template<typename T>
void FIFE::SharedPtr< T >::swap ( SharedPtr< T > &  rhs)
inlineprivate

provides swapping function between two shared pointers, used internally

Definition at line 222 of file sharedptr.h.

Referenced by FIFE::SharedPtr< RenderTarget >::operator=(), and FIFE::SharedPtr< RenderTarget >::reset().

+ Here is the caller graph for this function:

template<typename T>
bool FIFE::SharedPtr< T >::unique ( ) const
inline

provides the ability to see if a shared resource is currently only held by a single shared pointer this should only be called on a non-null shared pointer

Definition at line 197 of file sharedptr.h.

template<typename T>
uint32_t FIFE::SharedPtr< T >::useCount ( ) const
inline

returns the current reference count this should only be called on a non-null shared pointer

Definition at line 173 of file sharedptr.h.

template<typename T>
uint32_t* FIFE::SharedPtr< T >::useCountPtr ( ) const
inline

returns the current reference count provides direct access to the user count pointer this should really only be used internally

Definition at line 187 of file sharedptr.h.

Referenced by FIFE::SharedPtr< RenderTarget >::SharedPtr().

+ Here is the caller graph for this function:

Member Data Documentation


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