Panda3D
memoryUsagePointerCounts.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file memoryUsagePointerCounts.I
10  * @author drose
11  * @date 2001-06-04
12  */
13 
14 /**
15  *
16  */
17 INLINE MemoryUsagePointerCounts::
18 MemoryUsagePointerCounts() {
19  _count = 0;
20  _unknown_size_count = 0;
21  _size = 0;
22 }
23 
24 /**
25  *
26  */
27 INLINE MemoryUsagePointerCounts::
28 MemoryUsagePointerCounts(const MemoryUsagePointerCounts &copy) :
29  _count(copy._count),
30  _unknown_size_count(copy._unknown_size_count),
31  _size(copy._size)
32 {
33 }
34 
35 /**
36  *
37  */
38 INLINE void MemoryUsagePointerCounts::
39 operator = (const MemoryUsagePointerCounts &copy) {
40  _count = copy._count;
41  _unknown_size_count = copy._unknown_size_count;
42  _size = copy._size;
43 }
44 
45 /**
46  * Resets the counter to empty.
47  */
49 clear() {
50  _count = 0;
51  _unknown_size_count = 0;
52  _size = 0;
53 }
54 
55 /**
56  * Returns true if none of the pointers in the count have a known size, or
57  * false if at least one of them does.
58  */
60 is_size_unknown() const {
61  return _unknown_size_count == _count;
62 }
63 
64 /**
65  * Returns the total allocated size of all pointers in the count whose size is
66  * known.
67  */
68 INLINE size_t MemoryUsagePointerCounts::
69 get_size() const {
70  return _size;
71 }
72 
73 /**
74  * Returns the total number of pointers in the count.
75  */
77 get_count() const {
78  return _count;
79 }
80 
81 /**
82  *
83  */
84 INLINE bool MemoryUsagePointerCounts::
85 operator < (const MemoryUsagePointerCounts &other) const {
86  if (is_size_unknown() != other.is_size_unknown()) {
87  return is_size_unknown() > other.is_size_unknown();
88  }
89 
90  if (get_size() != other.get_size()) {
91  return get_size() < other.get_size();
92  }
93 
94  if (get_count() != other.get_count()) {
95  return get_count() != other.get_count();
96  }
97 
98  return false;
99 }
100 
101 INLINE std::ostream &
102 operator << (std::ostream &out, const MemoryUsagePointerCounts &c) {
103  c.output(out);
104  return out;
105 }
bool is_size_unknown() const
Returns true if none of the pointers in the count have a known size, or false if at least one of them...
int get_count() const
Returns the total number of pointers in the count.
void clear()
Resets the counter to empty.
size_t get_size() const
Returns the total allocated size of all pointers in the count whose size is known.
This is a supporting class for MemoryUsage.