LALError.h

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program 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.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /************************************ <lalVerbatim file="LALErrorHV">
00021 $Id: LALError.h,v 1.3 2007/06/08 14:41:52 bema Exp $
00022 ************************************* </lalVerbatim> */
00023 
00024 /* <lalLaTeX>
00025 
00026 \section{Header \texttt{LALError.h}}
00027 \label{s:LALError.h}
00028 
00029 Provides routines to report and handle errors.
00030 
00031 \subsection*{Synopsis}
00032 \begin{verbatim}
00033 #include <lal/LALError.h>
00034 \end{verbatim}
00035 
00036 \noindent This header covers routines that print status messages, and
00037 that allow functions to abort.
00038 
00039 \vfill{\footnotesize\input{LALErrorHV}}
00040 \newpage\input{LALErrorC}
00041 
00042 </lalLaTeX> */
00043 
00044 #ifndef _LALERROR_H
00045 #define _LALERROR_H
00046 
00047 #include <lal/LALDatatypes.h>
00048 
00049 #include <lal/XLALError.h>
00050 
00051 #ifdef  __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 
00056 NRCSID( LALERRORH, "$Id: LALError.h,v 1.3 2007/06/08 14:41:52 bema Exp $" );
00057 
00058 /* lalDebugLevel bit field values: */
00059 enum
00060 {
00061   LALNDEBUG  = 0,
00062   LALERROR   = 1,
00063   LALWARNING = 2,
00064   LALINFO    = 4,
00065   LALTRACE   = 8,
00066   LALMEMINFO = 16,
00067   LALNMEMDBG = 32,
00068   LALNMEMPAD = 64,
00069   LALNMEMTRK = 128,
00070   LALMEMDBG  = 16384 /* convenience: don't combine with other bits */
00071 };
00072 
00073 /* composite lalDebugLevels: */
00074 enum { LALMSGLVL1  = LALERROR };
00075 enum { LALMSGLVL2  = LALERROR | LALWARNING };
00076 enum { LALMSGLVL3  = LALERROR | LALWARNING | LALINFO };
00077 enum { LALMEMTRACE = LALTRACE | LALMEMINFO };
00078 enum { LALALLDBG   = ~( LALNMEMDBG | LALNMEMPAD | LALNMEMTRK ) };
00079 
00080 extern int  ( *lalRaiseHook )( int, const char *, ... );
00081 extern void ( *lalAbortHook )( const char *, ... );
00082 
00083 int
00084 LALPrintError( const char *fmt, ... );
00085 
00086 int
00087 LALRaise( int sig, const char *fmt, ... );
00088 
00089 void
00090 LALAbort( const char *fmt, ... );
00091 
00092 int
00093 LALError( LALStatus *status, const char *statement );
00094 
00095 int
00096 LALWarning( LALStatus *status, const char *warning );
00097 
00098 int
00099 LALInfo( LALStatus *status, const char *info );
00100 
00101 int
00102 LALTrace( LALStatus *status, int exitflg );
00103 
00104 int
00105 LALInitStatus( LALStatus *status, const char *function, const char *id,
00106                const char *file, const int line );
00107 
00108 int
00109 LALPrepareReturn( LALStatus *status, const char *file, const int line );
00110 
00111 int
00112 LALAttatchStatusPtr( LALStatus *status, const char *file, const int line );
00113 
00114 int
00115 LALDetatchStatusPtr( LALStatus *status, const char *file, const int line );
00116 
00117 int
00118 LALPrepareAbort( LALStatus *status, const INT4 code, const char *mesg,
00119                  const char *file, const int line );
00120 
00121 int
00122 LALPrepareAssertFail( LALStatus *status, const INT4 code, const char *mesg,
00123                       const char *statement, const char *file,
00124                       const int line );
00125 
00126 int
00127 LALCheckStatusPtr( LALStatus *status, const char *statement, const char *file,
00128                    const int line );
00129 
00130 void
00131 FREESTATUSPTR( LALStatus *status );
00132 
00133 void
00134 REPORTSTATUS( LALStatus *status );
00135 
00136 #ifdef NDEBUG
00137 
00138 #define LALError( statusptr, statement ) 0
00139 #define LALWarning( statusptr, warning ) 0
00140 #define LALInfo( statusptr, info )       0
00141 #define LALTrace( statusptr, exitflg )   0
00142 
00143 #else
00144 
00145 #ifndef NOLALMACROS
00146 
00147 #define LALError( statusptr, statement )                                    \
00148   ( lalDebugLevel & LALERROR ?                                                 \
00149     LALPrintError( "Error[%d] %d: function %s, file %s, line %d, %s\n"       \
00150         "        %s %s\n", (statusptr)->level, (statusptr)->statusCode,      \
00151         (statusptr)->function, (statusptr)->file, (statusptr)->line,        \
00152         (statusptr)->Id, (statement) ? (statement) : "",                    \
00153         (statusptr)->statusDescription ) : 0 )
00154 
00155 #define LALWarning( statusptr, warning )                                    \
00156   ( lalDebugLevel & LALWARNING ?                                               \
00157     LALPrintError( "Warning[%d]: function %s, file %s, line %d, %s\n"        \
00158         "        %s\n", (statusptr)->level, (statusptr)->function,          \
00159         (statusptr)->file, (statusptr)->line, (statusptr)->Id, (warning) )  \
00160       : 0 )
00161 
00162 #define LALInfo( statusptr, info )                                          \
00163   ( lalDebugLevel & LALINFO ?                                                  \
00164     LALPrintError( "Info[%d]: function %s, file %s, line %d, %s\n"          \
00165         "        %s\n", (statusptr)->level, (statusptr)->function,          \
00166         (statusptr)->file, (statusptr)->line, (statusptr)->Id, (info) )     \
00167       : 0 )
00168 
00169 #define LALTrace( statusptr, exitflg ) \
00170   ( lalDebugLevel & LALTRACE ? \
00171     LALPrintError( "%s[%d]: function %s, file %s, line %d, %s\n",      \
00172         (exitflg) ? "Leave" : "Enter", (statusptr)->level, \
00173         (statusptr)->function, (statusptr)->file, (statusptr)->line, \
00174         (statusptr)->Id )     \
00175       : 0 )
00176 
00177 #endif /* NOLALMACROS */
00178 
00179 #endif /* NDEBUG */
00180 
00181 #ifdef  __cplusplus
00182 }
00183 #endif
00184 
00185 #endif /* _LALERROR_H */

Generated on Sun Sep 7 03:06:52 2008 for LAL by  doxygen 1.5.2