FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
shared pointer implementation to provide automatic reference counting and deletion when last reference falls out of scope. More...
#include <sharedptr.h>
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... | |
SharedPtr & | operator= (const SharedPtr &rhs) |
provides functionality for the equality operator More... | |
template<typename U > | |
SharedPtr & | operator= (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 |
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.
|
inline |
Constructor default constructor creates a null shared pointer.
Definition at line 49 of file sharedptr.h.
|
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.
|
inline |
Copy Constructor provides ability to properly copy a shared resource.
Definition at line 68 of file sharedptr.h.
|
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.
|
inline |
Destructor handles deletion of underlying pointer if the reference count reaches 0.
Definition at line 90 of file sharedptr.h.
|
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().
|
inline |
allows direct access to underlying pointer
Definition at line 155 of file sharedptr.h.
Referenced by FIFE::InstanceRenderer::addToCheck(), FIFE::RenderBackendSDL::attachRenderTarget(), FIFE::RenderBackendOpenGL::attachRenderTarget(), FIFE::InstanceRenderer::bindColoring(), FIFE::InstanceRenderer::bindMultiOutline(), FIFE::InstanceRenderer::bindOutline(), FIFE::RenderBackendOpenGL::detachRenderTarget(), FIFE::InstanceRenderer::getMultiColorOverlay(), FIFE::InstanceRenderer::isValidImage(), FIFE::GLImage::load(), FIFE::operator!=(), FIFE::SharedPtr< RenderTarget >::operator=(), FIFE::operator==(), FIFE::InstanceRenderer::removeFromCheck(), FIFE::GLImage::render(), FIFE::RenderBackendOpenGL::renderGuiGeometry(), FIFE::Camera::renderOverlay(), FIFE::Camera::renderStaticLayer(), FIFE::GLImage::renderZ(), FIFE::SharedPtr< RenderTarget >::SharedPtr(), FIFE::SDLImage::useSharedImage(), and FIFE::GLImage::useSharedImage().
|
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().
|
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.
|
inline |
negation operator overload
Definition at line 213 of file sharedptr.h.
|
inline |
allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer
Definition at line 140 of file sharedptr.h.
|
inline |
allows dereferencing of shared pointer to act identical to dereferencing the underlying pointer
Definition at line 148 of file sharedptr.h.
|
inline |
provides functionality for the equality operator
Definition at line 106 of file sharedptr.h.
|
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.
|
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().
|
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().
|
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.
|
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.
|
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().
|
private |
Definition at line 246 of file sharedptr.h.
Referenced by FIFE::SharedPtr< RenderTarget >::get(), FIFE::SharedPtr< RenderTarget >::operator bool(), FIFE::SharedPtr< RenderTarget >::operator!(), FIFE::SharedPtr< RenderTarget >::operator*(), FIFE::SharedPtr< RenderTarget >::operator->(), FIFE::SharedPtr< RenderTarget >::operator=(), FIFE::SharedPtr< RenderTarget >::reset(), FIFE::SharedPtr< RenderTarget >::SharedPtr(), FIFE::SharedPtr< RenderTarget >::swap(), and FIFE::SharedPtr< RenderTarget >::~SharedPtr().
|
private |
Definition at line 247 of file sharedptr.h.
Referenced by FIFE::SharedPtr< RenderTarget >::decRefCount(), FIFE::SharedPtr< RenderTarget >::incRefCount(), FIFE::SharedPtr< RenderTarget >::SharedPtr(), FIFE::SharedPtr< RenderTarget >::swap(), FIFE::SharedPtr< RenderTarget >::unique(), FIFE::SharedPtr< RenderTarget >::useCount(), FIFE::SharedPtr< RenderTarget >::useCountPtr(), and FIFE::SharedPtr< RenderTarget >::~SharedPtr().