cel_referable.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00004 //
00005 // (C) 2003-2006 Celartem Technology Inc. All rights reserved.
00006 //----------------------------------------------------------------------------
00007 
00008 #ifndef _cel_referable_h_
00009 #define _cel_referable_h_
00010 
00011 #include "cel_types.h"
00012 #include "cel_autoptr.h"
00013 
00014 namespace Celartem
00015 {
00028     class Referable
00029     {
00030     public:
00034         Referable();
00035 
00039         void addRef() const;
00040 
00045         void releaseRef() const;
00046 
00051         size_t getReferenceCount() const {return m_refCount;}
00052 
00056         static void dumpDbgAllRefCount();
00057 
00058     private:
00059         mutable volatile size_t m_refCount;
00060 
00061         // duplication is not permitted
00062         Referable(const Referable&);
00063         Referable& operator=(const Referable&);
00064 
00065     protected:
00066         virtual ~Referable();
00067     };
00068     
00073     class ReferableNoTS
00074     {
00075     public:
00079         ReferableNoTS() : m_refCount(0) {}
00080 
00084         void addRef() const
00085         {
00086             ++m_refCount;
00087         }
00088 
00093         void releaseRef() const
00094         {
00095             if(--m_refCount == 0)
00096                 delete this;
00097         }
00098 
00102         size_t getReferenceCount() const {return m_refCount;}
00103 
00104     private:
00105         mutable size_t m_refCount;
00106 
00107         // duplication is not permitted
00108         ReferableNoTS(const ReferableNoTS&);
00109         ReferableNoTS& operator=(const ReferableNoTS&);
00110 
00111     protected:
00112         virtual ~ReferableNoTS() {}
00113     };
00114 } // namespace Celartem
00115 
00116 #endif // _cel_referable_h_

This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:21:54 2008.