OGRE  1.9.0
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.
 
 SharedPtr (const SharedPtr &r)
 
template<class Y >
 SharedPtr (const SharedPtr< Y > &r)
 
template<class Y >
 SharedPtr (Y *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
 Constructor.
 
 ~SharedPtr ()
 
void bind (T *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
 Binds rep to the SharedPtr.
 
template<typename Y >
SharedPtr< YdynamicCast () const
 
Tget () const
 
TgetPointer () const
 
bool isNull (void) const
 
Toperator* () const
 
Toperator-> () const
 
SharedPtroperator= (const SharedPtr &r)
 
template<class Y >
SharedPtroperator= (const SharedPtr< Y > &r)
 
void setNull (void)
 
void setUseCount (unsigned value)
 
template<typename Y >
SharedPtr< YstaticCast () 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.
 
void release (void)
 
void swap (SharedPtr< T > &other)
 

Protected Attributes

SharedPtrInfopInfo
 
TpRep
 

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 117 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 136 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 145 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 167 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 238 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 273 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::SharedPtr, 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 313 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::SharedPtr, 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 ( ) 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 262 of file OgreSharedPtr.h.

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

◆ operator->()

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

Definition at line 263 of file OgreSharedPtr.h.

References Ogre::SharedPtr< T >::SharedPtr, and 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)

◆ release()

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

◆ setNull()

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

Definition at line 287 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)

◆ 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 Symbol Documentation

◆ SharedPtr

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

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: