Drag[en]gine Game Engine  1.21
deTObjectReference< T > Class Template Reference

Template version of deObjectReference. More...

#include <deTObjectReference.h>

Public Member Functions

Constructors and Destructors
 deTObjectReference ()
 Create empty object reference holder. More...
 
 deTObjectReference (T *object)
 Create object reference holder with object. More...
 
 deTObjectReference (const deTObjectReference &reference)
 Create object reference holder with object from another holder. More...
 
 ~deTObjectReference ()
 Clean up object reference holder. More...
 

Management

void TakeOver (T *object)
 Set object without adding reference. More...
 
void TakeOver (deTObjectReference &reference)
 Move reference. More...
 
void TakeOver (const deTObjectReference &reference)
 Add reference. More...
 
bool operator! () const
 Object is nullptr. More...
 
 operator bool () const
 Test if object is not nullptr. More...
 
 operator T* () const
 Pointer to object. More...
 
 operator T& () const
 C to object. More...
 
T * operator-> () const
 Pointer to object. More...
 
deTObjectReferenceoperator= (T *object)
 Store object. More...
 
deTObjectReferenceoperator= (const deTObjectReference &reference)
 Store object. More...
 
bool operator== (T *object) const
 Test if object is held by this holder. More...
 
bool operator== (const deTObjectReference &reference) const
 Test if object is held by this holder. More...
 
bool operator!= (T *object) const
 Test if object is not held by this holder. More...
 
bool operator!= (const deTObjectReference &reference) const
 Test if object is not held by this holder. More...
 
static deTObjectReference New (T *object)
 Create instance taking over reference. More...
 
static deTObjectReference New (const deTObjectReference &reference)
 Returns reference to protect against problems. More...
 
static deTObjectReference New (deTObjectReference &reference)
 Returns reference to protect against problems. More...
 

Detailed Description

template<class T>
class deTObjectReference< T >

Template version of deObjectReference.

Version
1.5

Safe way to hold an object reference with correct reference handling. Storing nullptr is allowed. Initial value is nullptr.

Note
This class is designed to be used as stack or member object. Do not use it as pointer and memory allocate it. For this reason the destructor is on purpose not virtual.
Warning
Do not use template instances in public library interfaces. Template ABIs are not stable by design.

Constructor & Destructor Documentation

◆ deTObjectReference() [1/3]

template<class T >
deTObjectReference< T >::deTObjectReference ( )
inline

Create empty object reference holder.

◆ deTObjectReference() [2/3]

template<class T >
deTObjectReference< T >::deTObjectReference ( T *  object)
inline

Create object reference holder with object.

Reference is added if object is not nullptr.

◆ deTObjectReference() [3/3]

template<class T >
deTObjectReference< T >::deTObjectReference ( const deTObjectReference< T > &  reference)
inline

Create object reference holder with object from another holder.

Reference is added if object in holder is not nullptr.

◆ ~deTObjectReference()

template<class T >
deTObjectReference< T >::~deTObjectReference ( )
inline

Clean up object reference holder.

Releases reference if object is not nullptr.

Member Function Documentation

◆ New() [1/3]

template<class T >
static deTObjectReference deTObjectReference< T >::New ( const deTObjectReference< T > &  reference)
inlinestatic

Returns reference to protect against problems.

◆ New() [2/3]

template<class T >
static deTObjectReference deTObjectReference< T >::New ( deTObjectReference< T > &  reference)
inlinestatic

Returns reference to protect against problems.

◆ New() [3/3]

template<class T >
static deTObjectReference deTObjectReference< T >::New ( T *  object)
inlinestatic

Create instance taking over reference.

Same as calling TakeOver() on a new instance but allows for inline use.

References deTObjectReference< T >::TakeOver().

◆ operator bool()

template<class T >
deTObjectReference< T >::operator bool ( ) const
inline

Test if object is not nullptr.

◆ operator T&()

template<class T >
deTObjectReference< T >::operator T& ( ) const
inline

C to object.

Exceptions
deeNullPointerif object is nullptr.

◆ operator T*()

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

Pointer to object.

◆ operator!()

template<class T >
bool deTObjectReference< T >::operator! ( ) const
inline

Object is nullptr.

◆ operator!=() [1/2]

template<class T >
bool deTObjectReference< T >::operator!= ( const deTObjectReference< T > &  reference) const
inline

Test if object is not held by this holder.

◆ operator!=() [2/2]

template<class T >
bool deTObjectReference< T >::operator!= ( T *  object) const
inline

Test if object is not held by this holder.

◆ operator->()

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

Pointer to object.

Exceptions
deeNullPointerif object is nullptr.

References DEASSERT_NOTNULL.

◆ operator=() [1/2]

template<class T >
deTObjectReference& deTObjectReference< T >::operator= ( const deTObjectReference< T > &  reference)
inline

Store object.

If an object is already held its reference is release and the new object stored. If the new object is not nullptr a reference is added.

References deTObjectReference< T >::operator=().

◆ operator=() [2/2]

template<class T >
deTObjectReference& deTObjectReference< T >::operator= ( T *  object)
inline

Store object.

If an object is already held its reference is release and the new object stored. If the new object is not nullptr a reference is added.

Referenced by deTObjectReference< T >::operator=().

◆ operator==() [1/2]

template<class T >
bool deTObjectReference< T >::operator== ( const deTObjectReference< T > &  reference) const
inline

Test if object is held by this holder.

◆ operator==() [2/2]

template<class T >
bool deTObjectReference< T >::operator== ( T *  object) const
inline

Test if object is held by this holder.

◆ TakeOver() [1/3]

template<class T >
void deTObjectReference< T >::TakeOver ( const deTObjectReference< T > &  reference)
inline

Add reference.

◆ TakeOver() [2/3]

template<class T >
void deTObjectReference< T >::TakeOver ( deTObjectReference< T > &  reference)
inline

Move reference.

◆ TakeOver() [3/3]

template<class T >
void deTObjectReference< T >::TakeOver ( T *  object)
inline

Set object without adding reference.

Use this method if the object to hold has been added a reference already. This is the case with created objects as well as certain methods returning newly created objects. In all these cases the object has to be held without adding a reference. For all other situations use the constructor or assignment operator.

It is allowed for object to be a nullptr object.

Referenced by deTObjectReference< T >::New().


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