Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CandRefer.h

Go to the documentation of this file.
00001 
00002 // $Id: CandRefer.h,v 1.3 2002/10/16 07:04:30 rhatcher Exp $
00003 //
00004 // CandRefer.h
00005 //
00006 // Class for controlling access to the CandBase class.
00007 //
00008 // The CandBase class inherits from CandRefCounted for ref-counting.
00009 //
00010 // Each concrete CandBase must define a Dup function.
00011 // Each concrete CandBase must grant friendship to class CandRefer.
00012 //
00013 // Adapted from Babar's BbrReferencer (written by Gautier Hamel de
00014 // Monchenault and Bob Jacobsen).
00015 //
00016 // Author:  G. Irwin 1/2000
00018 
00019 #ifndef CANDREFER_H
00020 #define CANDREFER_H
00021 
00022 // not inheriting from TObject so we need an explicit Rtypes
00023 #ifndef ROOT_Rtypes
00024 #if !defined(__CINT__) || defined(__MAKECINT__)
00025 #include "Rtypes.h"
00026 #endif
00027 #endif
00028 
00029 class CandBase;
00030 
00031 class CandRefer
00032 {
00033 
00034 public:
00035 
00036 // Constructors
00037    CandRefer();
00038    CandRefer(CandBase *ref);
00039    CandRefer(const CandRefer &cr);
00040    virtual ~CandRefer();
00041 
00042 // Operators -
00043 // Access
00044    CandBase *operator->() {return  fRef;}
00045    CandBase& operator*()  {return *fRef;}
00046    CandBase* operator()() {return  fRef;}
00047 
00048 // Const-access
00049    const CandBase* operator->() const {return  fRef;}
00050    const CandBase& operator*()  const {return *fRef;}
00051    const CandBase* operator()() const {return  fRef;}
00052 
00053 // Logical operators
00054    Bool_t operator==(const CandRefer &cr) const;
00055    Bool_t operator!=(const CandRefer &cr) const;
00056 
00057 // Assignment
00058    CandRefer &operator=(const CandRefer &cr);
00059 
00060 // Accessors -
00061 // Number of counted CandRefers to the referenced object (incl. this)
00062    Int_t GetNRefers() const;
00063 
00064 // Exclusive access 
00065    CandBase *OwnRef();
00066 
00067 // Modifiers -
00068 // Decrement the ref counter of the referenced object
00069    Int_t DecNRefer();
00070 
00071 // Drop the reference to the referenced object
00072    void DropRefer();
00073 
00074 // Increment the ref counter of the referenced object
00075    Int_t IncNRefer();
00076 
00077 // Set a new reference (after dropping a possible existing reference)
00078    void SetRef(CandBase *ref);
00079 
00080 private:
00081    CandBase *fRef;              // Pointer to referenced CandBase object
00082 
00083 ClassDef(CandRefer,1) // Controlled access to ref-counted CandBase class
00084 
00085 };
00086 
00087 #endif                                                    // CANDREFER_H

Generated on Mon Feb 15 11:06:28 2010 for loon by  doxygen 1.3.9.1