00001 // Filename: memoryUsagePointers.I 00002 // Created by: drose (25May00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: MemoryUsagePointers::Entry::Constructor 00021 // Access: Public 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE MemoryUsagePointers::Entry:: 00025 Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr, 00026 TypeHandle type, double age) : 00027 _ref_ptr(ref_ptr), 00028 _typed_ptr(typed_ptr), 00029 _type(type), 00030 _age(age) 00031 { 00032 _ref_ptr->ref(); 00033 } 00034 00035 //////////////////////////////////////////////////////////////////// 00036 // Function: MemoryUsagePointers::Entry::Copy Constructor 00037 // Access: Public 00038 // Description: 00039 //////////////////////////////////////////////////////////////////// 00040 INLINE MemoryUsagePointers::Entry:: 00041 Entry(const Entry ©) : 00042 _ref_ptr(copy._ref_ptr), 00043 _typed_ptr(copy._typed_ptr), 00044 _type(copy._type), 00045 _age(copy._age) 00046 { 00047 _ref_ptr->ref(); 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: MemoryUsagePointers::Entry::Copy Assigment Operator 00052 // Access: Public 00053 // Description: 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE void MemoryUsagePointers::Entry:: 00056 operator = (const Entry ©) { 00057 if (_ref_ptr != copy._ref_ptr) { 00058 _ref_ptr->unref(); 00059 _ref_ptr = copy._ref_ptr; 00060 // We can't call unref_delete(), because we don't know what kind 00061 // of pointer it is precisely. Potential leak. 00062 _ref_ptr->ref(); 00063 } 00064 _typed_ptr = copy._typed_ptr; 00065 _type = copy._type; 00066 _age = copy._age; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: MemoryUsagePointers::Entry::Destructor 00071 // Access: Public 00072 // Description: 00073 //////////////////////////////////////////////////////////////////// 00074 INLINE MemoryUsagePointers::Entry:: 00075 ~Entry() { 00076 // We can't call unref_delete(), because we don't know what kind 00077 // of pointer it is precisely. Potential leak. 00078 _ref_ptr->unref(); 00079 } 00080