home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / NETFrameworkSDK.exe / comsdk.cab / samples1.exe / Profiler / ProfilerBase.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  4.4 KB  |  206 lines

  1. /****************************************************************************************
  2.  * Copyright (c) 1999 Microsoft Corporation.  All Rights Reserved.
  3.  *
  4.  * File:
  5.  *  ProfilerTestBase.cpp
  6.  *
  7.  * Description:
  8.  *    
  9.  *
  10.  *
  11.  ***************************************************************************************/
  12. #include "ProfilerBase.h"
  13.  
  14.  
  15. /***************************************************************************************
  16.  *    Method:
  17.  *
  18.  *
  19.  *    Purpose:
  20.  *
  21.  *
  22.  *    Parameters: 
  23.  *
  24.  *
  25.  *    Return value:
  26.  *
  27.  *
  28.  *    Notes:
  29.  *
  30.  ***************************************************************************************/
  31. void _LaunchDebugger( const char *szMsg, const char* szFile, int iLine )
  32. {    
  33. #ifdef _DEBUG
  34.  
  35.     char message[MAX_LENGTH];
  36.     
  37.          
  38.     sprintf( message, 
  39.              "%s\n\n"     \
  40.              "File: %s\n" \
  41.              "Line: %d\n",
  42.              ((szMsg == NULL) ? "FAILURE" : szMsg), 
  43.              szFile, 
  44.              iLine );
  45.               
  46.     switch ( MessageBoxA( NULL, message, "ASSERT", (MB_ABORTRETRYIGNORE | MB_ICONEXCLAMATION) ) )
  47.     {
  48.         case IDABORT:
  49.             TerminateProcess( GetCurrentProcess(), 1 /* bad exit code */ );
  50.             break;
  51.  
  52.         case IDRETRY:
  53.             _DbgBreak();
  54.  
  55.         case IDIGNORE:
  56.             break;
  57.                             
  58.     } // switch
  59.  
  60. #endif
  61.  
  62. } // _LaunchDebugger
  63.  
  64.  
  65. /***************************************************************************************
  66.  ********************                                               ********************
  67.  ********************          BaseException Implementation         ********************
  68.  ********************                                               ********************
  69.  ***************************************************************************************/
  70.  
  71. /***************************************************************************************
  72.  *    Method:
  73.  *
  74.  *
  75.  *    Purpose:
  76.  *
  77.  *
  78.  *    Parameters: 
  79.  *
  80.  *
  81.  *    Return value:
  82.  *
  83.  *
  84.  *    Notes:
  85.  *
  86.  ***************************************************************************************/
  87. /* public */
  88. BaseException::BaseException( const char *reason ) :
  89.     m_reason( NULL )
  90. {
  91.     SIZE_T length;
  92.  
  93.     
  94.     length = strlen( reason );
  95.     m_reason = new char[(length + 1)];
  96.  
  97.     strcpy( m_reason, reason );
  98.  
  99. } // ctor
  100.  
  101.  
  102. /***************************************************************************************
  103.  *    Method:
  104.  *
  105.  *
  106.  *    Purpose:
  107.  *
  108.  *
  109.  *    Parameters: 
  110.  *
  111.  *
  112.  *    Return value:
  113.  *
  114.  *
  115.  *    Notes:
  116.  *
  117.  ***************************************************************************************/
  118. /* virtual public */
  119. BaseException::~BaseException() 
  120. {
  121.     if ( m_reason != NULL )
  122.         delete[] m_reason;
  123.  
  124. } // dtor
  125.  
  126.  
  127. /***************************************************************************************
  128.  *    Method:
  129.  *
  130.  *
  131.  *    Purpose:
  132.  *
  133.  *
  134.  *    Parameters: 
  135.  *
  136.  *
  137.  *    Return value:
  138.  *
  139.  *
  140.  *    Notes:
  141.  *
  142.  ***************************************************************************************/
  143. /* virtual public */
  144. void BaseException::ReportFailure()
  145. {
  146.     TEXT_OUTLN( m_reason );
  147.     
  148. } // BaseException::ReportFailure
  149.  
  150.  
  151. /***************************************************************************************
  152.  ********************                                               ********************
  153.  ********************            Synchronize Implementation         ********************
  154.  ********************                                               ********************
  155.  ***************************************************************************************/
  156.  
  157. /***************************************************************************************
  158.  *    Method:
  159.  *
  160.  *
  161.  *    Purpose:
  162.  *
  163.  *
  164.  *    Parameters: 
  165.  *
  166.  *
  167.  *    Return value:
  168.  *
  169.  *
  170.  *    Notes:
  171.  *
  172.  ***************************************************************************************/
  173. /* public */
  174. Synchronize::Synchronize( CRITICAL_SECTION &criticalSection ) : 
  175.     m_block( criticalSection )
  176. {
  177.     EnterCriticalSection( &m_block );
  178.     
  179. } // ctor
  180.  
  181.  
  182. /***************************************************************************************
  183.  *    Method:
  184.  *
  185.  *
  186.  *    Purpose:
  187.  *
  188.  *
  189.  *    Parameters: 
  190.  *
  191.  *
  192.  *    Return value:
  193.  *
  194.  *
  195.  *    Notes:
  196.  *
  197.  ***************************************************************************************/
  198. /* public */
  199. Synchronize::~Synchronize()
  200. {
  201.     LeaveCriticalSection( &m_block );
  202.  
  203. } // dtor
  204.  
  205. // End of File
  206.