Ref< TYPE > Class Template Reference
[Kernel Module]

#include <ref.h>

Inheritance diagram for Ref< TYPE >:

SListNode ListNode< SListNode >

List of all members.


Detailed Description

template<class TYPE>
class Ref< TYPE >

Ref implements safe pointers to Referenced derived objects which will Invalidate themselves when the target object goes away. Usage of Ref 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 = NULL OR ref.Invalidate() OR ref.Set(NULL)

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

Public Member Functions

 Ref ()
 Ref (TYPE *o)
 Ref (const Ref< TYPE > &rhs)
 ~Ref ()
Refoperator= (TYPE *obj)
Refoperator= (const Ref< TYPE > &rhs)
bool operator== (const Ref< TYPE > &rhs)
bool operator!= (const Ref< TYPE > &rhs)
bool operator== (TYPE *obj)
bool operator!= (TYPE *obj)
TYPE * operator-> () const
TYPE & operator * () const
 operator TYPE * () const
bool IsValid () const
void Invalidate ()
void Set (TYPE *obj)
TYPE * Get () const
TYPE * GetUnsafe () const

Protected Attributes

TYPE * target_object


Constructor & Destructor Documentation

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

Default constructor.

template<class TYPE>
Ref< TYPE >::Ref ( TYPE *  obj  )  [inline]

Constructor with target object.

Parameters:
obj Pointer to target object.

template<class TYPE>
Ref< TYPE >::Ref ( const Ref< TYPE > &  ref  )  [inline]

Copy constructor.

Parameters:
ref Reference to object.

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

Destructor.


Member Function Documentation

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

Assigns TYPE pointer.

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

Copy operator.

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

Equality operator.

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

Inequality operator.

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

Equality operator.

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

Inequality operator.

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

Overrides -> operator.

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

Dereferences operator.

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

Cast operator.

template<class TYPE>
bool Ref< TYPE >::IsValid ( void   )  const [inline]

Checks if target object exists.

Returns:
True if pointer is still valid.

template<class TYPE>
void Ref< TYPE >::Invalidate (  )  [inline]

Invalidate the reference.

template<class TYPE>
void Ref< TYPE >::Set ( TYPE *  obj  )  [inline]

Set target object.

Parameters:
obj Pointer to target object.

template<class TYPE>
TYPE * Ref< TYPE >::Get (  )  const [inline]

Gets target object (safe).

Returns:
Pointer to target object.

template<class TYPE>
TYPE * Ref< TYPE >::GetUnsafe (  )  const [inline]

Gets target object (unsafe, may return NULL).

Returns:
Pointer to target object.


Member Data Documentation

template<class TYPE>
TYPE* Ref< TYPE >::target_object [protected]


The documentation for this class was generated from the following file:
Generated on Sat Oct 20 14:47:34 2007 for Dark Oberon by  doxygen 1.5.3