torque Torque Game Engine Documentation
TGE Version 1.5.2

SimObjectPtr< T > Class Template Reference

#include <simBase.h>

Inheritance diagram for SimObjectPtr< T >:

Inheritance graph
[legend]

Detailed Description


template<class T> class SimObjectPtr< T >

Smart SimObject pointer.

This class keeps track of the book-keeping necessary to keep a registered reference to a SimObject or subclass thereof.

Normally, if you want the SimObject to be aware that you have a reference to it, you must call SimObject::registerReference() when you create the reference, and SimObject::unregisterReference() when you're done. If you change the reference, you must also register/unregister it. This is a big headache, so this class exists to automatically keep track of things for you.

     // Assign an object to the
     SimObjectPtr<GameBase> mOrbitObject = Sim::findObject("anObject");

     // Use it as a GameBase*.
     mOrbitObject->getWorldBox().getCenter(&mPosition);

     // And reassign it - it will automatically update the references.
     mOrbitObject = Sim::findObject("anotherObject");


Public Member Functions

 SimObjectPtr ()
 SimObjectPtr (T *ptr)
 SimObjectPtr (const SimObjectPtr< T > &rhs)
SimObjectPtr< T > & operator= (const SimObjectPtr< T > &rhs)
 ~SimObjectPtr ()
SimObjectPtr< T > & operator= (T *ptr)
bool isNull () const
T * operator-> () const
T & operator * () const
 operator T * () const

Private Attributes

SimObjectmObj


Constructor & Destructor Documentation

template<class T>
SimObjectPtr< T >::SimObjectPtr (  )  [inline]

template<class T>
SimObjectPtr< T >::SimObjectPtr ( T *  ptr  )  [inline]

template<class T>
SimObjectPtr< T >::SimObjectPtr ( const SimObjectPtr< T > &  rhs  )  [inline]

template<class T>
SimObjectPtr< T >::~SimObjectPtr (  )  [inline]


Member Function Documentation

template<class T>
SimObjectPtr<T>& SimObjectPtr< T >::operator= ( const SimObjectPtr< T > &  rhs  )  [inline]

template<class T>
SimObjectPtr<T>& SimObjectPtr< T >::operator= ( T *  ptr  )  [inline]

template<class T>
bool SimObjectPtr< T >::isNull (  )  const [inline]

template<class T>
T* SimObjectPtr< T >::operator-> (  )  const [inline]

template<class T>
T& SimObjectPtr< T >::operator * (  )  const [inline]

template<class T>
SimObjectPtr< T >::operator T * (  )  const [inline]


Field Documentation

template<class T>
SimObject* SimObjectPtr< T >::mObj [private]




All Rights Reserved GarageGames.com, Inc. 1999-2005
Auto-magically Generated with Doxygen