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 #ifndef __ABSTRACTQGARERROR_H_INCLUDED__ 00029 #define __ABSTRACTQGARERROR_H_INCLUDED__ 00030 00031 00032 /** 00033 * @file AbstractQgarError.H 00034 * @brief Header file of class qgar::AbstractQgarError. 00035 * 00036 * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gerald Masini">Gerald Masini</a> 00037 * @date November 6, 2003 18:18 00038 * @since Qgar 2.1 00039 */ 00040 00041 00042 // For RCS/CVS use: Do not delete 00043 /* $Id: AbstractQgarError.H,v 1.13 2005/10/14 17:05:45 masini Exp $ */ 00044 00045 00046 // STL 00047 #include <string> 00048 00049 00050 00051 namespace qgar 00052 { 00053 00054 /** 00055 * @ingroup ERROR 00056 * 00057 * @class AbstractQgarError AbstractQgarError.H "qgarlib/AbstractQgarError.H" 00058 * 00059 * @brief Base class for Qgar exceptions. 00060 * 00061 * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gerald Masini">Gerald Masini</a> 00062 * @date November 6, 2003 18:18 00063 * @since Qgar 2.1 00064 */ 00065 class AbstractQgarError 00066 { 00067 // ------------------------------------------------------------------- 00068 // P U B L I C M E M B E R S 00069 // ------------------------------------------------------------------- 00070 public: 00071 00072 /** @name Destructor */ 00073 // ========== 00074 //@{ 00075 00076 /** 00077 * @brief Virtual destructor. 00078 */ 00079 virtual ~AbstractQgarError(); 00080 00081 //@} 00082 00083 00084 /** @name Display */ 00085 // ======= 00086 //@{ 00087 00088 /** 00089 * @brief Display the error message header (first line of the message), 00090 * including an explicit description (in capital letters) 00091 * of the error type. 00092 * 00093 * @param anErrorKind explicit description of the error type 00094 */ 00095 virtual void displayHeader(const char* anErrorKind) const; 00096 00097 /** 00098 * @brief Enable the display of error messages 00099 * when exceptions are raised. 00100 * 00101 * @warning This is a static function. 00102 */ 00103 static void errorMsgOn(); 00104 00105 /** 00106 * @brief Disable the display of error messages 00107 * when exceptions are raised. 00108 * 00109 * @warning This is a static function. 00110 */ 00111 static void errorMsgOff(); 00112 00113 //@} 00114 00115 // ------------------------------------------------------------------- 00116 // P R O T E C T E D M E M B E R S 00117 // ------------------------------------------------------------------- 00118 protected: 00119 00120 // ============================================ 00121 /** @name Constructors 00122 Constructors belong to the protected section 00123 so that the class cannot be instantiated. 00124 */ 00125 // ============================================ 00126 //@{ 00127 00128 /** 00129 * @brief Construct without displaying any error message. 00130 * 00131 * @param aFuncProfile profile of the function throwing the exception 00132 */ 00133 AbstractQgarError(const char* aFuncProfile); 00134 00135 /** 00136 * @brief Construct and display an error message. 00137 * 00138 * An error message includes 4 lines: 00139 * - message header, displayed by 00140 * qgar::AbstractQgarError::displayErrorMessageHeader(const char*) 00141 * - file name and line number of the corresponding <b>throw</b> instruction 00142 * - function profile 00143 * - diagnostic 00144 * 00145 * @param anErrorKind explicit description (in capital letters) of the error type 00146 * @param aFileName name of the file including the function throwing the exception 00147 * @param aLineNumber line number (in the file) of the <b>throw</b> instruction 00148 * @param aFuncProfile profile of the function throwing the exception 00149 * @param aDiagnostic full explicit diagnostic 00150 */ 00151 AbstractQgarError(const char* anErrorKind, 00152 const char* aFileName, 00153 int aLineNumber, 00154 const char* aFuncProfile, 00155 const std::string aDiagnostic); 00156 //@} 00157 00158 /** @name Messages */ 00159 // ======== 00160 //@{ 00161 00162 /** 00163 * @brief Display flag for error messages. 00164 * 00165 * When <b>true</b> (which is the default), an error message 00166 * is displayed when a Qgar exception is raised. 00167 */ 00168 static bool _msgFlag; 00169 00170 //@} 00171 00172 // ------------------------------------------------------------------- 00173 }; // class AbstractQgarError 00174 00175 00176 } // namespace qgar 00177 00178 00179 #endif /* __ABSTRACTQGARERROR_H_INCLUDED__ */