CandRefer Class Reference

#include <CandRefer.h>

List of all members.

Public Member Functions

 CandRefer ()
 CandRefer (CandBase *ref)
 CandRefer (const CandRefer &cr)
virtual ~CandRefer ()
CandBaseoperator-> ()
CandBaseoperator* ()
CandBaseoperator() ()
const CandBaseoperator-> () const
const CandBaseoperator* () const
const CandBaseoperator() () const
Bool_t operator== (const CandRefer &cr) const
Bool_t operator!= (const CandRefer &cr) const
CandReferoperator= (const CandRefer &cr)
Int_t GetNRefers () const
CandBaseOwnRef ()
Int_t DecNRefer ()
void DropRefer ()
Int_t IncNRefer ()
void SetRef (CandBase *ref)

Private Attributes

CandBasefRef

Detailed Description

Definition at line 31 of file CandRefer.h.


Constructor & Destructor Documentation

CandRefer::CandRefer (  ) 

Definition at line 34 of file CandRefer.cxx.

00034                      :
00035   fRef(0) 
00036 {
00037 }

CandRefer::CandRefer ( CandBase ref  ) 

Definition at line 40 of file CandRefer.cxx.

References IncNRefer().

00040                                   :
00041   fRef(ref) 
00042 {
00043    IncNRefer();
00044 }

CandRefer::CandRefer ( const CandRefer cr  ) 

Definition at line 47 of file CandRefer.cxx.

References fRef, and IncNRefer().

00048 {
00049    fRef = cr.fRef;
00050    IncNRefer();
00051 }

CandRefer::~CandRefer (  )  [virtual]

Definition at line 54 of file CandRefer.cxx.

References DropRefer().

00055 { 
00056    DropRefer();
00057 }


Member Function Documentation

Int_t CandRefer::DecNRefer (  ) 

Definition at line 83 of file CandRefer.cxx.

References CandRefCounted::DropLink(), and fRef.

Referenced by DropRefer(), and OwnRef().

00084 {
00085    if (fRef) return fRef->DropLink() - 1;   // Subtract LocalHandle link
00086    return 0;
00087 }

void CandRefer::DropRefer (  ) 

Definition at line 90 of file CandRefer.cxx.

References DecNRefer(), and fRef.

Referenced by operator=(), SetRef(), and ~CandRefer().

00091 {
00092    if (fRef && DecNRefer()==0) delete fRef;
00093    fRef = (CandBase *) 0;
00094 }

Int_t CandRefer::GetNRefers (  )  const

Definition at line 104 of file CandRefer.cxx.

References fRef, and CandRefCounted::GetNLinks().

Referenced by CandHandle::GetNRefers(), and OwnRef().

00105 {
00106    if (fRef) return fRef->GetNLinks() - 1;  // Subtract LocalHandle link
00107    return 0;
00108 }

Int_t CandRefer::IncNRefer (  ) 

Definition at line 97 of file CandRefer.cxx.

References CandRefCounted::AddLink(), and fRef.

Referenced by CandRefer(), operator=(), OwnRef(), and SetRef().

00098 {
00099    if (fRef) return fRef->AddLink() - 1;    // Subtract LocalHandle link
00100    return 0;
00101 }

Bool_t CandRefer::operator!= ( const CandRefer cr  )  const

Definition at line 66 of file CandRefer.cxx.

References fRef.

00067 { 
00068    return (fRef != cr.fRef);
00069 }

const CandBase* CandRefer::operator() (  )  const [inline]

Definition at line 51 of file CandRefer.h.

References fRef.

00051 {return  fRef;}

CandBase* CandRefer::operator() (  )  [inline]

Definition at line 46 of file CandRefer.h.

References fRef.

00046 {return  fRef;}

const CandBase& CandRefer::operator* (  )  const [inline]

Definition at line 50 of file CandRefer.h.

References fRef.

00050 {return *fRef;}

CandBase& CandRefer::operator* (  )  [inline]

Definition at line 45 of file CandRefer.h.

References fRef.

00045 {return *fRef;}

const CandBase* CandRefer::operator-> (  )  const [inline]

Definition at line 49 of file CandRefer.h.

References fRef.

00049 {return  fRef;}

CandBase* CandRefer::operator-> (  )  [inline]

Definition at line 44 of file CandRefer.h.

References fRef.

00044 {return  fRef;}

CandRefer & CandRefer::operator= ( const CandRefer cr  ) 

Definition at line 72 of file CandRefer.cxx.

References DropRefer(), fRef, and IncNRefer().

00073 {
00074    if ((this != &cr) && (fRef != cr.fRef)) {
00075      DropRefer();
00076      fRef = cr.fRef;
00077      IncNRefer();
00078    }
00079    return *this;
00080 } 

Bool_t CandRefer::operator== ( const CandRefer cr  )  const

Definition at line 60 of file CandRefer.cxx.

References fRef.

00061 { 
00062    return (fRef == cr.fRef);
00063 }

CandBase * CandRefer::OwnRef (  ) 

Definition at line 111 of file CandRefer.cxx.

References DecNRefer(), CandBase::Dup(), fRef, GetNRefers(), IncNRefer(), Msg::kSynopsis, and MSG.

Referenced by CandHandle::GetOwnedCandBase().

00112 {
00113 
00114 // Make sure the reference exists
00115    assert(fRef!=0);
00116     
00117 // Make sure the referenced object has links (at least this one)
00118    assert(GetNRefers() > 0);
00119 
00120    if (GetNRefers() != 1) {  // No exclusive access to referenced object
00121 
00122      MSG("Cand", Msg::kSynopsis) << "Candidate object of class "
00123          << fRef->ClassName() << " cloned before modification." << endl;
00124 
00125 // Decrement the referenced object counter
00126      DecNRefer();
00127      assert(GetNRefers() > 0);
00128 
00129 // Clone the referenced object
00130      fRef = fRef->Dup();
00131 
00132 // Increment the new referenced object counter
00133      IncNRefer();
00134      assert(GetNRefers()==1);
00135    }
00136 
00137 // Return the reference
00138    return fRef;
00139 }

void CandRefer::SetRef ( CandBase ref  ) 

Definition at line 142 of file CandRefer.cxx.

References DropRefer(), fRef, and IncNRefer().

00143 {
00144    if (ref != fRef) {
00145      DropRefer();
00146      fRef = ref;
00147      IncNRefer();
00148    }
00149 }


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1