Ogre::SharedPtr< T > Class Template Reference
Core » General

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

`#include <OgrePrerequisites.h>`

## Public Member Functions

| SharedPtr ()
| Constructor, does not initialise the SharedPtr. More...
template<class Y >
| SharedPtr (Y *rep, SharedPtrFreeMethod inFreeMethod=SPFM_DELETE)
| Constructor. More...
| SharedPtr (const SharedPtr &r)
template<class Y >
| SharedPtr (const SharedPtr< Y > &r)
| ~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
SharedPtr & | operator= (const SharedPtr &r)
template<class Y >
SharedPtr & | operator= (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

SharedPtrInfo * | pInfo
T * | pRep

## Static Private Member Functions

static SharedPtrInfo * | createInfoForMethod (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 310 of file OgrePrerequisites.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

  rep | The pointer to take ownership of
  inFreeMethod | The 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 | ) |

Definition at line 166 of file OgreSharedPtr.h.

## SharedPtr() [5/5]

template<class T>
template<class Y >

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

Definition at line 200 of file OgreSharedPtr.h.

## ~SharedPtr()

template<class T>

Ogre::SharedPtr< T >::~SharedPtr | ( |  | ) |

Definition at line 228 of file OgreSharedPtr.h.

## 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.

## createInfoForMethod()

template<class T>

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

static private

Definition at line 143 of file OgreSharedPtr.h.

## 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.

## dynamicCast()

template<class T>
template<typename Y >

SharedPtr<Y> Ogre::SharedPtr< T >::dynamicCast | ( |  | ) | const

Definition at line 243 of file OgreSharedPtr.h.

## get()

template<class T>

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

Definition at line 254 of file OgreSharedPtr.h.

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

## getPointer()

template<class T>

T* Ogre::SharedPtr< T >::getPointer | ( |  | ) | const

Definition at line 273 of file OgreSharedPtr.h.

Referenced by Ogre::HighLevelGpuProgram::_getBindingDelegate().

## isNull()

template<class T>

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

Definition at line 275 of file OgreSharedPtr.h.

Referenced by Ogre::GpuProgram::hasDefaultParameters(), Ogre::GpuProgramParameters::hasLogicalIndexedParameters(), Ogre::GpuProgramParameters::hasNamedParameters(), and Ogre::ResourceManager::resourceExists().

## operator*()

template<class T>

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

Definition at line 252 of file OgreSharedPtr.h.

## operator->()

template<class T>

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

Definition at line 253 of file OgreSharedPtr.h.

## operator=() [1/2]

template<class T>

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

Definition at line 176 of file OgreSharedPtr.h.

## 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.

## release()

template<class T>

void Ogre::SharedPtr< T >::release | ( | void |  | ) |

protected

Definition at line 286 of file OgreSharedPtr.h.

## setNull()

template<class T>

void Ogre::SharedPtr< T >::setNull | ( | void |  | ) |

Definition at line 277 of file OgreSharedPtr.h.

## setUseCount()

template<class T>

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

Definition at line 271 of file OgreSharedPtr.h.

## staticCast()

template<class T>
template<typename Y >

SharedPtr<Y> Ogre::SharedPtr< T >::staticCast | ( |  | ) | const

Definition at line 234 of file OgreSharedPtr.h.

## swap()

template<class T>

void Ogre::SharedPtr< T >::swap | ( | SharedPtr< T > & | other | ) |

protected

Definition at line 309 of file OgreSharedPtr.h.

## unique()

template<class T>

bool Ogre::SharedPtr< T >::unique | ( |  | ) | const

Definition at line 269 of file OgreSharedPtr.h.

## useCount()

template<class T>

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

Definition at line 270 of file OgreSharedPtr.h.

## 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

Definition at line 128 of file OgreSharedPtr.h.

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

## pRep

template<class T>

T* Ogre::SharedPtr< T >::pRep

protected

Definition at line 127 of file OgreSharedPtr.h.

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

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

- OgrePrerequisites.h
- OgreSharedPtr.h

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