CMS 3D CMS Logo

List of all members | Protected Member Functions | Private Attributes
ProxyBase< T, Cloner > Class Template Reference

#include <ProxyBase.h>

Inheritance diagram for ProxyBase< T, Cloner >:
reco::GhostTrackState reco::TransientTrack VertexState

Protected Member Functions

void check () const
 
const Tdata () const
 
void destroy ()
 
bool isValid () const
 
ProxyBaseoperator= (const ProxyBase &other)
 
ProxyBaseoperator= (ProxyBase &&other)
 
 ProxyBase ()
 
 ProxyBase (T *p)
 
 ProxyBase (const ProxyBase &other)
 
 ProxyBase (ProxyBase &&other)
 
int references () const
 
TsharedData ()
 
void swap (ProxyBase &other)
 
TunsharedData ()
 
 ~ProxyBase ()
 

Private Attributes

TtheData
 

Detailed Description

template<class T, class Cloner>
class ProxyBase< T, Cloner >

A base class for reference counting proxies. The class to which this one is proxy must inherit from ReferenceCounted. A ProxyBase has value semantics, in contrast to ReferenceCountingPointer, which has pointer semantics. The Proxy class inheriting from ProxyBase must duplicate the part of the interface of the reference counted class that it whiches to expose.

Definition at line 20 of file ProxyBase.h.

Constructor & Destructor Documentation

template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( )
inlineprotected

Definition at line 23 of file ProxyBase.h.

23 : theData(0) {}
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( T p)
inlineexplicitprotected

Definition at line 25 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( const ProxyBase< T, Cloner > &  other)
inlineprotected

Definition at line 27 of file ProxyBase.h.

References trackingPlots::other, and ProxyBase< T, Cloner >::theData.

27  {
28  theData = other.theData;
29  if (theData) theData->addReference();
30  }
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
ProxyBase< T, Cloner >::~ProxyBase ( )
inlineprotected

Definition at line 32 of file ProxyBase.h.

References ProxyBase< T, Cloner >::destroy().

32  {
33  destroy();
34  }
void destroy()
Definition: ProxyBase.h:86
template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( ProxyBase< T, Cloner > &&  other)
inlineprotected

Definition at line 51 of file ProxyBase.h.

References trackingPlots::other, and ProxyBase< T, Cloner >::theData.

51  {
52  theData = other.theData;
53  other.theData=0;
54  }
T * theData
Definition: ProxyBase.h:91

Member Function Documentation

template<class T, class Cloner>
void ProxyBase< T, Cloner >::check ( void  ) const
inlineprotected
template<class T, class Cloner>
const T& ProxyBase< T, Cloner >::data ( ) const
inlineprotected

Definition at line 65 of file ProxyBase.h.

References ProxyBase< T, Cloner >::check(), and ProxyBase< T, Cloner >::theData.

Referenced by reco::TransientTrack::basicTransientTrack(), reco::GhostTrackState::cartesianCovariance(), reco::GhostTrackState::cartesianError(), reco::TransientTrack::charge(), VertexState::components(), reco::TransientTrack::dtErrorExt(), VertexState::error(), VertexState::error4D(), reco::TransientTrack::field(), reco::GhostTrackState::globalPosition(), reco::TransientTrack::impactPointState(), reco::TransientTrack::impactPointStateAvailable(), reco::TransientTrack::impactPointTSCP(), reco::TransientTrack::initialFreeState(), reco::TransientTrack::innermostMeasurementState(), VertexState::is4D(), reco::GhostTrackState::isTrack(), reco::GhostTrackState::isValid(), VertexState::isValid(), reco::GhostTrackState::isVertex(), reco::GhostTrackState::lambda(), reco::TransientTrack::operator<(), reco::TransientTrack::operator==(), reco::TransientTrack::outermostMeasurementState(), VertexState::position(), reco::TransientTrack::stateAtBeamLine(), reco::TransientTrack::stateOnSurface(), VertexState::time(), VertexState::timeError(), reco::TransientTrack::timeExt(), reco::GhostTrackState::track(), reco::TransientTrack::track(), reco::TransientTrack::trackBaseRef(), reco::TransientTrack::trajectoryStateClosestToPoint(), reco::GhostTrackState::tsos(), reco::GhostTrackState::vertexStateOnGhostTrack(), reco::GhostTrackState::vertexStateOnMeasurement(), reco::GhostTrackState::weight(), VertexState::weight(), VertexState::weight4D(), VertexState::weightInMixture(), VertexState::weightTimesPosition(), and VertexState::weightTimesPosition4D().

