GSLError.h

Go to the documentation of this file.
00001 // @(#)root/mathmore:$Id: GSLError.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Authors: L. Moneta, A. Zsenei   08/2005
00003 
00004  /**********************************************************************
00005   *                                                                    *
00006   * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
00007   *                                                                    *
00008   * This library is free software; you can redistribute it and/or      *
00009   * modify it under the terms of the GNU General Public License        *
00010   * as published by the Free Software Foundation; either version 2     *
00011   * of the License, or (at your option) any later version.             *
00012   *                                                                    *
00013   * This library is distributed in the hope that it will be useful,    *
00014   * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00015   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
00016   * General Public License for more details.                           *
00017   *                                                                    *
00018   * You should have received a copy of the GNU General Public License  *
00019   * along with this library (see file COPYING); if not, write          *
00020   * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
00021   * 330, Boston, MA 02111-1307 USA, or contact the author.             *
00022   *                                                                    *
00023   **********************************************************************/
00024 
00025 // Header file for class GSLError
00026 
00027 #ifndef ROOT_Math_GSLError
00028 #define ROOT_Math_GSLError
00029 
00030 
00031 #if defined(G__DICTIONARY) 
00032 
00033 #include "gsl/gsl_errno.h"
00034 
00035 #include "TError.h"
00036 #include "TSystem.h"
00037 
00038 
00039 namespace ROOT { 
00040    namespace Math { 
00041 
00042       /**
00043          class to change GSL Error handler to use ROOT one. 
00044          It is used only when building the dictionary (G__DICTIONARY is defined) 
00045          and not in the stand-alone version of the library. 
00046          In that case the default GSL error handler is used  
00047        */
00048 
00049       class GSLError { 
00050 
00051       public: 
00052          
00053          GSLError() { 
00054                gsl_set_error_handler(&GSLError::Handler);
00055             // set a new handler for GSL 
00056          }
00057 
00058          static void Handler(const char * reason, const char * file, int line, int gsl_errno)  { 
00059 
00060             Error("GSLError","Error %d in %s at %d : %s",gsl_errno,file,line,reason);
00061             
00062          }
00063       }; 
00064 
00065    }
00066 }
00067 
00068 // re-define the default error handler when loading the library
00069 ROOT::Math::GSLError gGSLError; 
00070 
00071 
00072 #endif
00073 
00074 #endif /* ROOT_Math_GSLError */

Generated on Tue Jul 5 14:34:55 2011 for ROOT_528-00b_version by  doxygen 1.5.1