Main Page | Class List | File List | Class Members

UnwrittenLogfileManager Class Reference

Create or just get a handled logfile. More...

#include "Unwritten/UnwrittenLogfileManager.hpp"

List of all members.

Public Member Functions

UnwrittenLogfileGetLogfile (const std::string &szFilename)
void CloseLogfile (const UnwrittenLogfile *pLogfile)
void CloseLogfile (const std::string &szFilename)
void WriteToAllFiles (UnwrittenLogfile::UnwrittenLoggingType typeOfMsg, const std::string &szText, bool bNewLine=true)
void ShouldPrintMessageType (bool bShouldShow)
bool ShouldPrintMessageType ()
size_t GetManagedLogfiles ()
void SetDefaultLoggingType (UnwrittenLogfile::UnwrittenLoggingType newDefaultType)
UnwrittenLogfile::UnwrittenLoggingType GetDefaultLoggingType ()

Static Public Member Functions

static UnwrittenLogfileManagerGetInstance ()


Detailed Description

Create or just get a handled logfile.

Author:
Tim Hütz <matrix--@users.sourceforge.net>
Date:
01/26/2005
This class is used to handle all logfile which should be used while running this library.

Definition at line 44 of file UnwrittenLogfileManager.hpp.


Member Function Documentation

void UnwrittenLogfileManager::CloseLogfile const std::string &  szFilename  ) 
 

Parameters:
szFilename 

Definition at line 53 of file UnwrittenLogfileManager.cpp.

00054 {
00055         // if there is no corresponding logfile in the managed list, just return
00056         if( this->m_pLogfiles.find( szFilename ) == this->m_pLogfiles.end() )
00057                 return;
00058 
00059         // get an iterator for the given logging object
00060         std::map< std::string, UnwrittenLogfile * >::const_iterator i = this->m_pLogfiles.find( szFilename );
00061 
00062         // cast the second part of this pair, into an CLogFile class
00063         UnwrittenLogfile * pLogfile = static_cast< UnwrittenLogfile * >( i->second );
00064 
00065         // call the disposing function and destroy the object
00066         pLogfile->Dispose();
00067         delete( pLogfile );
00068 
00069         // remove the object from our managing list
00070         this->m_pLogfiles.erase( szFilename );
00071 }

void UnwrittenLogfileManager::CloseLogfile const UnwrittenLogfile pLogfile  ) 
 

Parameters:
pLogfile 
Returns:

Definition at line 73 of file UnwrittenLogfileManager.cpp.

00074 {
00075         // just call the same function for filenames
00076         this->CloseLogfile( pLogfile->m_szLogfileName );
00077 }

UnwrittenLogfile::UnwrittenLoggingType UnwrittenLogfileManager::GetDefaultLoggingType  ) 
 

Returns:

Definition at line 85 of file UnwrittenLogfileManager.cpp.

00086 {
00087         // get the current default logging type
00088         return( this->m_eDefaultLoggingType );
00089 }

UnwrittenLogfileManager * UnwrittenLogfileManager::GetInstance  )  [static]
 

Returns:

Definition at line 36 of file UnwrittenLogfileManager.cpp.

00037 {
00038         if( UnwrittenLogfileManager::m_pInstance == NULL )
00039                 UnwrittenLogfileManager::m_pInstance = new UnwrittenLogfileManager();
00040         return( UnwrittenLogfileManager::m_pInstance );
00041 }

UnwrittenLogfile * UnwrittenLogfileManager::GetLogfile const std::string &  szFilename  ) 
 

Parameters:
szFilename 
Returns:

Definition at line 91 of file UnwrittenLogfileManager.cpp.

00092 {
00093         // if we have already a logfile which is managed, return it
00094         if( this->m_pLogfiles.find( szFilename ) != this->m_pLogfiles.end() )
00095         {
00096                 // get an iterator for the given logging object
00097                 std::map< std::string, UnwrittenLogfile * >::const_iterator i = this->m_pLogfiles.find( szFilename );
00098 
00099                 // cast the second part of this pair, into an CLogFile class
00100                 UnwrittenLogfile * pLogfile = static_cast< UnwrittenLogfile * >( i->second );
00101 
00102                 // return the object
00103                 return( pLogfile );
00104         }
00105 
00106         // else, we must create a new logfile, add it to our manager, and return it
00107         
00108         // create it and set the logging type to the default value
00109         UnwrittenLogfile * pLogfile = new UnwrittenLogfile( szFilename, this->m_bPrintMessageType );
00110         pLogfile->SetLoggingType( this->m_eDefaultLoggingType );
00111 
00112         // add it
00113         this->m_pLogfiles[ szFilename ] = pLogfile;
00114 
00115         // return it
00116         return( pLogfile );
00117 }

size_t UnwrittenLogfileManager::GetManagedLogfiles  ) 
 

Returns:

Definition at line 168 of file UnwrittenLogfileManager.cpp.

00169 {
00170         return( this->m_pLogfiles.size() );
00171 }

void UnwrittenLogfileManager::SetDefaultLoggingType UnwrittenLogfile::UnwrittenLoggingType  newDefaultType  ) 
 

Parameters:
newDefaultType 

Definition at line 79 of file UnwrittenLogfileManager.cpp.

00080 {
00081         // set the new default logging type
00082         this->m_eDefaultLoggingType = newDefaultType;
00083 }

bool UnwrittenLogfileManager::ShouldPrintMessageType  ) 
 

Returns:

Definition at line 43 of file UnwrittenLogfileManager.cpp.

00044 {
00045         return( this->m_bPrintMessageType );
00046 }

void UnwrittenLogfileManager::ShouldPrintMessageType bool  bShouldShow  ) 
 

Parameters:
bShouldShow 

Definition at line 48 of file UnwrittenLogfileManager.cpp.

00049 {
00050         this->m_bPrintMessageType = bShouldPrint;
00051 }

void UnwrittenLogfileManager::WriteToAllFiles UnwrittenLogfile::UnwrittenLoggingType  typeOfMsg,
const std::string &  szText,
bool  bNewLine = true
 

Parameters:
typeOfMsg 
szText 
bNewLine 

Definition at line 119 of file UnwrittenLogfileManager.cpp.

00120 {
00121         // get the first iterator
00122         std::map< std::string, UnwrittenLogfile * >::const_iterator i = this->m_pLogfiles.begin();
00123 
00124         // iterate through all logfiles
00125         while( i != this->m_pLogfiles.end() )
00126         {
00127                 // cast the pointer
00128                 UnwrittenLogfile * pCurrentLogfile = static_cast< UnwrittenLogfile * >( i->second );
00129 
00130                 // if a new line should be set, use the WriteLine function
00131                 if( bNewLine )
00132                         pCurrentLogfile->WriteLine( typeOfMsg, szText.c_str() );
00133 
00134                 // else use the Write function
00135                 else
00136                         pCurrentLogfile->Write( typeOfMsg, szText.c_str() );
00137 
00138                 // next logfile
00139                 ++i;
00140         }
00141 }


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 19:49:00 2005 for Unwritten - Independet Logging Library by  doxygen 1.4.1