home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Samples / Samples / Profiler / heapmon / clsview.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-04  |  3.2 KB  |  160 lines

  1. // clsview.hpp
  2. //
  3. // Created 10/05/98
  4. //
  5. // (C)Copyright 1998-1999 Microsoft Corporation, All rights reserved.
  6. //
  7.  
  8. #ifndef __CLSVIEW_HPP__
  9. #define __CLSVIEW_HPP__
  10.  
  11. #include "baseview.hpp"
  12.  
  13.  
  14. #define WC_HEAPMONITOR_CLASSLISTVIEWER "JavaHeapMonitor_ClassListViewerClass"
  15.  
  16.  
  17. enum ClassViewerEvents
  18. {
  19.     CVWM_FIRST = WM_BC_LAST,
  20.  
  21.     CVWM_SNAPSHOT = CVWM_FIRST,
  22.  
  23.     CVWM_LAST,
  24. };
  25.  
  26.  
  27. // These are the fixed columns.  Two additional columns, "total size" and
  28. // "average age" are added if those capabilities are supported.
  29. #define CLV_COL_CLASSNAME       0
  30. #define CLV_COL_TOTALINSTANCES  1
  31. #define CLV_COL_LIVEINSTANCES   2
  32. #define CLV_COL_LIVESIZE        3
  33. #define CLV_NUM_COLUMNS         4
  34.  
  35.  
  36. class ClassListViewer : public BasicClient
  37. {
  38. private:
  39.  
  40.     static BOOL s_fRegisteredClass;
  41.  
  42.     HWND m_list;
  43.  
  44.     struct ClassDataSnapshot
  45.     {
  46.         CLASSID id;
  47.         __int64 totalinstances;
  48.         // Indicates that the following fields are valid
  49.         BOOL valid;
  50.         ULONG liveinstances;
  51.         ULONG totalsize;
  52.         ULONG livesize;
  53.         ULONG agesum;
  54.     };
  55.  
  56.  
  57.     //------------------------------------------------------------------------
  58.     // UI stuff
  59.     
  60.     static LRESULT CALLBACK WndProc (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
  61.  
  62.     BOOL OnCreateWindow ();
  63.  
  64.     static int PopulateListCB (ID id, PVOID token);
  65.  
  66.     BOOL AddClass (CLASSID cls);
  67.     VOID UpdateClassData (ClassDataSnapshot *pdata);
  68.  
  69.     VOID RedrawList ()
  70.     {
  71.         InvalidateRect(m_list, NULL, TRUE);
  72.         UpdateWindow(m_list);
  73.     }
  74.  
  75.     int m_sortcol;
  76.     int m_sortdir;
  77.  
  78.     static int CALLBACK SortColumnCB (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  79.  
  80.  
  81.     //------------------------------------------------------------------------
  82.     
  83.     // IHeapMonitorClient methods
  84.  
  85.     STDMETHODIMP OnStoppedExecution ()
  86.     {
  87.         return S_OK;
  88.     }
  89.     
  90.     STDMETHODIMP OnResumeExecution ()
  91.     {
  92.         return S_OK;
  93.     }
  94.  
  95.     STDMETHODIMP OnThreadCreated (THREADID thread)
  96.     {
  97.         return E_UNEXPECTED;
  98.     }
  99.     
  100.     STDMETHODIMP OnDestroyThread (THREADID thread)
  101.     {
  102.         return E_UNEXPECTED;
  103.     }
  104.  
  105.     STDMETHODIMP OnPackageCreated (PKGID pkg)
  106.     {
  107.         return S_OK;
  108.     }
  109.  
  110.     STDMETHODIMP OnClassLoaded (CLASSID cls)
  111.     {
  112.         AddClass(cls);
  113.         return S_OK;
  114.     }
  115.     
  116.     STDMETHODIMP OnUnloadClass (CLASSID cls)
  117.     {
  118.         // TODO
  119.         return S_OK;
  120.     }
  121.  
  122.     STDMETHODIMP RootReferences (RootReferencesEventInfo *pinfo)
  123.     {
  124.         return E_UNEXPECTED;
  125.     }
  126.  
  127.     STDMETHODIMP RootDiscoveryComplete ()
  128.     {
  129.         return E_UNEXPECTED;
  130.     }
  131.  
  132.     STDMETHODIMP OnObjectStatusChange (OBJID id)
  133.     {
  134.         return E_UNEXPECTED;
  135.     }
  136.  
  137.     STDMETHODIMP ObjectDiscoveryComplete ()
  138.     {
  139.         SendMessage(m_hwnd, CVWM_SNAPSHOT, 0, 0);
  140.         RedrawList();
  141.         return S_OK;
  142.     }
  143.  
  144.  
  145.     //------------------------------------------------------------------------
  146.     
  147. public:
  148.  
  149.     ClassListViewer ()
  150.     {
  151.         m_sortcol = -1;
  152.     }
  153.  
  154.     BOOL Initialize (HeapMonitorManager *mgr);
  155. };
  156.  
  157.  
  158. #endif /* __CLSVIEW_HPP__ */
  159.  
  160.