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

CountRef.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) Members of the EGEE Collaboration. 2004-2010.
00003 See http://www.eu-egee.org/partners for details on the copyright holders.
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 */
00017 
00018 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__
00019 #define __EDG_WORKLOAD_LOGGING_CLIENT_COUNTREF_HPP__
00020 
00024 #define EWL_BEGIN_NAMESPACE namespace glite { namespace lb {
00025 
00029 #define EWL_END_NAMESPACE } }
00030 
00031 EWL_BEGIN_NAMESPACE
00032 
00042 template<typename T>
00043 class CountRef {
00044 public:
00045         CountRef(void *); 
00046 //      CountRef(void *,void (*)(void *));
00047 
00048         void use(void); 
00049         void release(void);
00050 
00051         void    *ptr; 
00053 private:
00054         int     count;
00055 //      void    (*destroy)(void *);
00056 };
00057 
00062 template <typename T>
00063 CountRef<T>::CountRef(void *p)
00064 {
00065         ptr = p;
00066         count = 1;
00067 }
00068 
00075 template <typename T>
00076 void CountRef<T>::release(void)
00077 {
00078         if (--count == 0) {
00079                 T::destroyFlesh(ptr);
00080                 delete this;
00081         }
00082 }
00083 
00089 template <typename T>
00090 void CountRef<T>::use(void)
00091 {
00092         count++;
00093 }
00094 
00095 EWL_END_NAMESPACE
00096 
00097 #endif

Generated on Fri Aug 20 13:06:41 2010 for Glite LB Client: CPP - Interface by  doxygen 1.3.9.1