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 (const DeepCopyPointer &other)
 
 DeepCopyPointer (DeepCopyPointer &&other)
 
 DeepCopyPointer (T *t)
 
 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 15 of file DeepCopyPointer.h.

Constructor & Destructor Documentation

◆ ~DeepCopyPointer()

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

Definition at line 17 of file DeepCopyPointer.h.

17 { delete theData; }

References DeepCopyPointer< T >::theData.

◆ DeepCopyPointer() [1/4]

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

Definition at line 19 of file DeepCopyPointer.h.

19 : theData(0) {}

◆ DeepCopyPointer() [2/4]

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

Definition at line 21 of file DeepCopyPointer.h.

21 : theData(t) {}

◆ DeepCopyPointer() [3/4]

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

Definition at line 23 of file DeepCopyPointer.h.

23  {
24  if (other.theData)
25  theData = new T(*other);
26  else
27  theData = 0;
28  }

References trackingPlots::other, and DeepCopyPointer< T >::theData.

◆ DeepCopyPointer() [4/4]

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

Definition at line 42 of file DeepCopyPointer.h.

42 : theData(other.theData) { other.theData = 0; }

References trackingPlots::other.

Member Function Documentation

◆ operator bool()

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

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

Definition at line 71 of file DeepCopyPointer.h.

71 { return theData != 0; }

References DeepCopyPointer< T >::theData.

◆ operator*() [1/2]

template<class T >
T& DeepCopyPointer< T >::operator* ( )
inline

Definition at line 64 of file DeepCopyPointer.h.

64 { return *theData; }

References DeepCopyPointer< T >::theData.

◆ operator*() [2/2]

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

Definition at line 65 of file DeepCopyPointer.h.

65 { return *theData; }

References DeepCopyPointer< T >::theData.

◆ operator->() [1/2]

template<class T >
T* DeepCopyPointer< T >::operator-> ( )
inline

Definition at line 67 of file DeepCopyPointer.h.

67 { return theData; }

References DeepCopyPointer< T >::theData.

◆ operator->() [2/2]

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

Definition at line 68 of file DeepCopyPointer.h.

68 { return theData; }

References DeepCopyPointer< T >::theData.

◆ operator=() [1/2]

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

Definition at line 30 of file DeepCopyPointer.h.

30  {
31  if (theData != other.theData) {
32  delete theData;
33  if (other.theData)
34  theData = new T(*other);
35  else
36  theData = 0;
37  }
38  return *this;
39  }

References trackingPlots::other, and DeepCopyPointer< T >::theData.

◆ operator=() [2/2]

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

Definition at line 43 of file DeepCopyPointer.h.

43  {
44  std::swap(theData, other.theData);
45  return *this;
46  }

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

◆ operator==()

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

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

Definition at line 74 of file DeepCopyPointer.h.

74 { return theData == otherP; }

References DeepCopyPointer< T >::theData.

◆ replaceInplace()

template<class T >
T* DeepCopyPointer< T >::replaceInplace ( )
inline

Definition at line 62 of file DeepCopyPointer.h.

62 { return theData; }

References DeepCopyPointer< T >::theData.

◆ replaceWith()

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 50 of file DeepCopyPointer.h.

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

References DeepCopyPointer< T >::theData.

Member Data Documentation

◆ theData

template<class T >
T* DeepCopyPointer< T >::theData
private
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
trackingPlots.other
other
Definition: trackingPlots.py:1460
DeepCopyPointer::theData
T * theData
Definition: DeepCopyPointer.h:77
T
long double T
Definition: Basic3DVectorLD.h:48
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644