Panda3D
 All Classes Functions Variables Enumerations
memoryUsagePointerCounts.I
00001 // Filename: memoryUsagePointerCounts.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: MemoryUsagePointerCounts::Constructor
00018 //       Access: Public
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE MemoryUsagePointerCounts::
00022 MemoryUsagePointerCounts() {
00023   _count = 0;
00024   _unknown_size_count = 0;
00025   _size = 0;
00026 }
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //     Function: MemoryUsagePointerCounts::Copy Constructor
00030 //       Access: Public
00031 //  Description: 
00032 ////////////////////////////////////////////////////////////////////
00033 INLINE MemoryUsagePointerCounts::
00034 MemoryUsagePointerCounts(const MemoryUsagePointerCounts &copy) :
00035   _count(copy._count),
00036   _unknown_size_count(copy._unknown_size_count),
00037   _size(copy._size)
00038 {
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: MemoryUsagePointerCounts::Copy Assignment
00043 //       Access: Public
00044 //  Description: 
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE void MemoryUsagePointerCounts::
00047 operator = (const MemoryUsagePointerCounts &copy) {
00048   _count = copy._count;
00049   _unknown_size_count = copy._unknown_size_count;
00050   _size = copy._size;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: MemoryUsagePointerCounts::clear
00055 //       Access: Public
00056 //  Description: Resets the counter to empty.
00057 ////////////////////////////////////////////////////////////////////
00058 INLINE void MemoryUsagePointerCounts::
00059 clear() {
00060   _count = 0;
00061   _unknown_size_count = 0;
00062   _size = 0;
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: MemoryUsagePointerCounts::is_size_unknown
00067 //       Access: Public
00068 //  Description: Returns true if none of the pointers in the count
00069 //               have a known size, or false if at least one of them
00070 //               does.
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE bool MemoryUsagePointerCounts::
00073 is_size_unknown() const {
00074   return _unknown_size_count == _count;
00075 }
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: MemoryUsagePointerCounts::get_size
00079 //       Access: Public
00080 //  Description: Returns the total allocated size of all pointers in
00081 //               the count whose size is known.
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE size_t MemoryUsagePointerCounts::
00084 get_size() const {
00085   return _size;
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: MemoryUsagePointerCounts::get_count
00090 //       Access: Public
00091 //  Description: Returns the total number of pointers in the count.
00092 ////////////////////////////////////////////////////////////////////
00093 INLINE int MemoryUsagePointerCounts::
00094 get_count() const {
00095   return _count;
00096 }
00097 
00098 ////////////////////////////////////////////////////////////////////
00099 //     Function: MemoryUsagePointerCounts::Ordering Operator
00100 //       Access: Public
00101 //  Description:
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE bool MemoryUsagePointerCounts::
00104 operator < (const MemoryUsagePointerCounts &other) const {
00105   if (is_size_unknown() != other.is_size_unknown()) {
00106     return is_size_unknown() > other.is_size_unknown();
00107   }
00108 
00109   if (get_size() != other.get_size()) {
00110     return get_size() < other.get_size();
00111   }
00112 
00113   if (get_count() != other.get_count()) {
00114     return get_count() != other.get_count();
00115   }
00116 
00117   return false;
00118 }
00119 
00120 INLINE ostream &
00121 operator << (ostream &out, const MemoryUsagePointerCounts &c) {
00122   c.output(out);
00123   return out;
00124 }
 All Classes Functions Variables Enumerations