Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

CountRef.h

00001 #ifndef _EDG_WORKLOAD_LOGGING_COUNTREF_H_
00002 #define _EDG_WORKLOAD_LOGGING_COUNTREF_H_
00003 
00004 #define EWL_BEGIN_NAMESPACE namespace edg { namespace workload { namespace logging { namespace client {
00005 #define EWL_END_NAMESPACE } } } }
00006 
00007 EWL_BEGIN_NAMESPACE;
00008 
00009 template<typename T>
00010 class CountRef {
00011 public:
00012         CountRef(void *);
00013 //      CountRef(void *,void (*)(void *));
00014 
00015         void use(void);
00016         void release(void);
00017 
00018         void    *ptr;
00019 private:
00020         int     count;
00021 //      void    (*destroy)(void *);
00022 };
00023 
00024 template <typename T>
00025 CountRef<T>::CountRef(void *p)
00026 {
00027         ptr = p;
00028         count = 1;
00029 }
00030 
00031 template <typename T>
00032 void CountRef<T>::release(void)
00033 {
00034         if (--count == 0) {
00035                 T::destroyFlesh(ptr);
00036                 delete this;
00037         }
00038 }
00039 
00040 template <typename T>
00041 void CountRef<T>::use(void)
00042 {
00043         count++;
00044 }
00045 
00046 EWL_END_NAMESPACE;
00047 
00048 #endif

Generated on Fri May 14 14:19:00 2004 for L&B API CPP by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002