gpucalc::LogManager Class Reference

This class provides logging. More...

#include <log_manager.h>

Inheritance diagram for gpucalc::LogManager:

Inheritance graph

List of all members.

Public Member Functions

LogcreateLog (const std::string &name, bool defaultLog=false, unsigned int LogClassNameAlignment=15, unsigned int LogObjectNameAlignment=20, bool DebugOutput=true, bool SuppressFileOutput=false, bool SuppressObjectInfo=false)
 Creates a new log with the given name.
void destroyLog (Log *log)
 Closes and removes a log.
void destroyLog (const std::string &name)
 Closes and removes a named log.
const std::string & getClassName () const
 Returns name of class of our object.
LoggetDefaultLog ()
 Returns a pointer to the default log.
LoggetLog (const std::string &name)
 Retrieves a log managed by this class.
LoggingLevel getLogDetail ()
const std::string & getObjectName () const
 Returns name of our object.
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
bool isLocked () const
 returns state of object.
 LogManager ()
void logMessage (const std::string &LogId, const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
void logMessage (const std::string &LogId, const Object *object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
void logMessage (const Object *object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
void logMessage (const Object &object, const std::string &Message, LogMessageLevel lml=LML_Normal, bool maskDebug=false)
 Log a message to the default log.
template<>
TimermSingleton
template<>
TimermSingleton
template<>
ProfilermSingleton
template<>
LogManagermSingleton
template<>
debugger::DebuggermSingleton
template<>
debugger::CommandParsermSingleton
template<>
ApplicationmSingleton
LogsetDefaultLog (Log *newLog)
 Sets the passed in log as the default log.
void setLogDetail (LoggingLevel ll)
 Sets the level of detail of the default log.
 ~LogManager ()

Static Public Member Functions

static LogManagergetSingleton ()
static LogManagergetSingletonPtr ()

Protected Types

typedef std::map< std::string,
Log *, std::less< std::string > > 
LogMap

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Protected Attributes

LogmDefaultLog
 The default log to which output is done.
LogMap mLogMap
 A list of all the logs the manager can access.

Static Protected Attributes

static T * mSingleton


Detailed Description

This class provides logging.

This class creates one log, and provide logging into it.

Definition at line 48 of file log_manager.h.


Member Typedef Documentation

typedef std::map<std::string, Log *, std::less<std::string> > gpucalc::LogManager::LogMap [protected]

Definition at line 160 of file log_manager.h.


Constructor & Destructor Documentation

gpucalc::LogManager::LogManager (  ) 

Definition at line 54 of file log_manager.cpp.

00054                        : Singleton<LogManager>(_LogManagerObjectName), mLogMap(), mDefaultLog(0)
00055  {
00056  }

gpucalc::LogManager::~LogManager (  ) 

Definition at line 59 of file log_manager.cpp.

00060  {
00061   clearContainer(mLogMap);
00062  }


Member Function Documentation

void gpucalc::Object::addSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue,
size_t  Size 
) [inline, protected, inherited]

Definition at line 254 of file object.h.

00255    {
00256     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00257     if (i != mSpecificParameters.end())
00258     {
00259      mSpecificParameters.erase(i);
00260     }
00261     mSpecificParameters[ParameterName] = Any(ParameterValue, Size);
00262    }

Log * gpucalc::LogManager::createLog ( const std::string &  name,
bool  defaultLog = false,
unsigned int  LogClassNameAlignment = 15,
unsigned int  LogObjectNameAlignment = 20,
bool  DebugOutput = true,
bool  SuppressFileOutput = false,
bool  SuppressObjectInfo = false 
)

Creates a new log with the given name.

Parameters:
name - The name to give the log e.g. 'test.log'.
defaultLog - If true, this is the default log output will be sent to if the generic logging methods on this class are used. The first log created is always the default log unless this parameter is set.
LogClassNameAlignment - length of field of ClassName in log.
LogObjectNameAlignment - length of field of ObjectName in log.
DebugOutput - If true, output to this log will also be routed to the debugger's output window.
SuppressFileOutput - If true, this is a logical rather than a physical log and no file output will be written. If you do this you should register a LogListener so log output is not lost.
SuppressObjectInfo - if true does not log class name and object name.

Definition at line 65 of file log_manager.cpp.

00067  {
00068   Log * newLog = new Log(name, LogClassNameAlignment, LogObjectNameAlignment, DebugOutput, SuppressFileOutput, SuppressObjectInfo);
00069   if( !mDefaultLog || defaultLog )
00070   {
00071    mDefaultLog = newLog;
00072   }
00073   addToContainer(newLog, name, mLogMap);
00074   return newLog;
00075  }

void gpucalc::LogManager::destroyLog ( Log log  ) 

Closes and removes a log.

Definition at line 128 of file log_manager.cpp.

00129  {
00130   destroyLog(log->getObjectName());
00131  }

void gpucalc::LogManager::destroyLog ( const std::string &  name  ) 

Closes and removes a named log.

Set another default log if this one removed

Definition at line 107 of file log_manager.cpp.

00108  {
00109   LogMap::iterator i = mLogMap.find(name);
00110   if (i != mLogMap.end())
00111   {
00112    if (mDefaultLog == i->second)
00113    {
00114     mDefaultLog = NULL;
00115    }
00116    delete i->second;
00117    mLogMap.erase(i);
00118   }
00119 
00121   if (!mDefaultLog && !mLogMap.empty())
00122   {
00123    mDefaultLog = mLogMap.begin()->second;
00124   }
00125  }

const std::string& gpucalc::Object::getClassName (  )  const [inline, inherited]

Returns name of class of our object.

Definition at line 92 of file object.h.

00093    {
00094     return mClassName;
00095    }

Log * gpucalc::LogManager::getDefaultLog (  ) 

Returns a pointer to the default log.

Definition at line 78 of file log_manager.cpp.

00079  {
00080   return mDefaultLog;
00081  }

Log * gpucalc::LogManager::getLog ( const std::string &  name  ) 

Retrieves a log managed by this class.

Definition at line 92 of file log_manager.cpp.

00093  {
00094   LogMap::iterator i = mLogMap.find(name);
00095   if (i != mLogMap.end())
00096   {
00097    return i->second;
00098   }
00099   else
00100   {
00101    Except<ERR_INVALIDPARAMS>(this, "Log not found. ", "LogManager::getLog", __FILE__, __LINE__);
00102    return NULL;
00103   }
00104  }

LoggingLevel gpucalc::LogManager::getLogDetail (  ) 

Definition at line 194 of file log_manager.cpp.

00195  {
00196   if (mDefaultLog)
00197   {
00198    return mDefaultLog->getLogDetail();
00199   }
00200   return LL_Low;
00201  }

const std::string& gpucalc::Object::getObjectName (  )  const [inline, inherited]

Returns name of our object.

Definition at line 101 of file object.h.

00102    {
00103     return mObjectName;
00104    }

LogManager & gpucalc::LogManager::getSingleton (  )  [static]

Override standard Singleton retrieval.

Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from gpucalc::Singleton< T >.

Definition at line 47 of file log_manager.cpp.

00048  {
00049   assert(mSingleton);
00050   return(* mSingleton);
00051  }

LogManager * gpucalc::LogManager::getSingletonPtr (  )  [static]

Override standard Singleton retrieval.

Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from gpucalc::Singleton< T >.

Definition at line 41 of file log_manager.cpp.

00042  {
00043   return mSingleton;
00044  }

void gpucalc::Object::getSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue 
) [inline, inherited]

Method for obtaining some specific parameters, such as texture specific params, and so on.

Parameters:
ParameterName - name of parameter, usually it similar to specific method of some object (for example, GLTextureID)
ParameterValue - contain value of named parameter, it must be allocated and have sufficient size.
Todo:
Think for better realization.

Definition at line 128 of file object.h.

00129    {
00130     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00131     if (i != mSpecificParameters.end())
00132     {
00133      i->second.copyValue(ParameterValue);
00134     }
00135     else
00136     {
00137      Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__);
00138     }
00139    }

