    // @(#)root/base:$Name:  $:$Id: TRefCnt.h,v 1.2 2000/12/13 16:45:35 brun Exp $
    // Author: Fons Rademakers   04/08/95

    /*************************************************************************
     * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
     * All rights reserved.                                                  *
     *                                                                       *
     * For the licensing terms see $ROOTSYS/LICENSE.                         *
     * For the list of contributors see $ROOTSYS/README/CREDITS.             *
     *************************************************************************/

    #ifndef ROOT_TRefCnt
    #define ROOT_TRefCnt

    //////////////////////////////////////////////////////////////////////////
    //                                                                      //
    //  TRefCnt                                                             //
    //                                                                      //
    //  Base class for reference counted objects.                           //
    //                                                                      //
    //////////////////////////////////////////////////////////////////////////

    #ifndef ROOT_Rtypes
    #include "Rtypes.h"
    #endif

    class TRefCnt {

    protected:
       UInt_t  fRefs;      // (1 less than) number of references

    public:
       enum EReferenceFlag { kStaticInit };

       TRefCnt(Int_t initRef = 0) : fRefs((UInt_t)initRef-1) { }
       TRefCnt(EReferenceFlag) { }  // leave fRefs alone
       UInt_t   References() const      { return fRefs+1; }
       void     SetRefCount(UInt_t r)   { fRefs = r-1; }
       void     AddReference()          { fRefs++; }
       UInt_t   RemoveReference()       { return fRefs--; }
    };

    #endif