00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 #pragma once
00021 
00022 #include "TestToolBox\IEventReceiver.h"
00023 #include <iostream>
00024 
00025 namespace TestToolBox
00026 {
00027 
00028 
00029 
00030 
00031 class EventReceiverStdOut : public IEventReceiver
00032 {
00033 public:
00034 
00035 
00036     EventReceiverStdOut()
00037         : m_filterMask (0xffff)
00038         , m_numErrors  (0)
00039     {}
00040 
00041 
00042 
00043     void SetOutputFilter (long in_filterMask)
00044     {m_filterMask = in_filterMask;}
00045 
00046 
00047     void ResetErrors (void)
00048     {m_numErrors = 0;}
00049 
00050 
00051     long GetNumErrors (void)
00052     {return m_numErrors;}
00053 
00054 private:
00055 
00056 
00057     long m_filterMask;
00058     long m_numErrors;
00059 
00060 private:
00061 
00062 
00063         virtual void EventMsg(
00064                 EventContext in_context,
00065                 const char*  in_eventDescription)
00066         {
00067         if (!(in_context & m_filterMask))
00068             return;
00069 
00070         
00071         
00072         
00073         std::ostringstream fullInfoStr;
00074 
00075         if (in_context & CTX_PROT)
00076         {
00077             fullInfoStr << in_eventDescription;
00078         }
00079         else
00080         {
00081             if (in_context & CTX_INFO)
00082             {
00083                 fullInfoStr << "INFO: " << in_eventDescription;
00084             }
00085             else if (in_context & CTX_TEST_EVENT)
00086             {
00087                 fullInfoStr << "EVENT: " << in_eventDescription;
00088             }
00089             else
00090             {
00091                 
00092                 ++m_numErrors;
00093                 if (in_context & CTX_UNEXPECTED_EVENTS)
00094                 {
00095                     fullInfoStr << in_eventDescription << " (UNEXPECTED_EVENTS)";
00096                 }
00097                 else if (in_context & CTX_FATAL_ERROR)
00098                 {
00099                     fullInfoStr << in_eventDescription << " (FATAL_ERROR)";
00100                 }
00101                 else
00102                 {
00103                     fullInfoStr << in_eventDescription;
00104                 }
00105             }
00106         }
00107         std::cout << fullInfoStr.str().c_str() << std::endl;
00108     }
00109 
00110 
00111 }; 
00112 
00113 }; 
00114 
00115 
00116