Panda3D
memoryUsagePointerCounts.h
1 // Filename: memoryUsagePointerCounts.h
2 // Created by: drose (04Jun01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MEMORYUSAGEPOINTERCOUNTS_H
16 #define MEMORYUSAGEPOINTERCOUNTS_H
17 
18 #include "pandabase.h"
19 
20 #ifdef DO_MEMORY_USAGE
21 
22 class MemoryInfo;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : MemoryUsagePointerCounts
26 // Description : This is a supporting class for MemoryUsage. It
27 // tracks the relative counts of a number of pointers of
28 // some type (or age), for use by TypeHistogram and
29 // AgeHistogram. It's not exported from the DLL, and it
30 // doesn't even exist if we're compiling NDEBUG.
31 ////////////////////////////////////////////////////////////////////
32 class MemoryUsagePointerCounts {
33 public:
34  INLINE MemoryUsagePointerCounts();
35  INLINE MemoryUsagePointerCounts(const MemoryUsagePointerCounts &copy);
36  INLINE void operator = (const MemoryUsagePointerCounts &copy);
37 
38  INLINE void clear();
39  void add_info(MemoryInfo *info);
40  void output(ostream &out) const;
41 
42  INLINE bool is_size_unknown() const;
43  INLINE size_t get_size() const;
44  INLINE int get_count() const;
45 
46  INLINE bool operator < (const MemoryUsagePointerCounts &other) const;
47 
48 private:
49  static void output_bytes(ostream &out, size_t size);
50 
51 private:
52  int _count;
53  int _unknown_size_count;
54  size_t _size;
55 };
56 
57 INLINE ostream &operator << (ostream &out, const MemoryUsagePointerCounts &c);
58 
59 #include "memoryUsagePointerCounts.I"
60 
61 #endif // DO_MEMORY_USAGE
62 
63 #endif
64