00001 /*---------------------------------------------------------------------+ 00002 | Library QgarLib, graphics analysis and recognition | 00003 | Copyright (C) 2002 Qgar Project, LORIA | 00004 | | 00005 | This library is free software; you can redistribute it and/or | 00006 | modify it under the terms of the GNU Lesser General Public | 00007 | License version 2.1, as published by the Free Software Foundation. | 00008 | | 00009 | This library is distributed in the hope that it will be useful, | 00010 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00011 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 00012 | See the GNU Lesser General Public License for more details. | 00013 | | 00014 | The GNU Lesser General Public License is included in the file | 00015 | LICENSE.LGPL, in the root directory of the Qgar packaging. See | 00016 | http://www.gnu.org/licenses/lgpl.html for the terms of the licence. | 00017 | To receive a paper copy, write to the Free Software Foundation, | 00018 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | 00019 | | 00020 | Contact Project Qgar for any information: | 00021 | LORIA - équipe Qgar | 00022 | B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France | 00023 | email: qgar-contact@loria.fr | 00024 | http://www.qgar.org/ | 00025 *---------------------------------------------------------------------*/ 00026 00027 00028 /** 00029 * @file AbstractQgarError.C 00030 * @brief Implementation of class qgar::AbstractQgarError. 00031 * 00032 * See file AbstractQgarError.H for the interface. 00033 * 00034 * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gerald Masini">Gerald Masini</a> 00035 * @date February 18, 2003 16:48 00036 * @since qgar 2.1 00037 */ 00038 00039 00040 // STL 00041 #include <iostream> 00042 #include <string> 00043 // QGAR 00044 #include <qgarlib/AbstractQgarError.H> 00045 00046 00047 00048 namespace qgar 00049 { 00050 00051 00052 // ------------------------------------------------------------------- 00053 // S T A T I C M E M B E R I N I T I A L I Z A T I O N S 00054 // ------------------------------------------------------------------- 00055 00056 00057 bool AbstractQgarError::_msgFlag = true; 00058 00059 00060 // ------------------------------------------------------------------- 00061 // C O N S T R U C T O R S 00062 // ------------------------------------------------------------------- 00063 00064 00065 // CONSTRUCT FROM THE PROFILE OF THE FUNCTION THROWING THE EXCEPTION, 00066 // WITHOUT DISPLAYING ANY ERROR MESSAGE 00067 00068 AbstractQgarError::AbstractQgarError(const char* aFuncProfile) 00069 { 00070 // VOID 00071 } 00072 00073 00074 // CONSTRUCT AND DISPLAY AN ERROR MESSAGE 00075 00076 AbstractQgarError::AbstractQgarError(const char* anErrorKind, 00077 const char* aFileName, 00078 int aLineNb, 00079 const char* aFuncProfile, 00080 const std::string aDiagnostic) 00081 { 00082 if(_msgFlag) 00083 { 00084 displayHeader(anErrorKind); 00085 std::cerr << "Line " 00086 << aLineNb 00087 << " in file: " 00088 << aFileName 00089 << std::endl 00090 << "Function: " 00091 << aFuncProfile 00092 << std::endl 00093 << ">>> " 00094 << aDiagnostic 00095 << std::endl 00096 << std::endl; 00097 } 00098 } 00099 00100 00101 // ------------------------------------------------------------------- 00102 // D E S T R U C T O R 00103 // ------------------------------------------------------------------- 00104 00105 00106 AbstractQgarError::~AbstractQgarError() 00107 { 00108 // VOID 00109 } 00110 00111 00112 // ------------------------------------------------------------------- 00113 // D I S P L A Y 00114 // ------------------------------------------------------------------- 00115 00116 00117 void AbstractQgarError::errorMsgOn() 00118 { 00119 _msgFlag = true; 00120 } 00121 00122 00123 void AbstractQgarError::errorMsgOff() 00124 { 00125 _msgFlag = false; 00126 } 00127 00128 00129 void AbstractQgarError::displayHeader(const char* anErrorKind) const 00130 { 00131 std::cerr << std::endl 00132 << std::endl 00133 << "QGAR: " 00134 << anErrorKind 00135 << std::endl; 00136 } 00137 00138 00139 // ------------------------------------------------------------------- 00140 00141 00142 } // namespace qgar