| GL Studio C++ Runtime API

Classes | Public Member Functions | List of all members
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)
WeakRef & | operator= (WeakReferenceable *weakReferenceable)
WeakRef & | operator= (const WeakRef &w)
template<class U >
WeakRef & | operator= (const WeakRef< U > &w)
bool | IsNull () const
T * | Get () const
WeakReferenceable * | GetWeakReferenceable () 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] | weakReferenceable | pointer to an WeakReferenceable interface ( can be NULL )

## ◆ WeakRef() [3/4]

WeakRef | ( | const WeakRef< T > & | w | ) |
| inline

construct from an WeakRef< T >

Parameters

  [in] | w | WeakRef< T > ( can be NULL )

## ◆ WeakRef() [4/4]

WeakRef | ( | const WeakRef< U > & | w | ) |
| inline

construct from an WeakRef< U >

Parameters

  [in] | w | WeakRef< 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

  w | WeakRef< 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

  w | WeakRef< 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

  weakReferenceable | WeakReferenceable* in question (can be NULL)

Returns
  a ref to this

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

- weak_reference.h