CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProxyBase ()
 
 ProxyBase (T *p)
 
 ProxyBase (const 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:93
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.

25 : theData(p) {if (theData) theData->addReference();}
T * theData
Definition: ProxyBase.h:93
template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( const ProxyBase< T, Cloner > &  other)
inlineprotected

Definition at line 27 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

27  {
28  theData = other.theData;
29  if (theData) theData->addReference();
30  }
T * theData
Definition: ProxyBase.h:93
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:88

Member Function Documentation

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

Definition at line 83 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData, and unlikely.

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

83  {
84  if unlikely(theData == 0)
85  throw TrajectoryStateException("Error: uninitialized ProxyBase used");
86  }
#define unlikely(x)
T * theData
Definition: ProxyBase.h:93
template<class T, class Cloner>
const T& ProxyBase< T, Cloner >::data ( ) const
inlineprotected

Definition at line 67 of file ProxyBase.h.

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

Referenced by cuy.FindIssue::__init__(), reco::TransientTrack::basicTransientTrack(), reco::GhostTrackState::cartesianCovariance(), reco::GhostTrackState::cartesianError(), reco::TransientTrack::charge(), VertexState::components(), VertexState::error(), reco::TransientTrack::field(), reco::GhostTrackState::globalPosition(), reco::TransientTrack::impactPointState(), reco::TransientTrack::impactPointStateAvailable(), reco::TransientTrack::impactPointTSCP(), reco::TransientTrack::initialFreeState(), reco::TransientTrack::innermostMeasurementState(), 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(), reco::GhostTrackState::track(), reco::TransientTrack::track(), reco::TransientTrack::trackBaseRef(), reco::TransientTrack::trajectoryStateClosestToPoint(), reco::GhostTrackState::tsos(), reco::GhostTrackState::vertexStateOnGhostTrack(), reco::GhostTrackState::vertexStateOnMeasurement(), VertexState::weight(), reco::GhostTrackState::weight(), VertexState::weightInMixture(), and VertexState::weightTimesPosition().

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

Definition at line 88 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().

88 { if likely(isValid()) theData->removeReference();}
#define likely(x)
bool isValid() const
Definition: ProxyBase.h:81
T * theData
Definition: ProxyBase.h:93
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, and ProxyBase< T, Cloner >::theData.

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:88
#define likely(x)
T * theData
Definition: ProxyBase.h:93
template<class T, class Cloner>
int ProxyBase< T, Cloner >::references ( ) const
inlineprotected

Definition at line 90 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

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

90 {return theData->references();}
T * theData
Definition: ProxyBase.h:93
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 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:93
template<class T, class Cloner>
T& ProxyBase< T, Cloner >::unsharedData ( )
inlineprotected

Definition at line 69 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().

69  {
70  check();
71  if ( references() > 1) {
72  theData->removeReference();
73  theData = Cloner().clone( *theData);
74  if (theData) theData->addReference();
75  }
76  return *theData;
77  }
int references() const
Definition: ProxyBase.h:90
void check() const
Definition: ProxyBase.h:83
T * theData
Definition: ProxyBase.h:93

Member Data Documentation

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