CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

ZMuseCount.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 //  ZMuseCount.cc - utility class for use in reference-counting
00004 //
00005 //
00006 //  History:
00007 //    19-Sep-1997  WEB  Design stolen, and code adapted, from pp 70-73 of
00008 //      Koenig & Moo: "Ruminations on C++" (1996)
00009 //
00010 // ----------------------------------------------------------------------
00011 
00012 
00013 #ifndef ZMUSECOUNT_H
00014   #include "CLHEP/RefCount/ZMuseCount.h"
00015   #include "CLHEP/RefCount/ZMuseCount.icc"
00016 #endif
00017 
00018 
00019 bool ZMuseCount::makeonly()  {
00020 
00021   bool result = ( ! only() );
00022 
00023   if ( result )  {
00024     --*p;
00025     p = new int(1);
00026   }
00027 
00028   return result;
00029 
00030 }  // makeonly()
00031 
00032 
00033 bool ZMuseCount::reattach( const ZMuseCount & u )  {
00034 
00035   ++*u.p;
00036 
00037   bool result = ( --*p == 0 );
00038   if ( result )
00039     delete p;
00040 
00041   p = u.p;
00042   return result;
00043 
00044 }  // reattach()

Generated on Thu Jul 1 22:02:31 2010 for CLHEP by  doxygen 1.4.7