Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TRefCnt.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   04/08/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TRefCnt
0013 #define ROOT_TRefCnt
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 //  TRefCnt                                                             //
0019 //                                                                      //
0020 //  Base class for reference counted objects.                           //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "RtypesCore.h"
0025 
0026 
0027 class TRefCnt {
0028 
0029 protected:
0030    UInt_t  fRefs;      // (1 less than) number of references
0031 
0032 public:
0033    enum EReferenceFlag { kStaticInit };
0034 
0035    TRefCnt(Int_t initRef = 0) : fRefs((UInt_t)initRef-1) { }
0036    TRefCnt(EReferenceFlag);
0037    virtual ~TRefCnt() { }
0038    UInt_t   References() const      { return fRefs+1; }
0039    void     SetRefCount(UInt_t r)   { fRefs = r-1; }
0040    void     AddReference()          { fRefs++; }
0041    UInt_t   RemoveReference()       { return fRefs--; }
0042 };
0043 
0044 #endif