displayer.h
Go to the documentation of this file.00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_DISPLAYER_H
00025 #define NL_DISPLAYER_H
00026
00027 #include "types_nl.h"
00028
00029 #include <string>
00030
00031 #include "log.h"
00032
00033 namespace NLMISC
00034 {
00035
00036
00037 class CMutex;
00038
00039
00047 class IDisplayer
00048 {
00049 public:
00050
00052 IDisplayer(const char *displayerName = "");
00053
00055 virtual ~IDisplayer();
00056
00058 void display( const CLog::TDisplayInfo& args, const char *message );
00059
00061 std::string DisplayerName;
00062
00063 protected:
00064
00066 virtual void doDisplay( const CLog::TDisplayInfo& args, const char *message) = 0;
00067
00068
00069
00070 static const char *HeaderString ();
00071
00072 public:
00073
00075 static const char *logTypeToString (CLog::TLogType logType, bool longFormat = false);
00076
00078 static const char *dateToHumanString ();
00079
00081 static const char *dateToHumanString (time_t date);
00082
00084 static const char *dateToComputerString (time_t date);
00085
00086 private:
00087
00088 CMutex *_Mutex;
00089 };
00090
00091
00092
00100 class CStdDisplayer : virtual public IDisplayer
00101 {
00102 public:
00103 CStdDisplayer (const char *displayerName = "") : IDisplayer (displayerName) {}
00104
00105 protected:
00106
00108 virtual void doDisplay ( const CLog::TDisplayInfo& args, const char *message );
00109
00110 };
00111
00112
00120 class CFileDisplayer : virtual public IDisplayer
00121 {
00122 public:
00123
00125 CFileDisplayer (const std::string &filename, bool eraseLastLog = false, const char *displayerName = "", bool raw = false);
00126
00127 CFileDisplayer ();
00128
00129 ~CFileDisplayer ();
00130
00132 void setParam (const std::string &filename, bool eraseLastLog = false);
00133
00134 protected:
00136 virtual void doDisplay ( const CLog::TDisplayInfo& args, const char *message );
00137
00138 private:
00139 std::string _FileName;
00140
00141 FILE *_FilePointer;
00142
00143 bool _NeedHeader;
00144
00145 uint _LastLogSizeChecked;
00146
00147 bool _Raw;
00148 };
00149
00157 class CMsgBoxDisplayer : virtual public IDisplayer
00158 {
00159 public:
00160 CMsgBoxDisplayer (const char *displayerName = "") : IDisplayer (displayerName), IgnoreNextTime(false) {}
00161
00162 bool IgnoreNextTime;
00163
00164 protected:
00166 virtual void doDisplay ( const CLog::TDisplayInfo& args, const char *message );
00167 };
00168
00169
00170 };
00171
00172 #endif // NL_DISPLAYER_H
00173
00174