NLMISC::IDisplayer Class Reference

#include <displayer.h>

Inheritance diagram for NLMISC::IDisplayer:

NLMISC::CFileDisplayer NLMISC::CMemDisplayer NLMISC::CMsgBoxDisplayer NLMISC::CStdDisplayer NLMISC::CWindowDisplayer NLNET::CNetDisplayer NLMISC::CLightMemDisplayer

Detailed Description

Displayer interface. Used to specialize a displayer to display a string. log_howto
Author:
Vianney Lecroart

Nevrax France

Date:
2000

Definition at line 49 of file displayer.h.

Public Member Functions

void display (const CLog::TDisplayInfo &args, const char *message)
 Display the string where it does.

 IDisplayer (const char *displayerName="")
 Constructor.

virtual ~IDisplayer ()
 Destructor.


Static Public Member Functions

const char * dateToComputerString (time_t date)
 Convert date to "784551148" string (time in second from 1975).

const char * dateToHumanString (time_t date)
 Convert date to "2000/01/14 10:05:17" string.

const char * dateToHumanString ()
 Convert the current date to human string.

const char * logTypeToString (CLog::TLogType logType, bool longFormat=false)
 Convert log type to string.


Data Fields

std::string DisplayerName
 This is the idenfiant for a displayer, it is used to fond or remove a displayer.


Protected Member Functions

virtual void doDisplay (const CLog::TDisplayInfo &args, const char *message)=0
 Method to implement in the deriver.


Static Protected Member Functions

const char * HeaderString ()

Private Attributes

CMutex * _Mutex


Constructor & Destructor Documentation

NLMISC::IDisplayer::IDisplayer const char *  displayerName = ""  ) 
 

Constructor.

Definition at line 118 of file displayer.cpp.

References CMutex, and DisplayerName.

00119 {
00120         _Mutex = new CMutex (string(displayerName)+"DISP");
00121         DisplayerName = displayerName;
00122 }

NLMISC::IDisplayer::~IDisplayer  )  [virtual]
 

Destructor.

Definition at line 124 of file displayer.cpp.

00125 {
00126         delete _Mutex;
00127 }


Member Function Documentation

const char * NLMISC::IDisplayer::dateToComputerString time_t  date  )  [static]
 

Convert date to "784551148" string (time in second from 1975).

Definition at line 103 of file displayer.cpp.

References NLMISC::smprintf().

00104 {
00105         static char cstime[25];
00106         smprintf (cstime, 25, "%ld", &date);
00107         return cstime;
00108 }

const char * NLMISC::IDisplayer::dateToHumanString time_t  date  )  [static]
 

Convert date to "2000/01/14 10:05:17" string.

Definition at line 92 of file displayer.cpp.

References uint32.

00093 {
00094         static char cstime[25];
00095         struct tm *tms = localtime(&date);
00096         if (tms)
00097                 strftime (cstime, 25, "%Y/%m/%d %H:%M:%S", tms);
00098         else
00099                 sprintf(cstime, "bad date %d", (uint32)date);
00100         return cstime;
00101 }

const char * NLMISC::IDisplayer::dateToHumanString  )  [static]
 

Convert the current date to human string.

Definition at line 85 of file displayer.cpp.

Referenced by NLNET::CNetDisplayer::doDisplay(), NLMISC::CMemDisplayer::doDisplay(), NLMISC::CMsgBoxDisplayer::doDisplay(), NLMISC::CFileDisplayer::doDisplay(), and HeaderString().

00086 {
00087         time_t date;
00088         time (&date);
00089         return dateToHumanString (date);
00090 }

void NLMISC::IDisplayer::display const CLog::TDisplayInfo args,
const char *  message
 

Display the string where it does.

Definition at line 132 of file displayer.cpp.

References doDisplay().

00133 {
00134         _Mutex->enter();
00135         try
00136         {
00137                 doDisplay( args, message );
00138         }
00139         catch (Exception &)
00140         {
00141                 // silence
00142         }
00143         _Mutex->leave();
00144 }

virtual void NLMISC::IDisplayer::doDisplay const CLog::TDisplayInfo args,
const char *  message
[protected, pure virtual]
 

Method to implement in the deriver.

Implemented in NLMISC::CStdDisplayer, NLMISC::CFileDisplayer, NLMISC::CMsgBoxDisplayer, NLMISC::CMemDisplayer, and NLMISC::CLightMemDisplayer.

Referenced by display().

const char * NLMISC::IDisplayer::HeaderString  )  [static, protected]
 

Definition at line 110 of file displayer.cpp.

References dateToHumanString(), and NLMISC::smprintf().

Referenced by NLMISC::CMemDisplayer::doDisplay(), and NLMISC::CFileDisplayer::doDisplay().

00111 {
00112         static char header[1024];
00113         smprintf(header, 1024, "\nLog Starting [%s]\n", dateToHumanString());
00114         return header;
00115 }

const char * NLMISC::IDisplayer::logTypeToString CLog::TLogType  logType,
bool  longFormat = false
[static]
 

Convert log type to string.

Definition at line 77 of file displayer.cpp.

References NLMISC::LogTypeToString.

Referenced by NLMISC::CWindowDisplayer::doDisplay(), NLNET::CNetDisplayer::doDisplay(), NLMISC::CMemDisplayer::doDisplay(), NLMISC::CMsgBoxDisplayer::doDisplay(), NLMISC::CFileDisplayer::doDisplay(), and NLMISC::CStdDisplayer::doDisplay().

00078 {
00079         if (logType < CLog::LOG_NO || logType > CLog::LOG_UNKNOWN)
00080                 return "<NotDefined>";
00081 
00082         return LogTypeToString[longFormat?1:0][logType];
00083 }


Field Documentation

CMutex* NLMISC::IDisplayer::_Mutex [private]
 

Definition at line 90 of file displayer.h.

std::string NLMISC::IDisplayer::DisplayerName
 

This is the idenfiant for a displayer, it is used to fond or remove a displayer.

Definition at line 63 of file displayer.h.

Referenced by IDisplayer().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 13:45:31 2004 for NeL by doxygen 1.3.6