Main Page | Class List | Directories | File List | Class Members | File Members

ObitErr.h

Go to the documentation of this file.
00001 /* $Id: ObitErr.h,v 1.3 2005/12/08 02:01:20 bcotton Exp $         */
00002 /*--------------------------------------------------------------------*/
00003 /*;  Copyright (C) 2002-2004                                          */
00004 /*;  Associated Universities, Inc. Washington DC, USA.                */
00005 /*;  This program is free software; you can redistribute it and/or    */
00006 /*;  modify it under the terms of the GNU General Public License as   */
00007 /*;  published by the Free Software Foundation; either version 2 of   */
00008 /*;  the License, or (at your option) any later version.              */
00009 /*;                                                                   */
00010 /*;  This program is distributed in the hope that it will be useful,  */
00011 /*;  but WITHOUT ANY WARRANTY; without even the implied warranty of   */
00012 /*;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    */
00013 /*;  GNU General Public License for more details.                     */
00014 /*;                                                                   */
00015 /*;  You should have received a copy of the GNU General Public        */
00016 /*;  License along with this program; if not, write to the Free       */
00017 /*;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,     */
00018 /*;  MA 02139, USA.                                                   */
00019 /*;                                                                   */
00020 /*;  Correspondence this software should be addressed as follows:     */
00021 /*;         Internet email: bcotton@nrao.edu.                         */
00022 /*;         Postal address: William Cotton                            */
00023 /*;                         National Radio Astronomy Observatory      */
00024 /*;                         520 Edgemont Road                         */
00025 /*;                         Charlottesville, VA 22903-2475 USA        */
00026 /*--------------------------------------------------------------------*/
00027 #ifndef OBITERR_H 
00028 #define OBITERR_H 
00029 #include <glib.h>
00030 
00031 /*-------- Obit: Software for the recently deceased ------------------*/
00057 /*----------------- enums ---------------------------*/
00062 enum ObitErrCode {
00064   OBIT_None = 0,
00066   OBIT_InfoErr,
00068   OBIT_InfoWarn,
00070   OBIT_Traceback,
00072   OBIT_MildError,
00074   OBIT_Error,
00076   OBIT_StrongError,
00078   OBIT_Fatal
00079 };/* end enum ObitErrCode */
00083 typedef enum ObitErrCode ObitErrCode;
00084 
00086 #define OBITERRBUFSIZE 120
00087 
00088 /*----------------- Macroes ---------------------------*/
00096 #define Obit_log_error(err,errCode,format...)        G_STMT_START{ \
00097         g_snprintf (err->buffer, OBITERRBUFSIZE, format);          \
00098         ObitErrPush (err, errCode, err->buffer);                   \
00099         if (errCode>OBIT_Traceback) {                              \
00100            g_snprintf (err->buffer, OBITERRBUFSIZE,                \
00101                        " This occured at file %s: line %d (%s)",   \
00102                         __FILE__, __LINE__, __PRETTY_FUNCTION__);  \
00103            ObitErrPush (err, OBIT_Error, err->buffer);             \
00104           }                                                        \
00105         }G_STMT_END  
00106 
00114 #define Obit_log_error_no_trace(err,errCode,format...) G_STMT_START{ \
00115         g_snprintf (err->buffer, OBITERRBUFSIZE, format);          \
00116         ObitErrPush (err, errCode, err->buffer);                   \
00117         }G_STMT_END  
00118 
00127 #define Obit_return_if_fail(expr,err,format...)   G_STMT_START{  \
00128      if (expr) { } else  {                                       \
00129         g_snprintf (err->buffer, OBITERRBUFSIZE, format);        \
00130         ObitErrPush (err, OBIT_Error, err->buffer);              \
00131         g_snprintf (err->buffer, OBITERRBUFSIZE,                 \
00132                     " Occured at file %s: line %d (%s)",         \
00133                      __FILE__, __LINE__, __PRETTY_FUNCTION__);   \
00134         ObitErrPush (err, OBIT_Error, err->buffer);              \
00135         return;                                                  \
00136      } }G_STMT_END  
00137 
00148 #define Obit_retval_if_fail(expr,err,out,format...) G_STMT_START{ \
00149      if (expr) { } else  {                                        \
00150         g_snprintf (err->buffer, OBITERRBUFSIZE, format);         \
00151         ObitErrPush (err, OBIT_Error, err->buffer);               \
00152         g_snprintf (err->buffer, OBITERRBUFSIZE,                  \
00153                     " Occured at file %s: line %d (%s)",          \
00154                      __FILE__, __LINE__, __PRETTY_FUNCTION__);    \
00155         ObitErrPush (err, OBIT_Error, err->buffer);               \
00156         return out;                                               \
00157      } }G_STMT_END  
00158 
00166 #define Obit_traceback_msg(err,me,name) G_STMT_START{           \
00167      g_snprintf (err->buffer, OBITERRBUFSIZE,                   \
00168                 "Traceback: routine %s:  object %s", me, name); \
00169      ObitErrPush (err, OBIT_Traceback, err->buffer);            \
00170      g_snprintf (err->buffer, OBITERRBUFSIZE,                   \
00171                  " Occured at file %s: line %d (%s)",           \
00172                   __FILE__, __LINE__, __PRETTY_FUNCTION__);     \
00173       ObitErrPush (err, OBIT_Traceback, err->buffer);           \
00174       return;                                                   \
00175      }G_STMT_END
00176 
00185 #define Obit_traceback_val(err,me,name,out) G_STMT_START{       \
00186      g_snprintf (err->buffer, OBITERRBUFSIZE,                   \
00187                 "Traceback: routine %s:  object %s", me, name); \
00188      ObitErrPush (err, OBIT_Traceback, err->buffer);            \
00189      g_snprintf (err->buffer, OBITERRBUFSIZE,                   \
00190                  " at file %s: line %d (%s)",                   \
00191                   __FILE__, __LINE__, __PRETTY_FUNCTION__);     \
00192       ObitErrPush (err, OBIT_Traceback, err->buffer);           \
00193       return out;                                               \
00194      }G_STMT_END
00195 
00201 #define Obit_cfitsio_error(err)   G_STMT_START{                       \
00202       while (fits_read_errmsg(err->buffer))                           \
00203         ObitErrPush (err, OBIT_Error, err->buffer);                   \
00204       fits_clear_errmsg();     }G_STMT_END  
00205 
00206 /*---------------Class Structures---------------------------*/
00208 typedef struct {
00210   gchar *className;
00212   gint16 number;
00214   gboolean error;
00216   GQueue *stack;
00218   gint32 ReferenceCount;
00220   gchar buffer[OBITERRBUFSIZE+1];
00221 } ObitErr;
00222 
00224 typedef struct {
00226   ObitErrCode errLevel;
00228   gchar *errMsg;
00229 } ObitErrElem;
00230 
00231 /* Private functions defined only in ObitErr.c */
00232 /*---------------Public functions---------------------------*/
00233 
00235 ObitErr* newObitErr (void);
00236 
00238 ObitErr* ObitErrRef (ObitErr* in);
00239 
00241 ObitErr* ObitErrUnref (ObitErr* in);
00242 
00244 void ObitErrClear (ObitErr* in);
00245 
00247 void ObitErrClearErr (ObitErr* in);
00248 
00250 void ObitErrPush (ObitErr *in, ObitErrCode errLevel, gchar *errMsg);
00251 
00253 void ObitErrPop  (ObitErr *in, ObitErrCode *errLevel, gchar **errMsg);
00254 
00256 void ObitErrLog  (ObitErr *in);
00257 
00259 gboolean ObitErrIsA (ObitErr* in);
00260 
00261 #endif /* OBITERR_H */ 
00262 

Generated on Fri Aug 31 22:13:04 2007 for Obit by  doxygen 1.3.9.1