Panda3D

memoryUsagePointers.I

00001 // Filename: memoryUsagePointers.I
00002 // Created by:  drose (25May00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 ////////////////////////////////////////////////////////////////////
00016 //     Function: MemoryUsagePointers::Entry::Constructor
00017 //       Access: Public
00018 //  Description:
00019 ////////////////////////////////////////////////////////////////////
00020 INLINE MemoryUsagePointers::Entry::
00021 Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr,
00022       TypeHandle type, double age) :
00023   _ref_ptr(ref_ptr),
00024   _typed_ptr(typed_ptr),
00025   _type(type),
00026   _age(age)
00027 {
00028   _ref_ptr->ref();
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: MemoryUsagePointers::Entry::Copy Constructor
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 INLINE MemoryUsagePointers::Entry::
00037 Entry(const Entry &copy) :
00038   _ref_ptr(copy._ref_ptr),
00039   _typed_ptr(copy._typed_ptr),
00040   _type(copy._type),
00041   _age(copy._age)
00042 {
00043   _ref_ptr->ref();
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: MemoryUsagePointers::Entry::Copy Assignment Operator
00048 //       Access: Public
00049 //  Description:
00050 ////////////////////////////////////////////////////////////////////
00051 INLINE void MemoryUsagePointers::Entry::
00052 operator = (const Entry &copy) {
00053   if (_ref_ptr != copy._ref_ptr) {
00054     _ref_ptr->unref();
00055     _ref_ptr = copy._ref_ptr;
00056     // We can't call unref_delete(), because we don't know what kind
00057     // of pointer it is precisely.  Potential leak.
00058     _ref_ptr->ref();
00059   }
00060   _typed_ptr = copy._typed_ptr;
00061   _type = copy._type;
00062   _age = copy._age;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: MemoryUsagePointers::Entry::Destructor
00067 //       Access: Public
00068 //  Description:
00069 ////////////////////////////////////////////////////////////////////
00070 INLINE MemoryUsagePointers::Entry::
00071 ~Entry() {
00072   // We can't call unref_delete(), because we don't know what kind
00073   // of pointer it is precisely.  Potential leak.
00074   _ref_ptr->unref();
00075 }
00076 
 All Classes Functions Variables Enumerations