Leaked source code of windows server 2003
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.

218 lines
5.3 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: _reporter.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. #ifndef ESPUTIL__REPORTER_H
  11. #define ESPUTIL__REPORTER_H
  12. //
  13. // Throws away ALL messages.
  14. //
  15. class LTAPIENTRY CNullReporter : public CReporter
  16. {
  17. public:
  18. CNullReporter() {};
  19. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  20. const CLString &strMessage, CGoto *pGoto = NULL,
  21. CGotoHelp *pGotoHelp = NULL);
  22. };
  23. #pragma warning (disable:4251)
  24. class LTAPIENTRY CBufferReporter : public CReporter
  25. {
  26. public:
  27. CBufferReporter();
  28. void AssertValid(void) const;
  29. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  30. const CLString &strMessage, CGoto *pGoto = NULL,
  31. CGotoHelp *pGotoHelp = NULL);
  32. void Clear(void);
  33. NOTHROW const MessageList & GetNotes(void) const;
  34. NOTHROW const MessageList & GetWarnings(void) const;
  35. NOTHROW const MessageList & GetErrors(void) const;
  36. NOTHROW const MessageList & GetAborts(void) const;
  37. NOTHROW const MessageList & GetMessages(void) const;
  38. void DumpTo(CReport *) const;
  39. ~CBufferReporter();
  40. const CBufferReport & GetBufReport(void) const;
  41. private:
  42. CBufferReport m_bufReport;
  43. };
  44. //
  45. // This reporter just send all its messages directly to a message box.
  46. //
  47. class LTAPIENTRY CMessageBoxReporter : public CReporter
  48. {
  49. public:
  50. CMessageBoxReporter();
  51. void AssertValid(void) const;
  52. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  53. const CLString &strMessage, CGoto *pGoto = NULL,
  54. CGotoHelp *pGotoHelp = NULL);
  55. private:
  56. CMessageBoxReport m_mbReport;
  57. };
  58. //
  59. // This reporter is used to send all messages to a file.
  60. //
  61. class LTAPIENTRY CFileReporter : public CReporter
  62. {
  63. public:
  64. CFileReporter();
  65. BOOL InitFileReporter(const CLString &strFileName);
  66. virtual void Clear(void);
  67. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  68. const CLString &strMessage, CGoto *pGoto = NULL,
  69. CGotoHelp *pGotoHelp = NULL);
  70. ~CFileReporter();
  71. private:
  72. CFileReport m_fReport;
  73. };
  74. //
  75. // This reporter is used for command line utilities. Output goes to stdout
  76. //
  77. class LTAPIENTRY CStdOutReporter : public CReporter
  78. {
  79. public:
  80. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  81. const CLString &strMessage, CGoto *pGoto = NULL,
  82. CGotoHelp *pGotoHelp = NULL);
  83. private:
  84. CStdOutReport m_stReport;
  85. };
  86. //
  87. // This is used to 'redirect' messages to a single reporter. It's used
  88. // when several different reporters are required by the current
  89. // implementation, but the desired effect is that they all send their messages
  90. // to a common location.
  91. //
  92. // This class takes ownership of another Reporter, then uses reference
  93. // counting semantics to determine when to delete that reporter.
  94. //
  95. class LTAPIENTRY CRedirectReporter : public CReporter
  96. {
  97. public:
  98. CRedirectReporter();
  99. virtual void Activate(void);
  100. virtual void Clear(void);
  101. virtual void SetConfidenceLevel(ConfidenceLevel);
  102. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  103. const CLString &strMessage, CGoto *pGoto = NULL,
  104. CGotoHelp *pGotoHelp = NULL);
  105. // Used for initial attachment to a CReporter.
  106. NOTHROW void RedirectTo(CReport *pReport);
  107. // Used to share a single reporter among several CRedirectReporter's.
  108. NOTHROW void RedirectTo(CRedirectReporter *pReporter);
  109. private:
  110. CRedirectReport m_rdReport;
  111. };
  112. //
  113. //
  114. // This class is used to re-direct output through a reporter. It will
  115. // automatically call Clear() and Activate() the first time output is sent
  116. // to the reporter. If the usre calls Activate first on this reporter, then
  117. // no action is taken when something is output.
  118. //
  119. //
  120. class LTAPIENTRY CActivateReporter : public CReporter
  121. {
  122. public:
  123. CActivateReporter(CReport *);
  124. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  125. const CLString &strMessage, CGoto *pGoto = NULL,
  126. CGotoHelp *pGotoHelp = NULL);
  127. void Activate();
  128. void Clear();
  129. private:
  130. CActivateReport m_actReport;
  131. };
  132. //
  133. // Allows you to use a CReport as a CReporter.
  134. class LTAPIENTRY CReportReporter : public CReporter
  135. {
  136. public:
  137. CReportReporter(CReport *);
  138. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  139. const CLString &strMessage, CGoto *pGoto,
  140. CGotoHelp *pGotoHelp);
  141. virtual void Activate();
  142. virtual void Clear();
  143. virtual void SetConfidenceLevel(ConfidenceLevel);
  144. private:
  145. CReport *m_pReport;
  146. };
  147. #pragma warning(default:4251)
  148. //
  149. // The following manage a global 'pool' of reporters that are used by
  150. // different components in the system.
  151. // Each reporter has to be distinct. Once the reporter has been 'added',
  152. // the global pool *owns* the reporter and will delete it. This is done by
  153. // ReleaseAllReporters().
  154. //
  155. NOTHROW LTAPIENTRY void AddReporter(COutputTabs::OutputTabs idx, CReporter *pReporter);
  156. NOTHROW LTAPIENTRY CReporter * GetReporter(COutputTabs::OutputTabs);
  157. NOTHROW LTAPIENTRY void ReleaseAllReporters();
  158. #if !defined(_DEBUG) || defined(IMPLEMENT)
  159. #include "_reporter.inl"
  160. #endif
  161. #endif