Torque2D Reference
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
SimObjectPtr< T > Class Template Reference

#include <simObjectPtr.h>

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
 
bool notNull () const
 
T * operator-> () const
 
T & operator* () const
 
 operator T * () const
 

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");

Constructor & Destructor Documentation

SimObjectPtr ( )
inline
SimObjectPtr ( T *  ptr)
inline
SimObjectPtr ( const SimObjectPtr< T > &  rhs)
inline
~SimObjectPtr ( )
inline

Member Function Documentation

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

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