bool gpucalc::Object::isLocked (  )  const [inline, inherited]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

void gpucalc::LogManager::logMessage ( const std::string &  LogId,
const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Definition at line 169 of file log_manager.cpp.

00171  {
00172   LogMap::iterator i = mLogMap.find(LogId);
00173   if (i != mLogMap.end())
00174   {
00175    i->second->logMessage(object, Message, lml, maskDebug);
00176   }
00177   else
00178   {
00179    Except<ERR_ITEM_NOT_FOUND>(this, "Log with Id \"" + LogId + "\" cannot be found.", "LogManager::logMessage()", __FILE__, __LINE__);
00180   }
00181  }

void gpucalc::LogManager::logMessage ( const std::string &  LogId,
const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Definition at line 155 of file log_manager.cpp.

00157  {
00158   LogMap::iterator i = mLogMap.find(LogId);
00159   if (i != mLogMap.end())
00160   {
00161    i->second->logMessage(object, Message, lml, maskDebug);
00162   }
00163   else
00164   {
00165    Except<ERR_ITEM_NOT_FOUND>(this, "Log with Id \"" + LogId + "\" cannot be found.", "LogManager::logMessage()", __FILE__, __LINE__);
00166   }
00167  }

void gpucalc::LogManager::logMessage ( const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Definition at line 145 of file log_manager.cpp.

00147  {
00148   if (mDefaultLog)
00149   {
00150    mDefaultLog->logMessage(object, Message, lml, maskDebug);
00151   }
00152  }

void gpucalc::LogManager::logMessage ( const Object object,
const std::string &  Message,
LogMessageLevel  lml = LML_Normal,
bool  maskDebug = false 
)

Log a message to the default log.

Definition at line 134 of file log_manager.cpp.

00136  {
00137   if (mDefaultLog)
00138   {
00139    mDefaultLog->logMessage(object, Message, lml, maskDebug);
00140   }
00141  }

template<>
Timer * gpucalc::Singleton< Timer >::mSingleton (  )  [inline, inherited]

Definition at line 42 of file win32_timer_impl.cpp.

template<>
Timer * gpucalc::Singleton< Timer >::mSingleton (  )  [inline, inherited]

Definition at line 45 of file unix_timer_impl.cpp.

template<>
Profiler * gpucalc::Singleton< Profiler >::mSingleton (  )  [inline, inherited]

Definition at line 39 of file profiler.cpp.

template<>
LogManager * gpucalc::Singleton< LogManager >::mSingleton (  )  [inline, inherited]

Definition at line 38 of file log_manager.cpp.

template<>
debugger::Debugger * gpucalc::Singleton< debugger::Debugger >::mSingleton (  )  [inline, inherited]

Definition at line 42 of file debugger.cpp.

template<>
debugger::CommandParser * gpucalc::Singleton< debugger::CommandParser >::mSingleton (  )  [inline, inherited]

Definition at line 41 of file command_parser.cpp.

template<>
Application * gpucalc::Singleton< Application >::mSingleton (  )  [inline, inherited]

Definition at line 44 of file application.cpp.

Log * gpucalc::LogManager::setDefaultLog ( Log newLog  ) 

Sets the passed in log as the default log.

Returns:
The previous default log.

Definition at line 84 of file log_manager.cpp.

00085  {
00086   Log * oldLog = mDefaultLog;
00087   mDefaultLog = newLog;
00088   return oldLog;
00089  }

void gpucalc::LogManager::setLogDetail ( LoggingLevel  ll  ) 

Sets the level of detail of the default log.

Definition at line 185 of file log_manager.cpp.

00186  {
00187   if (mDefaultLog)
00188   {
00189    mDefaultLog->setLogDetail(ll);
00190   }
00191  }

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


Member Data Documentation

The default log to which output is done.

Definition at line 172 of file log_manager.h.

A list of all the logs the manager can access.

Definition at line 166 of file log_manager.h.

template<typename T>
T* gpucalc::Singleton< T >::mSingleton [static, protected, inherited]

Definition at line 108 of file singleton.h.


The documentation for this class was generated from the following files:

Generated on Thu Mar 5 22:36:45 2009 for gpucalc by  doxygen 1.5.6