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

25 : theData(p) {if (theData) theData->addReference();}
T * theData
Definition: ProxyBase.h:91
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: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 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

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

81  {
82  if unlikely(theData == 0)
83  throw TrajectoryStateException("Error: uninitialized ProxyBase used");
84  }
#define unlikely(x)
T * theData
Definition: ProxyBase.h:91
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 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().

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, 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, 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 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