Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

SmartPtr Class Template Reference

#include <smartptr.h>

Collaboration diagram for SmartPtr:

Collaboration graph
[legend]
List of all members.

Public Methods

 SmartPtr ()
 build Smart-NULL-Ptr. More...

 SmartPtr (T *p)
 build normal SmartPtr. More...

 ~SmartPtr ()
 destroy SmartPtr. More...

 SmartPtr (const SmartPtr< T > &other)
SmartPtr< T > & operator= (const SmartPtr< T > &other)
T * operator-> ()
const T * operator-> () const
T & operator * ()
const T & operator * () const
bool Null () const
void SetNull ()
SmartPtr< T > deep_copy () const
bool sameObject (const SmartPtr< T > &other) const

Private Methods

void Unbind ()

Private Attributes

Counted< T > * object

Detailed Description

template<class T>
class rs::SmartPtr< T >

Smart pointer class

Definition at line 67 of file smartptr.h.


Constructor & Destructor Documentation

SmartPtr   [inline]
 

build Smart-NULL-Ptr.

Definition at line 77 of file smartptr.h.

SmartPtr T *    p [inline]
 

build normal SmartPtr.

By passing an object to a SmartPtr you loose the responsibility for the object. That means : Never free an object which was passed to a SmartPtr! The object will be destroyed, when the last SmartPtr (pointing to that object) gets destroyed.

Parameters:
p  Pointer to any dynamically allocated object

Definition at line 87 of file smartptr.h.

~SmartPtr   [inline]
 

destroy SmartPtr.

object will not be destroyed as long as any other SmartPtr points to it

Definition at line 96 of file smartptr.h.

SmartPtr const SmartPtr< T > &    other [inline]
 

Definition at line 98 of file smartptr.h.


Member Function Documentation

void Unbind   [inline, private]
 

Definition at line 71 of file smartptr.h.

Referenced by SmartPtr::operator=(), SmartPtr::SetNull(), and SmartPtr::~SmartPtr().

SmartPtr<T>& operator= const SmartPtr< T > &    other [inline]
 

Definition at line 102 of file smartptr.h.

T* operator->   [inline]
 

Definition at line 109 of file smartptr.h.

const T* operator->   const [inline]
 

Definition at line 110 of file smartptr.h.

T& operator *   [inline]
 

Definition at line 112 of file smartptr.h.

const T& operator *   const [inline]
 

Definition at line 113 of file smartptr.h.

bool Null   const [inline]
 

test if SmartPtr is 0

Definition at line 116 of file smartptr.h.

void SetNull   [inline]
 

set SmartPtr to 0

Definition at line 119 of file smartptr.h.

SmartPtr<T> deep_copy   const [inline]
 

create a deep copy of the object pointed to by the smart pointer.

Afterwards there exist two equal copies of the object.

Returns:
SmartPtr to the new copy.

Definition at line 127 of file smartptr.h.

bool sameObject const SmartPtr< T > &    other const [inline]
 

test if two SmartPtrs point to the same object (this is used for operators == and !=).

if you like to compare the objects themselves use (*smart_ptr1 == *smart_ptr2)

Returns:
true if the SmartPtrs point to the same object

Definition at line 137 of file smartptr.h.

Referenced by rs::operator!=(), and rs::operator==().


Member Data Documentation

Counted<T>* object [private]
 

Definition at line 69 of file smartptr.h.

Referenced by SmartPtr::operator=(), SmartPtr::sameObject(), and SmartPtr::SmartPtr().


The documentation for this class was generated from the following file:
Contact me in case of errors or questions.
This documentation is powered by Doxygen.
(C) 2000-2002 Doxygen