00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MEMORYUSAGEPOINTERS_H
00016 #define MEMORYUSAGEPOINTERS_H
00017
00018 #include "pandabase.h"
00019
00020 #ifdef DO_MEMORY_USAGE
00021
00022 #include "typedObject.h"
00023 #include "pointerTo.h"
00024 #include "referenceCount.h"
00025 #include "pvector.h"
00026
00027 #ifdef HAVE_PYTHON
00028
00029 #undef _POSIX_C_SOURCE
00030 #include <Python.h>
00031
00032 #endif // HAVE_PYTHON
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class EXPCL_PANDAEXPRESS MemoryUsagePointers {
00056 PUBLISHED:
00057 MemoryUsagePointers();
00058 ~MemoryUsagePointers();
00059
00060 int get_num_pointers() const;
00061 ReferenceCount *get_pointer(int n) const;
00062 MAKE_SEQ(get_pointers, get_num_pointers, get_pointer);
00063 TypedObject *get_typed_pointer(int n) const;
00064 MAKE_SEQ(get_typed_pointers, get_num_pointers, get_typed_pointer);
00065
00066 TypeHandle get_type(int n) const;
00067 string get_type_name(int n) const;
00068 double get_age(int n) const;
00069
00070 #ifdef HAVE_PYTHON
00071 PyObject *get_python_pointer(int n) const;
00072 #endif
00073
00074 void clear();
00075
00076 void output(ostream &out) const;
00077
00078 private:
00079 void add_entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr,
00080 TypeHandle type, double age);
00081
00082 class Entry {
00083 public:
00084 INLINE Entry(ReferenceCount *ref_ptr, TypedObject *typed_ptr,
00085 TypeHandle type, double age);
00086 INLINE Entry(const Entry ©);
00087 INLINE void operator = (const Entry ©);
00088 INLINE ~Entry();
00089
00090
00091
00092
00093
00094
00095 ReferenceCount *_ref_ptr;
00096 TypedObject *_typed_ptr;
00097 TypeHandle _type;
00098 double _age;
00099 };
00100
00101 typedef pvector<Entry> Entries;
00102 Entries _entries;
00103 friend class MemoryUsage;
00104 };
00105
00106 INLINE ostream &operator << (ostream &out, const MemoryUsagePointers &mup) {
00107 mup.output(out);
00108 return out;
00109 }
00110
00111 #include "memoryUsagePointers.I"
00112
00113 #endif // MEMORY_USAGE_POINTERS
00114
00115 #endif
00116