Diana Software
QGSL.cc
Go to the documentation of this file.
1 #include "QGSL.hh"
2 #include "QError.hh"
3 #include <gsl/gsl_errno.h>
4 
6 
7 jmp_buf QGSL::fMark;
9 
11 {
12 }
13 
15 {
16  if(fError) delete fError;
17 }
19 {
20  static QGSL me;
21  return me;
22 }
23 
25 {
26  // translate the stack jump into a C++ throw
27  if (setjmp(fMark) != 0) {
28  if(!fError) fError = new QError(QERR_GSL_ERROR);
29  fError->SetDescription("Unknown GSL error, rerun with -g");
30  DianaThrow( *fError );
31  } else {
33  }
34 }
35 
37 {
38  gsl_set_error_handler(&ErrorHandler);
39 }
40 
42 {
43  gsl_set_error_handler_off();
44 }
45 
46 void QGSL::ErrorHandler(const char * reason, const char * file, int line, int gsl_errno)
47 {
48  if(fError) delete fError;
49  fError = new QError(QERR_GSL_ERROR,file,line,reason);
50  // this is like C++ throw
51  longjmp(fMark, -1);
52 }
53 
#define DianaThrow(obj)
Definition: QDianaDebug.hh:26
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
@ QERR_GSL_ERROR
Definition: QError.hh:37
error class with error type and description
Definition: QError.hh:115
void SetDescription(const std::string &descr)
set error description
Definition: QError.hh:147
diana interface to GSL core
Definition: QGSL.hh:16
static QGSL & GetInstance()
Definition: QGSL.cc:18
static QError * fError
Definition: QGSL.hh:28
QGSL()
Definition: QGSL.cc:10
static jmp_buf fMark
Definition: QGSL.hh:27
void TurnOffErrorHandler()
Definition: QGSL.cc:41
virtual ~QGSL()
Definition: QGSL.cc:14
void TurnOnErrorHandler()
Definition: QGSL.cc:36
void InitErrorHandler()
Definition: QGSL.cc:24
static void ErrorHandler(const char *reason, const char *file, int line, int gsl_errno)
Definition: QGSL.cc:46