GL Studio C++ Runtime API
WeakRef< T > Class Template Reference

#include <weak_reference.h>

Public Member Functions

 WeakRef ()
 
 WeakRef (WeakReferenceable *weakReferenceable)
 
 WeakRef (const WeakRef &w)
 
template<class U >
 WeakRef (const WeakRef< U > &w)
 
WeakRefoperator= (WeakReferenceable *weakReferenceable)
 
WeakRefoperator= (const WeakRef &w)
 
template<class U >
WeakRefoperator= (const WeakRef< U > &w)
 
bool IsNull () const
 
T * Get () const
 
WeakReferenceableGetWeakReferenceable () const
 

Detailed Description

template<class T>
class disti::WeakRef< T >

helper class to simplify working with a weak reference Ex Usage: DisplayObject* obj = GetSomeDisplayObject(); WeakRef< DisplayObject > weakRef = obj; ... ... some code that may or may not have deleted obj ... if( !weakRef.IsNull() ) { weakRef.Get()->Location( 0, 0, 0 ); }

Constructor & Destructor Documentation

◆ WeakRef() [1/4]

WeakRef ( )
inline

default ctor – initializes weak reference to NULL

◆ WeakRef() [2/4]

WeakRef ( WeakReferenceable weakReferenceable)
inline

construct from a WeakReferenceable pointer

Parameters
[in]weakReferenceablepointer to an WeakReferenceable interface ( can be NULL )

◆ WeakRef() [3/4]

WeakRef ( const WeakRef< T > &  w)
inline

construct from an WeakRef< T >

Parameters
[in]wWeakRef< T > ( can be NULL )

◆ WeakRef() [4/4]

WeakRef ( const WeakRef< U > &  w)
inline

construct from an WeakRef< U >

Parameters
[in]wWeakRef< U > ( can be NULL )

Member Function Documentation

◆ Get()

T * Get ( ) const
inline

Get a T*

Returns
if referent exists and supports interface T then return a pointer to T, else return NULL

◆ GetWeakReferenceable()

WeakReferenceable * GetWeakReferenceable ( ) const
inline

get the WeakReferenceable* contained in this weak ref

Returns
the WeakReferenceable pointer contained in this weak ref ( can be NULL )

◆ IsNull()

bool IsNull ( ) const
inline

determine if weak reference is NULL

Returns
true if weak ref is NULL else false

◆ operator=() [1/3]

WeakRef & operator= ( const WeakRef< T > &  w)
inline

assign this pointer to point to the given WeakRef< T >

Parameters
wWeakRef< T > in question (can be NULL)
Returns
a ref to this

◆ operator=() [2/3]

WeakRef & operator= ( const WeakRef< U > &  w)
inline

assign this pointer to point to the given WeakRef< U >

Parameters
wWeakRef< U > in question (can be NULL)
Returns
a ref to this

◆ operator=() [3/3]

WeakRef & operator= ( WeakReferenceable weakReferenceable)
inline

assign this weak ref to reference the given WeakReferenceable*

Parameters
weakReferenceableWeakReferenceable* in question (can be NULL)
Returns
a ref to this

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