00001 /* 00002 ** (c) 1996-2000 The Regents of the University of California (through 00003 ** E.O. Lawrence Berkeley National Laboratory), subject to approval by 00004 ** the U.S. Department of Energy. Your use of this software is under 00005 ** license -- the license agreement is attached and included in the 00006 ** directory as license.txt or you may contact Berkeley Lab's Technology 00007 ** Transfer Department at TTD@lbl.gov. NOTICE OF U.S. GOVERNMENT RIGHTS. 00008 ** The Software was developed under funding from the U.S. Government 00009 ** which consequently retains certain rights as follows: the 00010 ** U.S. Government has been granted for itself and others acting on its 00011 ** behalf a paid-up, nonexclusive, irrevocable, worldwide license in the 00012 ** Software to reproduce, prepare derivative works, and perform publicly 00013 ** and display publicly. Beginning five (5) years after the date 00014 ** permission to assert copyright is obtained from the U.S. Department of 00015 ** Energy, and subject to any subsequent five (5) year renewals, the 00016 ** U.S. Government is granted for itself and others acting on its behalf 00017 ** a paid-up, nonexclusive, irrevocable, worldwide license in the 00018 ** Software to reproduce, prepare derivative works, distribute copies to 00019 ** the public, perform publicly and display publicly, and to permit 00020 ** others to do so. 00021 */ 00022 00023 #ifndef BL_USECOUNT_H 00024 #define BL_USECOUNT_H 00025 // 00026 // $Id: UseCount.H,v 1.13 2001/07/31 22:43:19 lijewski Exp $ 00027 // 00028 #include <BLassert.H> 00029 #include <BoxLib.H> 00030 00031 // 00032 // : 00034 00039 class UseCount 00040 { 00041 public: 00042 // 00044 // 00045 UseCount (); 00046 // 00048 // 00049 UseCount (const UseCount& rhs); 00050 00055 UseCount& operator= (const UseCount& rhs); 00056 // 00058 // 00059 ~UseCount (); 00060 // 00062 // 00063 bool unique () const; 00064 // 00066 // 00067 int linkCount () const; 00068 00069 private: 00070 // 00071 // A pointer to the reference count. 00072 // 00073 unsigned int* cnt; 00074 // 00075 // Decrement the reference count and delete the reference 00076 // counter if there are no more references. 00077 // 00078 void decrement (); 00079 }; 00080 00081 inline 00082 bool 00083 UseCount::unique () const 00084 { 00085 return *cnt == 1; 00086 } 00087 00088 inline 00089 int 00090 UseCount::linkCount () const 00091 { 00092 return *cnt; 00093 } 00094 00095 #endif /*BL_USECOUNT_H*/