00001 /* 00002 * Copyright (C) 1991-9 Eric M. Hopper <hopper@omnifarious.mn.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License as published 00006 * by the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, but 00010 * WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 /* $Header: /home/hopper/src/cvs/C++/LCore/rfcntptr.cxx,v 1.6 2002/08/29 00:58:04 hopper Exp $ */ 00020 00021 // For a log, see ChangeLog 00022 // 00023 // Revision 1.3 1998/05/01 11:58:44 hopper 00024 // Cleaned DelReference up a little. 00025 // 00026 // Revision 1.2 1997/05/12 16:34:53 hopper 00027 // Fixed #include directives so auto-dependency generator would work better. 00028 // -- 00029 // Also fixed reference count is decremented to 0 before actual deletion. 00030 // This doesn't fix any current bug, but may prevent future ones in 00031 // multi-threaded environments, and also reduces confusion. 00032 // 00033 // Revision 1.1 1997/05/12 14:32:39 hopper 00034 // Added new RefCountPtr class, and RefCountPtrT class to aid in using 00035 // the ReferenceCounting mixin class. 00036 // 00037 00038 #ifdef __GNUG__ 00039 # pragma implementation "RefCountPtr.h" 00040 #endif 00041 00042 #define _LCORE_RefCountPtr_H_CC 00043 #include "LCore/RefCountPtr.h" 00044 #undef _LCORE_RefCountPtr_H_CC 00045 00046 #include "LCore/RefCounting.h" 00047 00048 namespace strmod { 00049 namespace lcore { 00050 00051 const LCore_ClassIdent RefCountPtr::identifier(9UL); 00052 00053 void RefCountPtr::i_SetPtr(ReferenceCounting *p, bool deleteref) 00054 { 00055 if (p) { 00056 p->AddReference(); 00057 } 00058 if (ptr_ && deleteref) { 00059 if (ptr_->NumReferences() > 0) { 00060 ptr_->DelReference(); 00061 } 00062 if (ptr_->NumReferences() <= 0) { 00063 delete ptr_; 00064 } 00065 } 00066 ptr_ = p; 00067 } 00068 00069 } // namespace lcore 00070 } // namespace strmod
1.3-rc1