Panda3D

Loading...
Searching...
No Matches
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 */
17INLINE MemoryUsagePointerCounts::
18MemoryUsagePointerCounts() {
19 _count = 0;
20 _unknown_size_count = 0;
21 _size = 0;
22}
23
24/**
25 *
26 */
27INLINE MemoryUsagePointerCounts::
28MemoryUsagePointerCounts(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 */
38INLINE void MemoryUsagePointerCounts::
39operator = (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 */
48INLINE void MemoryUsagePointerCounts::
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 */
59INLINE bool MemoryUsagePointerCounts::
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 */
68INLINE size_t MemoryUsagePointerCounts::
69 get_size() const {
70 return _size;
71}
72
73/**
74 * Returns the total number of pointers in the count.
75 */
76INLINE int MemoryUsagePointerCounts::
77 get_count() const {
78 return _count;
79}
80
81/**
82 *
83 */
84INLINE bool MemoryUsagePointerCounts::
85operator < (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
101INLINE std::ostream &
102operator << (std::ostream &out, const MemoryUsagePointerCounts &c) {
103 c.output(out);
104 return out;
105}
MemoryUsagePointerCounts
This is a supporting class for MemoryUsage.
Definition memoryUsagePointerCounts.h:27
MemoryUsagePointerCounts::get_size
size_t get_size() const
Returns the total allocated size of all pointers in the count whose size is known.
Definition memoryUsagePointerCounts.I:69
MemoryUsagePointerCounts::get_count
int get_count() const
Returns the total number of pointers in the count.
Definition memoryUsagePointerCounts.I:77
MemoryUsagePointerCounts::clear
void clear()
Resets the counter to empty.
Definition memoryUsagePointerCounts.I:49
MemoryUsagePointerCounts::is_size_unknown
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...
Definition memoryUsagePointerCounts.I:60