Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Ogre::SharedPtr< T > Class Template Reference

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

#include <OgreSharedPtr.h>

List of all members.

Public Member Functions

OGRE_AUTO_SHARED_MUTEX SharedPtr ()
 Constructor, does not initialise the SharedPtr.
template<class Y>
 SharedPtr (Y *rep)
 SharedPtr (const SharedPtr &r)
SharedPtroperator= (const SharedPtr &r)
template<class Y>
 SharedPtr (const SharedPtr< Y > &r)
template<class Y>
SharedPtroperator= (const SharedPtr< Y > &r)
virtual ~SharedPtr ()
T & operator * () const
T * operator-> () const
T * get () const
void bind (T *rep)
 Binds rep to the SharedPtr.
bool unique () const
unsigned int useCount () const
unsigned int * useCountPointer () const
T * getPointer () const
bool isNull (void) const
void setNull (void)

Protected Member Functions

void release (void)
virtual void destroy (void)

Protected Attributes

T * pRep
unsigned int * pUseCount


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. OGRE does not use this class very often, because it is usually more efficient to make the destruction of objects more intentional (in blocks, say). However in some cases you really cannot tell how many people are using an object, and this approach is worthwhile (e.g. ControllerValue)
If OGRE_THREAD_SUPPORT is defined to be 1, use of this class is thread-safe.

Definition at line 48 of file OgreSharedPtr.h.


Constructor & Destructor Documentation

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

Constructor, does not initialise the SharedPtr.

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

Definition at line 58 of file OgreSharedPtr.h.

template<class T>
template<class Y>
Ogre::SharedPtr< T >::SharedPtr Y *  rep  )  [explicit]
 

Definition at line 64 of file OgreSharedPtr.h.

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

Definition at line 69 of file OgreSharedPtr.h.

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

Definition at line 114 of file OgreSharedPtr.h.

template<class T>
virtual Ogre::SharedPtr< T >::~SharedPtr  )  [virtual]
 

Definition at line 152 of file OgreSharedPtr.h.


Member Function Documentation

template<class T>
void Ogre::SharedPtr< T >::bind T *  rep  ) 
 

Binds rep to the SharedPtr.

Remarks:
Assumes that the SharedPtr is uninitialised!

Definition at line 165 of file OgreSharedPtr.h.

template<class T>
virtual void Ogre::SharedPtr< T >::destroy void   )  [protected, virtual]
 

Reimplemented in Ogre::MeshPtr.

Definition at line 219 of file OgreSharedPtr.h.

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

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

Definition at line 159 of file OgreSharedPtr.h.

Referenced by Ogre::operator!=(), and Ogre::operator==().

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

Definition at line 177 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=(), and Ogre::SharedPtr< Skeleton >::SharedPtr().

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

Definition at line 179 of file OgreSharedPtr.h.

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

Definition at line 157 of file OgreSharedPtr.h.

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

Definition at line 158 of file OgreSharedPtr.h.

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

Definition at line 134 of file OgreSharedPtr.h.

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

Definition at line 88 of file OgreSharedPtr.h.

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

Definition at line 193 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=(), Ogre::SharedPtr< Skeleton >::setNull(), and Ogre::SharedPtr< Skeleton >::~SharedPtr().

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

Definition at line 181 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=().

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

Definition at line 173 of file OgreSharedPtr.h.

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

Definition at line 174 of file OgreSharedPtr.h.

template<class T>
unsigned int* Ogre::SharedPtr< T >::useCountPointer  )  const
 

Definition at line 175 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=(), and Ogre::SharedPtr< Skeleton >::SharedPtr().


Member Data Documentation

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

Definition at line 50 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=().

template<class T>
unsigned int* Ogre::SharedPtr< T >::pUseCount [protected]
 

Definition at line 51 of file OgreSharedPtr.h.

Referenced by Ogre::SharedPtr< Skeleton >::operator=().


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

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun May 6 10:58:32 2007