AI_Ref< TYPE > Class Template Reference
[Utilities]

#include <AI_Ref.h>

Inheritance diagram for AI_Ref< TYPE >:

AI_Node

List of all members.


Detailed Description

template<class TYPE>
class AI_Ref< TYPE >

AI_Ref implements safe pointers to AI_Referenced derived objects which will invalidate themselves when the target object goes away. nAutoRef works similarly to AI_Ref but is also NOH aware and as such takes pointers to nRoot derived objects. Usage of AI_Ref/nAutoRef helps you avoid dangling pointers and also protects against dereferencing a null pointer.

Operations:

Assigning ptr to ref: ref=ptr OR ref.set(ptr)

Invalidating: ref=0 OR ref.invalidate() OR ref.set(0)

Checking if pointer is valid (non-null): ref.isvalid()

Version:
2.0 AI_Ref was ripped from The Nebula Device and renamed to AI_Ref. Now it is possible to use the class inside and outside Nebula projects.

(C) 1999 RadonLabs GmbH

Public Member Functions

 AI_Ref ()
 default constructor
 AI_Ref (TYPE *o)
 constructor with target object
 AI_Ref (const AI_Ref &)
 copy constructor
 ~AI_Ref ()
 destructor
AI_Refoperator= (TYPE *obj)
 assign TYPE pointer
AI_Refoperator= (const AI_Ref &rhs)
 assign AI_Ref object
bool operator== (const AI_Ref &rhs)
 equality operator
bool operator!= (const AI_Ref< TYPE > &rhs)
 inequality operator
bool operator== (TYPE *obj)
 shortcut equality operator
bool operator!= (TYPE *obj)
 shortcut inequality operator
TYPE * operator-> () const
 override -> operator
TYPE & operator * () const
 dereference operator
 operator TYPE * () const
 cast operator
bool isvalid () const
 check if target object exists
void invalidate ()
 invalidate the ref
void set (TYPE *obj)
 set target object
TYPE * get () const
 get target object (safe)
TYPE * get_unsafe () const
 get target object (unsafe, may return 0)

Protected Attributes

TYPE * targetObject


Constructor & Destructor Documentation

template<class TYPE>
AI_Ref< TYPE >::AI_Ref (  )  [inline]

default constructor

template<class TYPE>
AI_Ref< TYPE >::AI_Ref ( TYPE *  o  )  [inline]

constructor with target object

template<class TYPE>
AI_Ref< TYPE >::AI_Ref ( const AI_Ref< TYPE > &  rhs  )  [inline]

copy constructor

template<class TYPE>
AI_Ref< TYPE >::~AI_Ref (  )  [inline]

destructor


Member Function Documentation

template<class TYPE>
AI_Ref< TYPE > & AI_Ref< TYPE >::operator= ( TYPE *  obj  )  [inline]

assign TYPE pointer

template<class TYPE>
AI_Ref< TYPE > & AI_Ref< TYPE >::operator= ( const AI_Ref< TYPE > &  rhs  )  [inline]

assign AI_Ref object

Copy operator.

template<class TYPE>
bool AI_Ref< TYPE >::operator== ( const AI_Ref< TYPE > &  rhs  )  [inline]

equality operator

Equality operator.

template<class TYPE>
bool AI_Ref< TYPE >::operator!= ( const AI_Ref< TYPE > &  rhs  )  [inline]

inequality operator

Inequality operator.

template<class TYPE>
bool AI_Ref< TYPE >::operator== ( TYPE *  obj  )  [inline]

shortcut equality operator

Equality operator.

template<class TYPE>
bool AI_Ref< TYPE >::operator!= ( TYPE *  obj  )  [inline]

shortcut inequality operator

Inequality operator.

template<class TYPE>
TYPE * AI_Ref< TYPE >::operator-> (  )  const [inline]

override -> operator

template<class TYPE>
TYPE & AI_Ref< TYPE >::operator * (  )  const [inline]

dereference operator

template<class TYPE>
AI_Ref< TYPE >::operator TYPE * (  )  const [inline]

cast operator

template<class TYPE>
bool AI_Ref< TYPE >::isvalid ( void   )  const [inline]

check if target object exists

template<class TYPE>
void AI_Ref< TYPE >::invalidate (  )  [inline]

invalidate the ref

template<class TYPE>
void AI_Ref< TYPE >::set ( TYPE *  obj  )  [inline]

set target object

template<class TYPE>
TYPE * AI_Ref< TYPE >::get (  )  const [inline]

get target object (safe)

template<class TYPE>
TYPE * AI_Ref< TYPE >::get_unsafe (  )  const [inline]

get target object (unsafe, may return 0)


Member Data Documentation

template<class TYPE>
TYPE* AI_Ref< TYPE >::targetObject [protected]


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