Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members

CountRef.h

Go to the documentation of this file.
00001 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__
00002 #define __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__
00003 
00007 #define EWL_BEGIN_NAMESPACE namespace glite { namespace lb {
00008 
00012 #define EWL_END_NAMESPACE } }
00013 
00014 EWL_BEGIN_NAMESPACE
00015 
00025 template<typename T>
00026 class CountRef {
00027 public:
00028         CountRef(void *); 
00029 //      CountRef(void *,void (*)(void *));
00030 
00031         void use(void); 
00032         void release(void);
00033 
00034         void    *ptr; 
00036 private:
00037         int     count;
00038 //      void    (*destroy)(void *);
00039 };
00040 
00045 template <typename T>
00046 CountRef<T>::CountRef(void *p)
00047 {
00048         ptr = p;
00049         count = 1;
00050 }
00051 
00058 template <typename T>
00059 void CountRef<T>::release(void)
00060 {
00061         if (--count == 0) {
00062                 T::destroyFlesh(ptr);
00063                 delete this;
00064         }
00065 }
00066 
00072 template <typename T>
00073 void CountRef<T>::use(void)
00074 {
00075         count++;
00076 }
00077 
00078 EWL_END_NAMESPACE
00079 
00080 #endif

Generated on Wed Jun 27 13:43:06 2007 for Glite LB Client: CPP - Interface by doxygen 1.3.5