Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions | Friends | List of all members
Ogre::SharedPtr< T > Class Template Reference

Reference-counted shared pointer, used for objects where implicit destruction is required. More...

#include <OgreSharedPtr.h>

Public Member Functions

 SharedPtr ()
 Constructor, does not initialise the SharedPtr. More...
 
 SharedPtr (const SharedPtr &r)
 
template<class Y >
 SharedPtr (const SharedPtr< Y > &r)
 
template<class Y >
 SharedPtr (Y *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
 Constructor. More...
 
 ~SharedPtr ()
 
void bind (T *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
 Binds rep to the SharedPtr. More...
 
template<typename Y >
SharedPtr< Y > dynamicCast () const
 
T * get () const
 
T * getPointer () const
 
bool isNull (void) const
 
T & operator* () const
 
T * operator-> () const
 
SharedPtroperator= (const SharedPtr &r)
 
template<class Y >
SharedPtroperator= (const SharedPtr< Y > &r)
 
void setNull (void)
 
void setUseCount (unsigned value)
 
template<typename Y >
SharedPtr< Y > staticCast () const
 
bool unique () const
 
unsigned int useCount () const
 

Protected Member Functions

 SharedPtr (T *rep, SharedPtrInfo *info)
 
void destroy (void)
 IF YOU GET A CRASH HERE, YOU FORGOT TO FREE UP POINTERS BEFORE SHUTTING OGRE DOWN Use setNull() before shutdown or make sure your pointer goes out of scope before OGRE shuts down to avoid this. More...
 
void release (void)
 
void swap (SharedPtr< T > &other)
 

Protected Attributes

SharedPtrInfopInfo
 
T * pRep
 

Static Private Member Functions

static SharedPtrInfocreateInfoForMethod (T *rep, SharedPtrFreeMethod method)
 

Friends

template<typename Y >
class SharedPtr
 

Detailed Description

template<class T>
class Ogre::SharedPtr< T >

Reference-counted shared pointer, used for objects where implicit destruction is required.

Remarks
This is a standard shared pointer implementation which uses a reference count to work out when to delete the object.
If OGRE_THREAD_SUPPORT is defined to be 1, use of this class is thread-safe.

Definition at line 111 of file OgreSharedPtr.h.

Constructor & Destructor Documentation

◆ SharedPtr() [1/5]

template<class T >
Ogre::SharedPtr< T >::SharedPtr ( T *  rep,
SharedPtrInfo info 
)
protected

Definition at line 130 of file OgreSharedPtr.h.

◆ SharedPtr() [2/5]

template<class T >
Ogre::SharedPtr< T >::SharedPtr ( )

Constructor, does not initialise the SharedPtr.

Remarks
Dangerous! You have to call bind() before using the SharedPtr.

Definition at line 139 of file OgreSharedPtr.h.

◆ SharedPtr() [3/5]

template<class T >
template<class Y >
Ogre::SharedPtr< T >::SharedPtr ( Y *  rep,
SharedPtrFreeMethod  inFreeMethod = SPFM_DELETE 
)
explicit

Constructor.

Parameters
repThe pointer to take ownership of
inFreeMethodThe mechanism to use to free the pointer

Definition at line 160 of file OgreSharedPtr.h.

◆ SharedPtr() [4/5]

template<class T >
Ogre::SharedPtr< T >::SharedPtr ( const SharedPtr< T > &  r)

◆ SharedPtr() [5/5]

template<class T >
template<class Y >
Ogre::SharedPtr< T >::SharedPtr ( const SharedPtr< Y > &  r)

◆ ~SharedPtr()

template<class T >
Ogre::SharedPtr< T >::~SharedPtr ( )

Definition at line 228 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::release().

Member Function Documentation

◆ bind()

template<class T >
void Ogre::SharedPtr< T >::bind ( T *  rep,
SharedPtrFreeMethod  inFreeMethod = SPFM_DELETE 
)

Binds rep to the SharedPtr.

Remarks
Assumes that the SharedPtr is uninitialised!
Warning
The object must not be bound into a SharedPtr elsewhere

Definition at line 263 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::createInfoForMethod(), Ogre::SharedPtr< T >::pInfo, and Ogre::SharedPtr< T >::pRep.

◆ createInfoForMethod()

template<class T >
static SharedPtrInfo * Ogre::SharedPtr< T >::createInfoForMethod ( T *  rep,
SharedPtrFreeMethod  method 
)
staticprivate

◆ destroy()

template<class T >
void Ogre::SharedPtr< T >::destroy ( void  )
protected

IF YOU GET A CRASH HERE, YOU FORGOT TO FREE UP POINTERS BEFORE SHUTTING OGRE DOWN Use setNull() before shutdown or make sure your pointer goes out of scope before OGRE shuts down to avoid this.

Definition at line 303 of file OgreSharedPtr.h.

References Ogre::MEMCATEGORY_GENERAL, OGRE_DELETE_T, Ogre::SharedPtr< T >::pInfo, and Ogre::SharedPtr< T >::pRep.

Referenced by Ogre::SharedPtr< T >::release().

◆ dynamicCast()

template<class T >
template<typename Y >
SharedPtr< Y > Ogre::SharedPtr< T >::dynamicCast ( ) const

◆ get()

template<class T >
T * Ogre::SharedPtr< T >::get ( void  ) const

◆ getPointer()

template<class T >
T * Ogre::SharedPtr< T >::getPointer ( ) const

◆ isNull()

template<class T >
bool Ogre::SharedPtr< T >::isNull ( void  ) const

◆ operator*()

template<class T >
T & Ogre::SharedPtr< T >::operator* ( ) const

Definition at line 252 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::pRep.

◆ operator->()

template<class T >
T * Ogre::SharedPtr< T >::operator-> ( ) const

Definition at line 253 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::pRep.

◆ operator=() [1/2]

template<class T >
SharedPtr & Ogre::SharedPtr< T >::operator= ( const SharedPtr< T > &  r)

◆ operator=() [2/2]

template<class T >
template<class Y >
SharedPtr & Ogre::SharedPtr< T >::operator= ( const SharedPtr< Y > &  r)

Definition at line 217 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::pRep, and Ogre::SharedPtr< T >::swap().

◆ release()

template<class T >
void Ogre::SharedPtr< T >::release ( void  )
protected

◆ setNull()

template<class T >
void Ogre::SharedPtr< T >::setNull ( void  )

Definition at line 277 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::pRep, and Ogre::SharedPtr< T >::release().

◆ setUseCount()

template<class T >
void Ogre::SharedPtr< T >::setUseCount ( unsigned  value)

Definition at line 271 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::pInfo, and Ogre::SharedPtrInfo::useCount.

◆ staticCast()

template<class T >
template<typename Y >
SharedPtr< Y > Ogre::SharedPtr< T >::staticCast ( ) const

◆ swap()

template<class T >
void Ogre::SharedPtr< T >::swap ( SharedPtr< T > &  other)
protected

◆ unique()

template<class T >
bool Ogre::SharedPtr< T >::unique ( ) const

◆ useCount()

template<class T >
unsigned int Ogre::SharedPtr< T >::useCount ( ) const

Friends And Related Function Documentation

◆ SharedPtr

template<class T >
template<typename Y >
friend class SharedPtr
friend

Definition at line 113 of file OgreSharedPtr.h.

Member Data Documentation

◆ pInfo

template<class T >
SharedPtrInfo* Ogre::SharedPtr< T >::pInfo
protected

◆ pRep

template<class T >
T* Ogre::SharedPtr< T >::pRep
protected

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

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.