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.

114 lines
2.9 KiB

  1. //---------------------------------------------------------------------------
  2. // McsDebugUtil.h
  3. //
  4. // The MCS Debug utility classes are declared in this file.
  5. // The utility classes are:
  6. //
  7. // McsDebugException:
  8. // This class is the exception class that is thrown by
  9. // MCSEXCEPTION(SZ) macros and MCSASSERT(SZ) macros in
  10. // test mode.
  11. //
  12. // McsDebugCritSec:
  13. // Critical section class to support multi-threaded calls
  14. // to the logger classes.
  15. //
  16. // McsDebugLog:
  17. // Writes to ostream object.
  18. //
  19. //
  20. // (c) Copyright 1995-1998, Mission Critical Software, Inc., All Rights Reserved
  21. //
  22. // Proprietary and confidential to Mission Critical Software, Inc.
  23. //---------------------------------------------------------------------------
  24. #ifndef MCSINC_McsDebugUtil_h
  25. #define MCSINC_McsDebugUtil_h
  26. #ifdef __cplusplus /* C++ */
  27. #ifndef WIN16_VERSION /* Not WIN16_VERSION */
  28. #include <iostream.h>
  29. #include <fstream.h>
  30. namespace McsDebugUtil {
  31. // ---------------
  32. // McsDebugCritSec
  33. // ---------------
  34. class McsDebugCritSec {
  35. public:
  36. McsDebugCritSec (void);
  37. ~McsDebugCritSec (void);
  38. void enter (void);
  39. void leave (void);
  40. private:
  41. McsDebugCritSec (const McsDebugCritSec&);
  42. McsDebugCritSec& operator= (const McsDebugCritSec&);
  43. private:
  44. CRITICAL_SECTION m_section;
  45. };
  46. // -----------
  47. // McsDebugLog
  48. // -----------
  49. class McsDebugLog {
  50. public:
  51. McsDebugLog (void);
  52. ~McsDebugLog (void);
  53. bool isLogSet (void) const;
  54. void changeLog (ostream *outStreamIn);
  55. void write (const char *messageIn);
  56. private:
  57. // Do not allow copy ctor & operator=.
  58. McsDebugLog (const McsDebugLog&);
  59. McsDebugLog& operator= (const McsDebugLog&);
  60. private:
  61. ostream *m_outStream;
  62. };
  63. // --- INLINES ---
  64. // ---------------------
  65. // McsDebugCritSec
  66. // ---------------------
  67. inline McsDebugCritSec::McsDebugCritSec (void){
  68. ::InitializeCriticalSection (&m_section);
  69. }
  70. inline McsDebugCritSec::~McsDebugCritSec (void) {
  71. ::DeleteCriticalSection (&m_section);
  72. }
  73. inline void McsDebugCritSec::enter (void) {
  74. ::EnterCriticalSection (&m_section);
  75. }
  76. inline void McsDebugCritSec::leave (void) {
  77. ::LeaveCriticalSection (&m_section);
  78. }
  79. // -----------
  80. // McsDebugLog
  81. // -----------
  82. inline McsDebugLog::McsDebugLog (void)
  83. : m_outStream (NULL)
  84. { /* EMPTY */ }
  85. // outStream object is set and owned by the
  86. // user of this class do not delete.
  87. inline McsDebugLog::~McsDebugLog (void) { /* EMPTY */ }
  88. inline bool McsDebugLog::isLogSet (void) const
  89. { return m_outStream != NULL; }
  90. inline void McsDebugLog::changeLog
  91. (ostream *outStreamIn) {
  92. m_outStream = outStreamIn;
  93. }
  94. }
  95. #endif /* Not WIN16_VERSION */
  96. #endif /* C++ */
  97. #endif /* MCSINC_Mcs_Debug_Util_h */