Panda3D

memoryInfo.h

00001 // Filename: memoryInfo.h
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 #ifndef MEMORYINFO_H
00016 #define MEMORYINFO_H
00017 
00018 #include "pandabase.h"
00019 
00020 #ifdef DO_MEMORY_USAGE
00021 
00022 #include "typeHandle.h"
00023 
00024 class ReferenceCount;
00025 class TypedObject;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : MemoryInfo
00029 // Description : This is a supporting class for MemoryUsage.  It
00030 //               records the detailed information for a particular
00031 //               pointer allocated by Panda code.  This record is only
00032 //               kept if track-mem-usage is configured #t.
00033 //
00034 //               It's not exported from the DLL, and it doesn't even
00035 //               exist if we're compiling NDEBUG.
00036 ////////////////////////////////////////////////////////////////////
00037 class MemoryInfo {
00038 public:
00039   MemoryInfo();
00040 
00041 public:
00042   // Members to view the MemoryInfo structure.
00043   TypeHandle get_type();
00044 
00045   INLINE void *get_void_ptr() const;
00046   INLINE ReferenceCount *get_ref_ptr() const;
00047   INLINE TypedObject *get_typed_ptr() const;
00048 
00049   INLINE bool is_size_known() const;
00050   INLINE size_t get_size() const;
00051 
00052   INLINE double get_time() const;
00053 
00054 private:
00055   // Members to set up the MemoryInfo structure.
00056   void determine_dynamic_type();
00057   bool update_type_handle(TypeHandle &destination, TypeHandle refined);
00058 
00059 private:
00060   enum Flags {
00061     F_size_known              = 0x0001,
00062     F_reconsider_dynamic_type = 0x0002,
00063   };
00064   
00065   void *_void_ptr;
00066   ReferenceCount *_ref_ptr;
00067   TypedObject *_typed_ptr;
00068   size_t _size;
00069   TypeHandle _static_type;
00070   TypeHandle _dynamic_type;
00071   int _flags;
00072   
00073   double _time;
00074   int _freeze_index;
00075 
00076   friend class MemoryUsage;
00077 };
00078 
00079 #include "memoryInfo.I"
00080 
00081 #endif  // DO_MEMORY_USAGE
00082 
00083 #endif
00084 
 All Classes Functions Variables Enumerations