Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.1 KiB

  1. // This is a part of the Active Template Library.
  2. // Copyright (C) 1996-2001 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Active Template Library Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Active Template Library product.
  10. #ifndef ATLDEBUG_SHAREDMEORY_ALLOCATOR_HEADER
  11. #define ATLDEBUG_SHAREDMEORY_ALLOCATOR_HEADER
  12. class CAtlTraceProcess;
  13. class CAtlTraceModule;
  14. class CAtlTraceCategory;
  15. class CTraceSnapshot
  16. {
  17. public:
  18. struct CModuleInfo
  19. {
  20. DWORD_PTR m_dwModule;
  21. int m_nCategories;
  22. int m_iFirstCategory;
  23. };
  24. public:
  25. CSimpleArray< CModuleInfo > m_aModules;
  26. CSimpleArray< DWORD_PTR > m_adwCategories;
  27. };
  28. class CAtlAllocator
  29. {
  30. public:
  31. CAtlAllocator() :
  32. m_dwPageSize(0),
  33. m_hMap(NULL),
  34. m_bValid(false),
  35. m_pProcess(NULL),
  36. m_bSnapshot(false)
  37. {
  38. }
  39. ~CAtlAllocator()
  40. {
  41. Close();
  42. }
  43. bool Init(const CHAR *pszFileMappingName, DWORD dwMaxSize);
  44. bool Open(const CHAR *pszFileMappingName);
  45. void Close(bool bForceUnmap = false);
  46. bool IsValid() const {return m_bValid;}
  47. CAtlTraceProcess *GetProcess() const {return m_pProcess;}
  48. CAtlTraceModule *GetModule(int iModule) const;
  49. // CAtlTraceCategory *GetCategory(int iModule, unsigned nCategory) const;
  50. CAtlTraceCategory* GetCategory(int iCategory) const;
  51. /*
  52. bool Lock(DWORD dwTimeOut);
  53. void Unlock();
  54. */
  55. bool LoadSettings(const CHAR *pszFileName);
  56. bool LoadSettings(const WCHAR *pszFileName);
  57. bool SaveSettings(const CHAR *pszFileName);
  58. bool SaveSettings(const WCHAR *pszFileName);
  59. int GetModuleCount() const;
  60. int GetCategoryCount(int iModule) const;
  61. int GetCategoryCount(const CAtlTraceModule& Module) const;
  62. int AddModule(HINSTANCE hInst);
  63. int AddCategory(int iModule, const WCHAR *szCategoryName);
  64. bool RemoveModule(int iModule);
  65. void CleanUp();
  66. void TakeSnapshot();
  67. void ReleaseSnapshot();
  68. CTraceSnapshot m_snapshot;
  69. bool m_bSnapshot;
  70. private:
  71. CAtlTraceProcess *m_pProcess;
  72. DWORD m_dwPageSize;
  73. HANDLE m_hMap;
  74. bool m_bValid;
  75. BYTE *m_pBufferStart;
  76. };
  77. #endif // ATLDEBUG_SHAREDMEORY_ALLOCATOR_HEADER