CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
DeepCopyPointer< T > Class Template Reference

#include <DeepCopyPointer.h>

Public Member Functions

 DeepCopyPointer ()
 
 DeepCopyPointer (T *t)
 
 DeepCopyPointer (const DeepCopyPointer &other)
 
 DeepCopyPointer (DeepCopyPointer &&other)
 
 operator bool () const
 to allow test like " if (p) {...}" More...
 
Toperator* ()
 
const Toperator* () const
 
Toperator-> ()
 
const Toperator-> () const
 
DeepCopyPointeroperator= (const DeepCopyPointer &other)
 
DeepCopyPointeroperator= (DeepCopyPointer &&other)
 
bool operator== (const T *otherP) const
 to allow test like " if (p == &someT) {...}" More...
 
TreplaceInplace ()
 
void replaceWith (T *otherP)
 
 ~DeepCopyPointer ()
 

Private Attributes

TtheData
 

Detailed Description

template<class T>
class DeepCopyPointer< T >

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.

Constructor & Destructor Documentation

template<class T >
DeepCopyPointer< T >::~DeepCopyPointer ( )
inline

Definition at line 19 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

19 { delete theData;}
template<class T >
DeepCopyPointer< T >::DeepCopyPointer ( )
inline

Definition at line 21 of file DeepCopyPointer.h.

21 : theData(0) {}
template<class T >
DeepCopyPointer< T >::DeepCopyPointer ( T t)
inline

Definition at line 23 of file DeepCopyPointer.h.

template<class T >
DeepCopyPointer< T >::DeepCopyPointer ( const DeepCopyPointer< T > &  other)
inline

Definition at line 25 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

25  {
26  if (other.theData) theData = new T( *other); else theData = 0;
27  }
long double T
template<class T >
DeepCopyPointer< T >::DeepCopyPointer ( DeepCopyPointer< T > &&  other)
inline

Definition at line 38 of file DeepCopyPointer.h.

References trackingPlots::other.

38  : theData(other.theData) {
39  other.theData=0;
40  }

Member Function Documentation

template<class T >
DeepCopyPointer< T >::operator bool ( ) const
inline

to allow test like " if (p) {...}"

Definition at line 73 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

73 { return theData != 0;}
template<class T >
T& DeepCopyPointer< T >::operator* ( )
inline

Definition at line 66 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

66 { return *theData;}
template<class T >
const T& DeepCopyPointer< T >::operator* ( ) const
inline

Definition at line 67 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

67 { return *theData;}
template<class T >
T* DeepCopyPointer< T >::operator-> ( )
inline

Definition at line 69 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

69 { return theData;}
template<class T >
const T* DeepCopyPointer< T >::operator-> ( ) const
inline

Definition at line 70 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

70 { return theData;}
template<class T >
DeepCopyPointer& DeepCopyPointer< T >::operator= ( const DeepCopyPointer< T > &  other)
inline

Definition at line 29 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

29  {
30  if ( theData != other.theData) {
31  delete theData;
32  if (other.theData) theData = new T( *other); else theData = 0;
33  }
34  return *this;
35  }
long double T
template<class T >
DeepCopyPointer& DeepCopyPointer< T >::operator= ( DeepCopyPointer< T > &&  other)
inline

Definition at line 41 of file DeepCopyPointer.h.

References trackingPlots::other, std::swap(), and DeepCopyPointer< T >::theData.

41  {
42  std::swap(theData,other.theData);
43  return *this;
44  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
template<class T >
bool DeepCopyPointer< T >::operator== ( const T otherP) const
inline

to allow test like " if (p == &someT) {...}"

Definition at line 76 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

76 { return theData == otherP;}
template<class T >
T* DeepCopyPointer< T >::replaceInplace ( )
inline

Definition at line 61 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

61  {
62  return theData;
63  }
template<class T >
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 49 of file DeepCopyPointer.h.

References DeepCopyPointer< T >::theData.

49  {
50  if ( theData != otherP ) {
51  delete theData;
52  theData = otherP;
53  }
54  }

Member Data Documentation

template<class T >
T* DeepCopyPointer< T >::theData
private