Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

AutoCloner< T > Class Template Reference

Enhanced AutoPtr that has a proper copy constructor to allow copy constructor-style constructs to work properly with inheritance. More...

#include <autocloner.h>

Collaboration diagram for AutoCloner< T >:

Collaboration graph
[legend]
List of all members.

Public Methods

 AutoCloner ()
 Default constructor sets things to NULL. More...

 AutoCloner (T *t)
 Pass in a T* and this sets the pointer to it. More...

 AutoCloner (const AutoCloner< T > &o)
 The copy constructor calls the gets operator. More...

AutoCloner< T > & operator= (const T &t)
 The gets operator clones T when a sole T is passed in. More...

AutoCloner< T > & operator= (const T *t)
 When a T pointer is passed in it checks for nullity before calling Clone(). More...

AutoCloner< T > & operator= (const AutoCloner< T > &o)
 The standard gets uses one of the other gets to clone the pointer. More...

 ~AutoCloner ()
 Destructor kills this copy of T -- wow this seems like Jave. More...

const T * operator-> () const
 Dereferences this. More...

T * operator-> ()
 Dereferences this. More...

bool IsNull () const
 Checks if the pointer itself is null so that one may dereference safely. More...

bool NotNull () const
 Inverse if isNull(). More...


Private Attributes

T * t
 The actual pointer. More...


Detailed Description

template<class T>
class AutoCloner< T >

Enhanced AutoPtr that has a proper copy constructor to allow copy constructor-style constructs to work properly with inheritance.

Requires class T to have a virtual Clone() function that will duplicate itself


Constructor & Destructor Documentation

template<class T>
AutoCloner< T >::AutoCloner   [inline]
 

Default constructor sets things to NULL.

00009 {t=NULL;}

template<class T>
AutoCloner< T >::AutoCloner T *    t [inline]
 

Pass in a T* and this sets the pointer to it.

00011 {this->t =t;}

template<class T>
AutoCloner< T >::AutoCloner const AutoCloner< T > &    o [inline]
 

The copy constructor calls the gets operator.

00013 {*this = o;}

template<class T>
AutoCloner< T >::~AutoCloner   [inline]
 

Destructor kills this copy of T -- wow this seems like Jave.

00031 {if (t) delete t;}


Member Function Documentation

template<class T>
bool AutoCloner< T >::IsNull   const [inline]
 

Checks if the pointer itself is null so that one may dereference safely.

00037 {return t==0;}

template<class T>
bool AutoCloner< T >::NotNull   const [inline]
 

Inverse if isNull().

00039 {return !isNull();}

template<class T>
T* AutoCloner< T >::operator->   [inline]
 

Dereferences this.

00035 {return t;}

template<class T>
const T* AutoCloner< T >::operator->   const [inline]
 

Dereferences this.

00033 {return t;}

template<class T>
AutoCloner<T>& AutoCloner< T >::operator= const AutoCloner< T > &    o [inline]
 

The standard gets uses one of the other gets to clone the pointer.

00027                                                         {
00028         return *this = o.t;
00029     }

template<class T>
AutoCloner<T>& AutoCloner< T >::operator= const T *    t [inline]
 

When a T pointer is passed in it checks for nullity before calling Clone().

00020                                            {
00021         if (t)
00022             return *this = *t;
00023         else this->t=0;
00024         return *this;
00025     }

template<class T>
AutoCloner<T>& AutoCloner< T >::operator= const T &    t [inline]
 

The gets operator clones T when a sole T is passed in.

00015                                            {
00016         this->t = t.clone();
00017         return *this;
00018     }


Member Data Documentation

template<class T>
T* AutoCloner< T >::t [private]
 

The actual pointer.


The documentation for this class was generated from the following file:
Generated on Mon Jul 7 21:13:51 2003 for Ethereal by doxygen1.2.15