displayer.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
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     // Return the header string with date (for the first line of the log)
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 /* End of displayer.h */

Generated on Thu Jan 7 08:26:22 2010 for NeL by  doxygen 1.6.1