#include <DeepCopyPointer.h>
Public Member Functions | |
DeepCopyPointer () | |
DeepCopyPointer (const DeepCopyPointer &other) | |
DeepCopyPointer (T *t) | |
operator bool () const | |
to allow test like " if (p) {...}" | |
T & | operator* () |
const T & | operator* () const |
T * | operator-> () |
const T * | operator-> () const |
DeepCopyPointer & | operator= (const DeepCopyPointer &other) |
bool | operator== (const T *otherP) const |
to allow test like " if (p == &someT) {...}" | |
T * | replaceInplace () |
void | replaceWith (T *otherP) |
~DeepCopyPointer () | |
Private Attributes | |
T * | theData |
A "smart" pointer that implements deep copy and ownership. In other words, when the pointer is copied it copies the object it points to using "new". It also deletes the object it points to when it is deleted. Very useful for use as private data member of a class: it handles the copy construction, assignment, and destruction.
Definition at line 16 of file DeepCopyPointer.h.
DeepCopyPointer< T >::~DeepCopyPointer | ( | ) | [inline] |
Definition at line 19 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ delete theData;}
DeepCopyPointer< T >::DeepCopyPointer | ( | ) | [inline] |
Definition at line 21 of file DeepCopyPointer.h.
: theData(0) {}
DeepCopyPointer< T >::DeepCopyPointer | ( | T * | t | ) | [inline] |
Definition at line 23 of file DeepCopyPointer.h.
DeepCopyPointer< T >::DeepCopyPointer | ( | const DeepCopyPointer< T > & | other | ) | [inline] |
Definition at line 25 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
DeepCopyPointer< T >::operator bool | ( | ) | const [inline] |
to allow test like " if (p) {...}"
Definition at line 77 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return theData != 0;}
T& DeepCopyPointer< T >::operator* | ( | ) | [inline] |
Definition at line 70 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return *theData;}
const T& DeepCopyPointer< T >::operator* | ( | ) | const [inline] |
Definition at line 71 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return *theData;}
const T* DeepCopyPointer< T >::operator-> | ( | ) | const [inline] |
Definition at line 74 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return theData;}
T* DeepCopyPointer< T >::operator-> | ( | ) | [inline] |
Definition at line 73 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return theData;}
DeepCopyPointer& DeepCopyPointer< T >::operator= | ( | const DeepCopyPointer< T > & | other | ) | [inline] |
Definition at line 29 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
bool DeepCopyPointer< T >::operator== | ( | const T * | otherP | ) | const [inline] |
to allow test like " if (p == &someT) {...}"
Definition at line 80 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return theData == otherP;}
T* DeepCopyPointer< T >::replaceInplace | ( | ) | [inline] |
Definition at line 65 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
{ return theData; }
void DeepCopyPointer< T >::replaceWith | ( | T * | otherP | ) | [inline] |
Assing a new bare pointer to this DeepCopyPointer, taking ownership of it. The old content of this DeepCopyPointer is deleted
Definition at line 53 of file DeepCopyPointer.h.
References DeepCopyPointer< T >::theData.
T* DeepCopyPointer< T >::theData [private] |
Definition at line 83 of file DeepCopyPointer.h.
Referenced by DeepCopyPointer< T >::DeepCopyPointer(), DeepCopyPointer< T >::operator bool(), DeepCopyPointer< T >::operator*(), DeepCopyPointer< T >::operator->(), DeepCopyPointer< T >::operator=(), DeepCopyPointer< T >::operator==(), DeepCopyPointer< T >::replaceInplace(), DeepCopyPointer< T >::replaceWith(), and DeepCopyPointer< T >::~DeepCopyPointer().