Torque2D Reference
Loading...
Searching...
No Matches
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");
Definition simObjectPtr.h:56
SimObject * findObject(SimObjectId)
Definition simManager.cc:384

Constructor & Destructor Documentation

◆ SimObjectPtr() [1/3]

template<class T >
SimObjectPtr ( )
inline

◆ SimObjectPtr() [2/3]

template<class T >
SimObjectPtr ( T *  ptr)
inline

◆ SimObjectPtr() [3/3]

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

◆ ~SimObjectPtr()

template<class T >
~SimObjectPtr ( )
inline

Member Function Documentation

◆ isNull()

template<class T >
bool isNull ( ) const
inline

◆ notNull()

template<class T >
bool notNull ( ) const
inline

◆ operator T*()

template<class T >
operator T* ( ) const
inline

◆ operator*()

template<class T >
T & operator* ( ) const
inline

◆ operator->()

template<class T >
T * operator-> ( ) const
inline

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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