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.

233 lines
5.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: _report.h
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. #ifndef LOCUTIL_REPORT_H
  11. #define LOCUTIL_REPORT_H
  12. #pragma once
  13. //
  14. // Throws away ALL messages.
  15. //
  16. class LTAPIENTRY CNullReport : public CReport
  17. {
  18. public:
  19. CNullReport() {};
  20. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  21. const CLString &strMessage, CGoto *pGoto = NULL,
  22. CGotoHelp *pGotoHelp = NULL);
  23. };
  24. //
  25. // This stuff is used for an implementation of CReport that will
  26. // 'buffer' messages. Use CBufferReporter if you don't want to
  27. // process messages until after the process producing them is done.
  28. // You can get the messages either by severity, or as a list of all
  29. // messages as they were issued.
  30. //
  31. struct ReportMessage
  32. {
  33. MessageSeverity sev;
  34. CLString strContext;
  35. CLString strMessage;
  36. SmartRef<CGoto> spGoto;
  37. SmartRef<CGotoHelp> spGotoHelp;
  38. };
  39. typedef CTypedPtrList<CPtrList, ReportMessage *> MessageList;
  40. #pragma warning (disable:4251)
  41. class LTAPIENTRY CBufferReport : public CReport
  42. {
  43. public:
  44. CBufferReport();
  45. void AssertValid(void) const;
  46. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  47. const CLString &strMessage, CGoto *pGoto = NULL,
  48. CGotoHelp *pGotoHelp = NULL);
  49. void Clear(void);
  50. NOTHROW const MessageList & GetNotes(void) const;
  51. NOTHROW const MessageList & GetWarnings(void) const;
  52. NOTHROW const MessageList & GetErrors(void) const;
  53. NOTHROW const MessageList & GetAborts(void) const;
  54. NOTHROW const MessageList & GetMessages(void) const;
  55. void DumpTo(CReport *) const;
  56. ~CBufferReport();
  57. private:
  58. MessageList m_mlNotes;
  59. MessageList m_mlWarnings;
  60. MessageList m_mlErrors;
  61. MessageList m_mlAborts;
  62. mutable MessageList m_mlMessages;
  63. };
  64. //
  65. // This reporter just send all its messages directly to a message box.
  66. //
  67. class LTAPIENTRY CMessageBoxReport : public CReport
  68. {
  69. public:
  70. CMessageBoxReport();
  71. void AssertValid(void) const;
  72. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  73. const CLString &strMessage, CGoto *pGoto = NULL,
  74. CGotoHelp *pGotoHelp = NULL);
  75. ~CMessageBoxReport();
  76. private:
  77. };
  78. //
  79. // This reporter is used to send all messages to a file.
  80. //
  81. class LTAPIENTRY CFileReport : public CReport
  82. {
  83. public:
  84. CFileReport();
  85. BOOL InitFileReport(const CLString &strFileName);
  86. virtual void Clear(void);
  87. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  88. const CLString &strMessage, CGoto *pGoto = NULL,
  89. CGotoHelp *pGotoHelp = NULL);
  90. ~CFileReport();
  91. private:
  92. CFile m_OutputFile;
  93. };
  94. //
  95. // This reporter is used for command line utilities. Output goes to stdout
  96. //
  97. class LTAPIENTRY CStdOutReport : public CReport
  98. {
  99. public:
  100. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  101. const CLString &strMessage, CGoto *pGoto = NULL,
  102. CGotoHelp *pGotoHelp = NULL);
  103. virtual void SetConfidenceLevel(ConfidenceLevel);
  104. private:
  105. BOOL m_fEnabled;
  106. };
  107. //
  108. // This is used to 'redirect' messages to a single reporter. It's used
  109. // when several different reporters are required by the current
  110. // implementation, but the desired effect is that they all send their messages
  111. // to a common location.
  112. //
  113. // This class takes ownership of another Reporter, then uses reference
  114. // counting semantics to determine when to delete that reporter.
  115. //
  116. class LTAPIENTRY CRedirectReport : public CReport
  117. {
  118. public:
  119. CRedirectReport();
  120. virtual void Activate(void);
  121. virtual void Clear(void);
  122. virtual void SetConfidenceLevel(ConfidenceLevel);
  123. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  124. const CLString &strMessage, CGoto *pGoto = NULL,
  125. CGotoHelp *pGotoHelp = NULL);
  126. // Used for initial attachment to a CReporter.
  127. NOTHROW void RedirectTo(CReport *pReport);
  128. // Used to share a single reporter among several CRedirectReporter's.
  129. NOTHROW void RedirectTo(CRedirectReport *pReport);
  130. ~CRedirectReport();
  131. private:
  132. struct RedirectInfo
  133. {
  134. SmartPtr<CReport> pReport;
  135. UINT uiRefCount;
  136. };
  137. RedirectInfo *m_pRedirectInfo;
  138. void NOTHROW Detach(void);
  139. };
  140. //
  141. //
  142. // This class is used to re-direct output through a reporter. It will
  143. // automatically call Clear() and Activate() the first time output is sent
  144. // to the reporter. If the usre calls Activate first on this reporter, then
  145. // no action is taken when something is output.
  146. //
  147. //
  148. class LTAPIENTRY CActivateReport : public CReport
  149. {
  150. public:
  151. CActivateReport(CReport *);
  152. virtual void IssueMessage(MessageSeverity, const CLString &strContext,
  153. const CLString &strMessage, CGoto *pGoto = NULL,
  154. CGotoHelp *pGotoHelp = NULL);
  155. void Activate();
  156. void Clear();
  157. private:
  158. BOOL m_fActivated;
  159. CReport *m_pReport;
  160. };
  161. //
  162. // The following manage a global 'pool' of reporters that are used by
  163. // different components in the system.
  164. // Each reporter has to be distinct. Once the reporter has been 'added',
  165. // the global pool *owns* the reporter and will delete it. This is done by
  166. // ReleaseAllReporters().
  167. //
  168. NOTHROW LTAPIENTRY void AddReport(COutputTabs::OutputTabs idx, CReport *pReport);
  169. NOTHROW LTAPIENTRY CReport * GetReport(COutputTabs::OutputTabs);
  170. NOTHROW LTAPIENTRY void ReleaseAllReports();
  171. #include "_report.inl"
  172. #endif