Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

LOW_exception.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_exception.cpp  -  description
00003                              -------------------
00004     begin                : Sat Jul 6 2002
00005     copyright            : (C) 2002 by Harald Roelle
00006     email                : roelle@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #include <typeinfo>
00020  
00021 
00022 #include "LOW_exception.h"
00023 #include "LOW_objectSynchronizer.h"
00024 #include "LOW_helper_msglog.h"
00025 
00026 
00027 //=====================================================================================
00028 //
00029 // static attributes
00030 //
00031 
00032 __LOW_SYNCHRONIZE_INIT_PROTECTED_LOCK__(LOW_exception)
00033 
00034 bool LOW_exception::logOnCreation = false;
00035 
00036 
00037 //=====================================================================================
00038 //
00039 // constructors
00040 //
00041 
00042 LOW_exception::LOW_exception() :
00043   errNum( 0),
00044   message( "")
00045 {
00046 }
00047 
00048 
00049 LOW_exception::LOW_exception( const std::string inMsg, const std::string inFile, const int inLine) : 
00050   errNum( 0),
00051   message( inMsg),
00052   file( inFile),
00053   line( inLine)
00054 {
00055   if ( logOnCreation )
00056     logException( "[auto-logged on creation] ");
00057 }
00058 
00059 
00060 LOW_exception::LOW_exception( const int inErrNum, const std::string inMsg, const std::string inFile, const int inLine) : 
00061   errNum( inErrNum),
00062   message( inMsg),
00063   file( inFile),
00064   line( inLine)
00065 {
00066   if ( logOnCreation )
00067     logException( "[auto-logged on creation] ");
00068 }
00069 
00070 
00071 LOW_exception::~LOW_exception()
00072 {
00073 }
00074   
00075   
00076 //=====================================================================================
00077 //
00078 // public static methods
00079 //
00080 
00081 void LOW_exception::setLogOnCreation( const bool inLogOnCreation)
00082 {
00083   __LOW_SYNCHRONIZE_STATIC_WRITE__
00084 
00085   logOnCreation = inLogOnCreation;
00086 }
00087 
00088 
00089 const bool LOW_exception::getLogOnCreation()
00090 {
00091   __LOW_SYNCHRONIZE_STATIC_READ__
00092 
00093   return logOnCreation;
00094 }
00095     
00096 
00097 //=====================================================================================
00098 //
00099 // public methods
00100 //
00101 
00102 void LOW_exception::logException( const std::string inPrefix)
00103 {
00104   if ( errNum == 0 )
00105     LOW_helper_msglog::printError( "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00106   else
00107     LOW_helper_msglog::printPerror( errNum, "%s%s {file: %s, line: %d}", inPrefix.c_str(), message.c_str(), file.c_str(), line);
00108 }

Generated on Tue Feb 3 11:30:25 2004 for OneWireLibrary++ by doxygen 1.3.2