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 TrajectoryStateOnSurface VertexState

Protected Member Functions

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

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 ( )
inlineprotectednoexcept

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)
inlineexplicitprotectednoexcept

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)
inlineprotectednoexcept

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 ( )
inlineprotectednoexcept

Definition at line 32 of file ProxyBase.h.

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

32  {
33  destroy();
34  }
void destroy() noexcept
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)
Definition: Likely.h:21
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(), TrajectoryStateOnSurface::cartesianError(), reco::TransientTrack::charge(), TrajectoryStateOnSurface::charge(), VertexState::components(), TrajectoryStateOnSurface::components(), TrajectoryStateOnSurface::curvilinearError(), VertexState::error(), reco::TransientTrack::field(), TrajectoryStateOnSurface::freeState(), TrajectoryStateOnSurface::globalDirection(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalParameters(), reco::GhostTrackState::globalPosition(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateOnSurface::hasError(), reco::TransientTrack::impactPointState(), reco::TransientTrack::impactPointStateAvailable(), reco::TransientTrack::impactPointTSCP(), reco::TransientTrack::initialFreeState(), reco::TransientTrack::innermostMeasurementState(), reco::GhostTrackState::isTrack(), reco::GhostTrackState::isValid(), VertexState::isValid(), TrajectoryStateOnSurface::isValid(), reco::GhostTrackState::isVertex(), reco::GhostTrackState::lambda(), TrajectoryStateOnSurface::localDirection(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localMomentum(), TrajectoryStateOnSurface::localParameters(), TrajectoryStateOnSurface::localPosition(), TrajectoryStateOnSurface::magneticField(), reco::TransientTrack::operator<(), reco::TransientTrack::operator==(), reco::TransientTrack::outermostMeasurementState(), VertexState::position(), TrajectoryStateOnSurface::signedInverseMomentum(), reco::TransientTrack::stateAtBeamLine(), reco::TransientTrack::stateOnSurface(), TrajectoryStateOnSurface::surface(), TrajectoryStateOnSurface::surfaceSide(), reco::GhostTrackState::track(), reco::TransientTrack::track(), reco::TransientTrack::trackBaseRef(), reco::TransientTrack::trajectoryStateClosestToPoint(), TrajectoryStateOnSurface::transverseCurvature(), reco::GhostTrackState::tsos(), TrajectoryStateOnSurface::update(), reco::GhostTrackState::vertexStateOnGhostTrack(), reco::GhostTrackState::vertexStateOnMeasurement(), VertexState::weight(), reco::GhostTrackState::weight(), TrajectoryStateOnSurface::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 ( )
inlineprotectednoexcept

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)
Definition: Likely.h:20
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)
inlineprotectednoexcept

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() noexcept
Definition: ProxyBase.h:88
#define likely(x)
Definition: Likely.h:20
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)
inlineprotectednoexcept

Definition at line 46 of file ProxyBase.h.

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

Referenced by reco::TransientTrack::swap(), and TrajectoryStateOnSurface::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(), TrajectoryStateOnSurface::rescaleError(), reco::GhostTrackState::reset(), reco::GhostTrackState::setWeight(), and TrajectoryStateOnSurface::update().

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