65 { check(); return *theData;}
void check() const
Definition: ProxyBase.h:81
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
void ProxyBase< T, Cloner >::destroy ( )
inlineprotected

Definition at line 86 of file ProxyBase.h.

References ProxyBase< T, Cloner >::isValid(), likely, and ProxyBase< T, Cloner >::theData.

Referenced by ProxyBase< T, Cloner >::operator=(), and ProxyBase< T, Cloner >::~ProxyBase().

86 { if likely(isValid()) theData->removeReference();}
#define likely(x)
bool isValid() const
Definition: ProxyBase.h:79
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
bool ProxyBase< T, Cloner >::isValid ( void  ) const
inlineprotected
template<class T, class Cloner>
ProxyBase& ProxyBase< T, Cloner >::operator= ( const ProxyBase< T, Cloner > &  other)
inlineprotected

Definition at line 36 of file ProxyBase.h.

References ProxyBase< T, Cloner >::destroy(), likely, trackingPlots::other, and ProxyBase< T, Cloner >::theData.

Referenced by reco::TransientTrack::operator=().

36  {
37  if likely( theData != other.theData) {
38  destroy();
39  theData = other.theData;
40  if (theData) theData->addReference();
41  }
42  return *this;
43  }
void destroy()
Definition: ProxyBase.h:86
#define likely(x)
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
ProxyBase& ProxyBase< T, Cloner >::operator= ( ProxyBase< T, Cloner > &&  other)
inlineprotected

Definition at line 56 of file ProxyBase.h.

References ProxyBase< T, Cloner >::destroy(), likely, trackingPlots::other, and ProxyBase< T, Cloner >::theData.

56  {
57  if likely( theData != other.theData) {
58  destroy();
59  theData = other.theData;
60  other.theData=0;
61  }
62  return *this;
63  }
void destroy()
Definition: ProxyBase.h:86
#define likely(x)
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
int ProxyBase< T, Cloner >::references ( ) const
inlineprotected

Definition at line 88 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

Referenced by ProxyBase< T, Cloner >::unsharedData().

88 {return theData->references();}
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
T& ProxyBase< T, Cloner >::sharedData ( )
inlineprotected
template<class T, class Cloner>
void ProxyBase< T, Cloner >::swap ( ProxyBase< T, Cloner > &  other)
inlineprotected

Definition at line 46 of file ProxyBase.h.

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

Referenced by reco::TransientTrack::swap().

46  {
47  std::swap(theData,other.theData);
48  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T * theData
Definition: ProxyBase.h:91
template<class T, class Cloner>
T& ProxyBase< T, Cloner >::unsharedData ( )
inlineprotected

Definition at line 67 of file ProxyBase.h.

References ProxyBase< T, Cloner >::check(), ProxyBase< T, Cloner >::references(), and ProxyBase< T, Cloner >::theData.

Referenced by reco::GhostTrackState::linearize(), reco::GhostTrackState::reset(), and reco::GhostTrackState::setWeight().

67  {
68  check();
69  if ( references() > 1) {
70  theData->removeReference();
71  theData = Cloner().clone( *theData);
72  if (theData) theData->addReference();
73  }
74  return *theData;
75  }
int references() const
Definition: ProxyBase.h:88
void check() const
Definition: ProxyBase.h:81
T * theData
Definition: ProxyBase.h:91

Member Data Documentation

template<class T, class Cloner>
T* ProxyBase< T, Cloner >::theData
private