home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / dxtdbg.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  3.4 KB  |  98 lines

  1. /*******************************************************************************
  2. * DXTDbg.h *
  3. *----------*
  4. *   Description:
  5. *       This header file contains the custom error codes specific to DX Transforms
  6. *-------------------------------------------------------------------------------
  7. *  Created By: EDC                                      Date: 03/31/98
  8. *  Copyright (C) 1998 Microsoft Corporation
  9. *  All Rights Reserved
  10. *
  11. *-------------------------------------------------------------------------------
  12. *  Revisions:
  13. *
  14. *******************************************************************************/
  15. #ifndef DXTDbg_h
  16. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  17. #define DXTDbg_h
  18.  
  19. #ifndef _INC_CRTDBG
  20. #include <crtdbg.h>
  21. #endif
  22.  
  23. #define DXTDBG_FUNC_TRACE   1
  24. #define DXTDBG_INFO         2
  25.  
  26. class CDXTDbgFlags
  27. {
  28.   public:
  29.     DWORD m_F;
  30.     CDXTDbgFlags()
  31.     {
  32.         m_F = 0;
  33.         HKEY hkResult;
  34.         DWORD dwDisposition;
  35.         if( RegCreateKeyEx( HKEY_CLASSES_ROOT, _T("DXTDbgFlags"), 0, NULL, 0,
  36.                             KEY_ALL_ACCESS, NULL, &hkResult, &dwDisposition )
  37.                             == ERROR_SUCCESS )
  38.         {
  39.             if( dwDisposition == REG_CREATED_NEW_KEY )
  40.             {
  41.                 RegSetValueEx( hkResult, _T("Flags"), NULL, REG_DWORD, (PBYTE)&m_F, sizeof( m_F ) );
  42.             }
  43.             else
  44.             {
  45.                 DWORD BuffSize = sizeof( m_F );
  46.                 RegQueryValueEx( hkResult, _T("Flags"), NULL, NULL, (PBYTE)&m_F, &BuffSize );
  47.             }
  48.             RegCloseKey( hkResult );
  49.         }
  50.     }
  51. };
  52.  
  53. class CDXTDbgScope
  54. {
  55.   public:
  56.     static CDXTDbgFlags m_DebugFlags; 
  57.     PCHAR  m_pFuncName;
  58.     CDXTDbgScope( PCHAR pFuncName )
  59.     {
  60.         m_pFuncName = pFuncName;
  61.         if( m_DebugFlags.m_F & DXTDBG_FUNC_TRACE )
  62.         {
  63.             _RPT1( _CRT_WARN, "\nEntering Function: %s\n", m_pFuncName );
  64.         }
  65.     }
  66.     ~CDXTDbgScope()
  67.     {
  68.         if( m_DebugFlags.m_F & DXTDBG_FUNC_TRACE )
  69.         {
  70.             _RPT1( _CRT_WARN, "Leaving Function: %s\n", m_pFuncName );
  71.         }
  72.     }
  73. };
  74.  
  75. //=== User macros ==============================================================
  76. #ifdef _DEBUG
  77. #define DXTDBG_FUNC( name ) CDXTDbgScope DXTDbgScope( name ); 
  78. #define DXTDBG_MSG0( reportType, format ) \
  79.     if( DXTDbgScope.m_DebugFlags.m_F & DXTDBG_INFO ) _RPTF0( reportType, format );
  80. #define DXTDBG_MSG1( reportType, format, arg1 ) \
  81.     if( DXTDbgScope.m_DebugFlags.m_F & DXTDBG_INFO ) _RPTF1( reportType, format, arg1 )
  82. #define DXTDBG_MSG2( reportType, format, arg1, arg2 ) \
  83.     if( DXTDbgScope.m_DebugFlags.m_F & DXTDBG_INFO ) _RPTF2( reportType, format, arg1, arg2 )
  84. #define DXTDBG_MSG3( reportType, format, arg1, arg2, arg3 ) \
  85.     if( DXTDbgScope.m_DebugFlags.m_F & DXTDBG_INFO ) _RPTF3( reportType, format, arg1, arg2, arg3 )
  86. #define DXTDBG_MSG4( reportType, format, arg1, arg2, arg3, arg4 ) \
  87.     if( DXTDbgScope.m_DebugFlags.m_F & DXTDBG_INFO ) _RPTF4( reportType, format, arg1, arg2, arg3, arg4 )
  88. #else
  89. #define DXTDBG_FUNC( name )
  90. #define DXTDBG_MSG0( reportType, format )
  91. #define DXTDBG_MSG1( reportType, format, arg1 )
  92. #define DXTDBG_MSG2( reportType, format, arg1, arg2 )
  93. #define DXTDBG_MSG3( reportType, format, arg1, arg2, arg3 )
  94. #define DXTDBG_MSG4( reportType, format, arg1, arg2, arg3, arg4 )
  95. #endif
  96.  
  97. #pragma option pop /*P_O_Pop*/
  98. #endif  //--- This must be the last line in the file