#ifndef RECO_REFCOUNT_H
#define RECO_REFCOUNT_H

///_____________________________________________________________________________
/// \class RefCount
///
/// \brief
/// Class RefCount defines (and implements) reference counting. All objects
/// using Handle<> smart pointer should inherit from RefCount.   
///
///_____________________________________________________________________________

namespace Reco
{
   class RefCount
   {
   public:
      
      RefCount();
      virtual ~RefCount();
      
      void add_ref() { ++fCount; }
      void release() { if ( --fCount == 0 ) delete this; }
      
      short use_count() const { return fCount; }
      
   private:
      
      short fCount;     // reference count
   };
   
   inline RefCount::RefCount() : fCount(0) 
   {}
   
   inline RefCount::~RefCount()
   {}
}

#endif
