casa
$Rev:20696$
|
00001 //# FITSError.h: default FITS error handling function, typdef, and enumeration 00002 //# Copyright (C) 1999 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: FITSError.h 20652 2009-07-06 05:04:32Z Malte.Marquarding $ 00028 00029 #ifndef FITS_FITSERROR_H 00030 #define FITS_FITSERROR_H 00031 00032 //#! Includes go here 00033 #include <casa/aips.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> 00038 // default FITS error handling function, typdef, and enumeration 00039 // </summary> 00040 00041 // <use visibility=export> 00042 00043 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos=""> 00044 // </reviewed> 00045 00046 // <synopsis> 00047 // FITSError contains the enumeration specifying the possible error 00048 // message levels. It also contains the default error handling function 00049 // for the FITS classes. 00050 // </synopsis> 00051 // 00052 // <example> 00053 // This example shows how one could set up an error handler 00054 // which does what the FITS classes originally did - just 00055 // send the error message to cout without any indication as 00056 // to the severity of the error message. 00057 // <srcblock> 00058 // void coutErrHandler(const char *errMessage, FITSError::ErrorLevel) 00059 // { cout << errMessage << endl; } 00060 // 00061 // FitsInput fin("myFile", FITS::Disk, 10, coutErrHandler); 00062 // </srcblock> 00063 // Any error messages generated by fin will be sent to cout. 00064 // Error handlers for the HDUs would need to be indicated in 00065 // their constructors. For example: 00066 // <srcblock> 00067 // PrimaryArray<Float> pa(fin, coutErrHandler); 00068 // </srcblock> 00069 // The default error handler is FITSError::defaultHandler which 00070 // sends the error message to the global log sink at the 00071 // severity implied by ErrorLevel. 00072 // 00073 // The error handler only handles the error messages. It is up to 00074 // the programmer to check for the error status of classes like 00075 // FitsInput. 00076 // </example> 00077 // 00078 // <motivation> 00079 // Originally, FITS error message were simply sent to an ostream. In 00080 // order to have these error messages go to the AIPS++ logger by default, 00081 // this class was added. This was made a separate class because both 00082 // BlockIo and FITS need to use this class. The anticipated replacements 00083 // for the current FITS classes use a somewhat similar scheme. 00084 // </motivation> 00085 00086 class FITSError 00087 { 00088 public: 00089 00090 // WARN means that the FITS file is still usable - this generally 00091 // happens when parsing the HDU and some minor, recoverable 00092 // violation of the FITS rules is detected. 00093 // SEVERE means that a fatal error has occurred and the FITS file 00094 // can not be properly processed. 00095 enum ErrorLevel { INFO, WARN, SEVERE }; 00096 00097 // The default error handler. The errMessage is posted to 00098 // the global log sink at the severity implied by ErrorLevel. 00099 // It is assumed that errMessage is null terminated. 00100 static void defaultHandler(const char *errMessage, ErrorLevel severity); 00101 }; 00102 00103 // <summary> 00104 // Define a typedef for the handler function signature for convenience. 00105 // </summary> 00106 00107 // <use visibility=export> 00108 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos=""> 00109 // </reviewed> 00110 00111 typedef void (*FITSErrorHandler) (const char* errMessage, 00112 FITSError::ErrorLevel severity); 00113 00114 00115 00116 } //# NAMESPACE CASA - END 00117 00118 #endif 00119 00120