Panda3D
 All Classes Functions Variables Enumerations
memoryInfo.I
00001 // Filename: memoryInfo.I
00002 // Created by:  drose (04Jun01)
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 ////////////////////////////////////////////////////////////////////
00017 //     Function: MemoryInfo::get_void_ptr
00018 //       Access: Public
00019 //  Description: Returns the data pointer as a void pointer.  This
00020 //               should always be non-NULL.
00021 ////////////////////////////////////////////////////////////////////
00022 void *MemoryInfo::get_void_ptr() const {
00023   if (_void_ptr != (void *)NULL) {
00024     return _void_ptr;
00025   }
00026   if (_ref_ptr == (void *)NULL) {
00027     return _typed_ptr;
00028   }
00029   if (_typed_ptr == (void *)NULL) {
00030     return _ref_ptr;
00031   }
00032   return ((void *)_ref_ptr < (void *)_typed_ptr) ? (void *)_ref_ptr : (void *)_typed_ptr;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: MemoryInfo::get_ref_ptr
00037 //       Access: Public
00038 //  Description: Returns the data pointer as a ReferenceCount pointer.
00039 //               This may be NULL if the data pointer does not
00040 //               represent a ReferenceCount object.
00041 ////////////////////////////////////////////////////////////////////
00042 ReferenceCount *MemoryInfo::get_ref_ptr() const {
00043   return _ref_ptr;
00044 }
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //     Function: MemoryInfo::get_typed_ptr
00048 //       Access: Public
00049 //  Description: Returns the data pointer as a TypedObject pointer.
00050 //               This may be NULL if the data pointer does not
00051 //               represent a pointer to a TypedObject.
00052 ////////////////////////////////////////////////////////////////////
00053 TypedObject *MemoryInfo::get_typed_ptr() const {
00054   return _typed_ptr;
00055 }
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: MemoryInfo::is_size_known
00059 //       Access: Public
00060 //  Description: Returns true if the size of the memory block
00061 //               referenced by this pointer is known.  Most pointers'
00062 //               sizes should be known, but some may not be.
00063 ////////////////////////////////////////////////////////////////////
00064 bool MemoryInfo::is_size_known() const {
00065   return (_flags & F_size_known) != 0;
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: MemoryInfo::get_size
00070 //       Access: Public
00071 //  Description: Returns the size in bytes of the memory block
00072 //               referenced by this pointer, if it is known.  Returns
00073 //               zero if the size is not known.
00074 ////////////////////////////////////////////////////////////////////
00075 size_t MemoryInfo::get_size() const {
00076   return _size;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: MemoryInfo::get_time
00081 //       Access: Public
00082 //  Description: Returns the time in seconds (based on the
00083 //               GlobalClock) at which the pointer was allocated.
00084 ////////////////////////////////////////////////////////////////////
00085 double MemoryInfo::get_time() const {
00086   return _time;
00087 }
00088 
 All Classes Functions Variables Enumerations