00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #pragma once
00018
00019
00020 #include "TestToolBox/IProtocol.h"
00021 #include <fstream>
00022
00023 #ifdef USE_TEST_INSTANCE_DLL
00024 # include "TestToolBox/TestInstanceDll.h"
00025 #endif
00026
00027 namespace TestToolBox
00028 {
00029 struct IProtocol;
00030 class TestStream;
00031
00032
00033
00034
00035
00036
00037
00038 class Protocol :
00039 public AutoCriticalSection,
00040 public IProtocol
00041 {
00042 private:
00043
00044
00045
00046 explicit Protocol(
00047 unsigned int in_allowedStreams,
00048 OutputLevel::Enum in_outputLevel);
00049
00050
00051 public:
00052
00053 std::string const S_SEPARATOR_LINE;
00054
00055
00056 ~Protocol();
00057
00058
00059 #ifdef USE_TEST_INSTANCE_DLL
00060 static Protocol* CreateNewInstanceForUsageInDll(void){return new Protocol;};
00061 static Protocol* Get (void)
00062 {return TTB_GetInstance_Protocol();}
00063 static void Cleanup (void)
00064 {TTB_CleanupInstance_Protocol();}
00065 #else
00066 static Protocol* Get (
00067 unsigned int in_allowedStreams = OutputMode::M_STDOUT | OutputMode::M_OUTFILE | OutputMode::M_RPTFILE,
00068 OutputLevel::Enum in_outputLevel = OutputLevel::eREGULAR)
00069 {if (!s_pProtocol) s_pProtocol = new Protocol(in_allowedStreams, in_outputLevel);
00070 return s_pProtocol;}
00071 static Protocol* s_pProtocol;
00072 static void Cleanup (void)
00073 {delete s_pProtocol; s_pProtocol = 0;}
00074 #endif
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 virtual void Write(
00085 std::string const & in_text);
00086
00087
00088
00089 virtual void Writeln(
00090 std::string const & in_text);
00091
00092
00093
00094 virtual void Write(
00095 OutputLevel::Enum in_outputLevel,
00096 unsigned char in_outputMode,
00097 std::string const & in_text);
00098
00099
00100
00101 virtual void Writeln(
00102 OutputLevel::Enum in_outputLevel,
00103 unsigned char in_outputMode,
00104 std::string const & in_text);
00105
00106
00107 virtual void WriteFooter(unsigned char m = TestToolBox::OutputMode::M_ALL);
00108
00109
00110 void SetMode (
00111 unsigned char in_newMode);
00112
00113
00114 void ResetMode (void);
00115
00116
00117 void SetOutputLevelForStdOut (
00118 OutputLevel::Enum in_outputLevel);
00119
00120
00121
00122
00123
00124 void SetStreamActivation (
00125 unsigned char in_streamsToActivate);
00126
00127
00128
00129
00130 void SwitchLogfiles (
00131 std::string const & in_postFixNewFileName,
00132 std::string const & in_msgClose,
00133 std::string const & in_msgOpen);
00134
00135 private:
00136
00137
00138 std::fstream m_outF;
00139
00140
00141 std::fstream m_rptF;
00142
00143
00144 TestStream* m_pTestStream;
00145
00146
00147 bool m_footerAlreadyWritten;
00148
00149 OutputLevel::Enum m_activeOutputLevelForStdOut;
00150
00151 private:
00152
00153 void WriteHeader(void);
00154
00155
00156 TestStream& TS (void);
00157
00158
00159
00160
00161 unsigned char AdjustOutputMode(
00162 OutputLevel::Enum in_outputLevel,
00163 unsigned char in_outputMode);
00164
00165 };
00166
00167 static Protocol* TheProtocol (void)
00168 {return Protocol::Get();}
00169
00170
00171 #ifndef USE_TEST_INSTANCE_DLL
00172 __declspec(selectany) Protocol* Protocol::s_pProtocol = 0;
00173 #endif
00174
00175
00176 };
00177
00178