Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | Friends | List of all members
jop::WeakReference< T > Class Template Reference

#include <SafeReferenceable.hpp>

Public Member Functions

 WeakReference ()=default
 Default constructor. More...
 
 WeakReference (const SafeReferenceable< T > &ref)
 Constructor for initializing from a SafeReferenceable object. More...
 
bool expired () const
 Check if this reference is expired. More...
 
void reset ()
 Reset this reference. More...
 
T * get ()
 Get a pointer to the bound object. More...
 
const T * get () const
 Get a pointer to the bound object. More...
 
T & operator* ()
 Dereference operator. More...
 
const T & operator* () const
 Dereference operator. More...
 
 operator T & ()
 Dereference operator. More...
 
 operator const T & () const
 Dereference operator. More...
 
T * operator-> ()
 Get a pointer to the bound object. More...
 
const T * operator-> () const
 Get a pointer to the bound object. More...
 
 operator bool () const
 Check if this reference is not expired. More...
 
WeakReferenceoperator= (const SafeReferenceable< T > &other)
 Assignment operator for assigning a SafeReferenceable object. More...
 

Friends

template<typename To , typename From >
WeakReference< To > static_ref_cast (const WeakReference< From > &)
 Statically cast a weak reference. More...
 
template<typename To , typename From >
WeakReference< To > dynamic_ref_cast (const WeakReference< From > &)
 Dynamically cast a weak reference. More...
 

Detailed Description

template<typename T>
class jop::WeakReference< T >

Definition at line 38 of file SafeReferenceable.hpp.

Constructor & Destructor Documentation

template<typename T>
jop::WeakReference< T >::WeakReference ( )
default

Default constructor.

Initializes the internal reference to be empty

template<typename T>
jop::WeakReference< T >::WeakReference ( const SafeReferenceable< T > &  ref)

Constructor for initializing from a SafeReferenceable object.

Parameters
refThe object to bind

Member Function Documentation

template<typename T>
bool jop::WeakReference< T >::expired ( ) const

Check if this reference is expired.

Returns
True if expired
template<typename T>
T* jop::WeakReference< T >::get ( )

Get a pointer to the bound object.

Returns
Pointer to the object. nullptr if expired
template<typename T>
const T* jop::WeakReference< T >::get ( ) const

Get a pointer to the bound object.

Returns
Pointer to the object. nullptr if expired
template<typename T>
jop::WeakReference< T >::operator bool ( ) const

Check if this reference is not expired.

This is the same as !expired()

Returns
True if not expired
template<typename T>
jop::WeakReference< T >::operator const T & ( ) const

Dereference operator.

Calling this operator when this reference is expired will cause a segmentation fault.

Returns
Reference to the bound object
template<typename T>
jop::WeakReference< T >::operator T & ( )

Dereference operator.

Calling this operator when this reference is expired will cause a segmentation fault.

Returns
Reference to the bound object
template<typename T>
T& jop::WeakReference< T >::operator* ( )

Dereference operator.

Calling this operator when this reference is expired will cause a segmentation fault.

Returns
Reference to the bound object
template<typename T>
const T& jop::WeakReference< T >::operator* ( ) const

Dereference operator.

Calling this operator when this reference is expired will cause a segmentation fault.

Returns
Reference to the bound object
template<typename T>
T* jop::WeakReference< T >::operator-> ( )

Get a pointer to the bound object.

Returns
Pointer to the object. nullptr if expired
template<typename T>
const T* jop::WeakReference< T >::operator-> ( ) const

Get a pointer to the bound object.

Returns
Pointer to the object. nullptr if expired
template<typename T>
WeakReference& jop::WeakReference< T >::operator= ( const SafeReferenceable< T > &  other)

Assignment operator for assigning a SafeReferenceable object.

Parameters
otherThe object to bind
Returns
Reference to self
template<typename T>
void jop::WeakReference< T >::reset ( )

Reset this reference.

After this call, this reference won't point to anything.

Friends And Related Function Documentation

template<typename T>
template<typename To , typename From >
WeakReference<To> dynamic_ref_cast ( const WeakReference< From > &  )
friend

Dynamically cast a weak reference.

Parameters
otherThe reference to cast
Returns
Weak reference with the cast type. Empty if unsuccessful
template<typename T>
template<typename To , typename From >
WeakReference<To> static_ref_cast ( const WeakReference< From > &  )
friend

Statically cast a weak reference.

Parameters
otherThe reference to cast
Returns
Weak reference with the cast type

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