aflibDebug.h

Go to the documentation of this file.
00001     /*
00002 
00003     Copyright (C) 2000 Stefan Westerfeld
00004                        stefan@space.twc.de
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010   
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015    
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 
00021 
00022     Some inspiration taken from glib.
00023     Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
00024     Modified by the GLib Team and others 1997-1999.
00025 
00026     */
00027 
00028 #ifndef _AFLIBDEBUG_H_
00029 #define _AFLIBDEBUG_H_
00030 
00031 /*
00032  * BC - Status (2000-09-30): Debug.
00033  *
00034  * Collection class, no instance, no members. Thus binary compatible (will
00035  * be kept).
00036  */
00037 
00038 #define aflib_fatal     ::aflibDebug::fatal
00039 #define aflib_warning   ::aflibDebug::warning
00040 #define aflib_info      ::aflibDebug::info
00041 #define aflib_debug     ::aflibDebug::debug
00042 
00043 /* source compatibility with older sources */
00044 #define aflibdebug      ::aflibDebug::debug
00045 #define setaflibdebug(x)    aflib_warning("setaflibdebug is obsolete")
00046 
00047 #ifdef __GNUC__
00048 
00049 #define aflib_return_if_fail(expr)                                      \
00050      if (!(expr))                                                       \
00051      {                                                                  \
00052        aflib_warning ("file %s: line %d (%s): assertion failed: (%s)",  \
00053           __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr);              \
00054        return;                                                          \
00055      }
00056 
00057 #define aflib_return_val_if_fail(expr,val)                              \
00058      if (!(expr))                                                       \
00059      {                                                                  \
00060        aflib_warning ("file %s: line %d (%s): assertion failed: (%s)",      \
00061           __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr);              \
00062        return (val);                                                    \
00063      }
00064 
00065 #define aflib_assert(expr)                                              \
00066      if (!(expr))                                                       \
00067        aflib_fatal ("file %s: line %d (%s): assertion failed: (%s)",    \
00068           __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr);              \
00069 
00070 #else
00071 
00072 #define aflib_return_if_fail(expr)                                      \
00073      if (!(expr))                                                       \
00074      {                                                                  \
00075        aflib_warning ("file %s: line %d: assertion failed: (%s)",       \
00076           __FILE__, __LINE__, #expr);                                   \
00077        return;                                                          \
00078      }
00079 
00080 #define aflib_return_val_if_fail(expr,val)                              \
00081      if (!(expr))                                                       \
00082      {                                                                  \
00083        aflib_warning ("file %s: line %d: assertion failed: (%s)",       \
00084           __FILE__, __LINE__, #expr);                                   \
00085        return (val);                                                    \
00086      }
00087 
00088 #define aflib_assert(expr)                                              \
00089      if (!(expr))                                                       \
00090     aflib_fatal ("file %s: line %d: assertion failed: (%s)",        \
00091           __FILE__, __LINE__, #expr);                                   \
00092 
00093 #endif
00094 
00095 class aflibDebug {
00096     public:
00097         enum Level { lFatal = 3, lWarning = 2, lInfo = 1, lDebug = 0 };
00098 
00103         static void init(const char *prefix, Level level);
00104 
00105         static void fatal(const char *fmt,...);     // print on stderr & abort
00106         static void warning(const char *fmt,...);   // print on stderr
00107         static void info(const char *fmt,...);      // print on stdout
00108         static void debug(const char *fmt,...);     // print on stdout
00109 
00114         static void messageApp(const char *appName);
00115 
00116     };
00117 
00118 #endif

Generated on Sat Feb 23 13:56:37 2008 for Open Source Audio Library Project by  doxygen 1.5.1