CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public 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

Public 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 ()
 
virtual ~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 17 of file ProxyBase.h.

Constructor & Destructor Documentation

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

Definition at line 20 of file ProxyBase.h.

20 : theData(0) {}
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
ProxyBase< T, Cloner >::ProxyBase ( T p)
inline

Definition at line 22 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

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

Definition at line 24 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

24  {
25  theData = other.theData;
26  if (theData) theData->addReference();
27  }
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
virtual ProxyBase< T, Cloner >::~ProxyBase ( )
inlinevirtual

Definition at line 29 of file ProxyBase.h.

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

29  {
30  destroy();
31  }
void destroy()
Definition: ProxyBase.h:85

Member Function Documentation

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

Definition at line 80 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

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

80  {
81  if (theData == 0)
82  throw TrajectoryStateException("Error: uninitialized ProxyBase used");
83  }
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
const T& ProxyBase< T, Cloner >::data ( ) const
inline

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

64 { check(); return *theData;}
void check() const
Definition: ProxyBase.h:80
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
void ProxyBase< T, Cloner >::destroy ( )
inline

Definition at line 85 of file ProxyBase.h.

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

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

85 { if (isValid()) theData->removeReference();}
bool isValid() const
Definition: ProxyBase.h:78
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
bool ProxyBase< T, Cloner >::isValid ( void  ) const
inline
template<class T, class Cloner>
ProxyBase& ProxyBase< T, Cloner >::operator= ( const ProxyBase< T, Cloner > &  other)
inline

Definition at line 33 of file ProxyBase.h.

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

33  {
34  if ( theData != other.theData) {
35  destroy();
36  theData = other.theData;
37  if (theData) theData->addReference();
38  }
39  return *this;
40  }
void destroy()
Definition: ProxyBase.h:85
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
int ProxyBase< T, Cloner >::references ( ) const
inline

Definition at line 87 of file ProxyBase.h.

References ProxyBase< T, Cloner >::theData.

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

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

Definition at line 43 of file ProxyBase.h.

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

Referenced by swap(), and TrajectoryStateOnSurface::swap().

43  {
44  std::swap(theData,other.theData);
45  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T * theData
Definition: ProxyBase.h:90
template<class T, class Cloner>
T& ProxyBase< T, Cloner >::unsharedData ( )
inline

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

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

Member Data Documentation

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