KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsl_util.h
Go to the documentation of this file.
1 
9 /*
10  * $Id: gsl_util.h 14342 2013-05-02 02:35:41Z predoehl $
11  */
12 
13 #ifndef GSL_UTIL_H_KJBLIB_UARIZONAVISION
14 #define GSL_UTIL_H_KJBLIB_UARIZONAVISION
15 
16 #ifdef KJB_HAVE_GSL
17 #include "gsl/gsl_errno.h"
18 #else
19 #warning "GNU GSL is absent"
20 #define GSL_SUCCESS 0
21 #endif
22 
23 /*
24  * @brief This throws an exception if its argument is a GSL error.
25  * @throws KJB_error if the gsl_code is not equal to GSL_SUCCESS
26  *
27  * This macro is intended to be used like other KJB-library macros like ETE
28  * or EPE: it surrounds executable code that might return a GSL error.
29  * In the common case the expression is GSL_SUCCESS and the macro does nothing.
30  * When the argument is not GSL_SUCCESS, this will generate an error string
31  * describing the flavor of GSL error, and throw a kjb::KJB_error object
32  * containing the error string.
33  *
34  * This macro invokes an implementation function that is designed to be as
35  * lightweight as possible, so that each use injects a minimum of code inline.
36  */
37 #define GSL_ETX( gsl_expr ) kjb::Gsl_Etx_impl( (gsl_expr), __FILE__, __LINE__ )
38 
39 
40 namespace kjb {
41 
42 
50  int gsl_code,
51  const char* file,
52  unsigned line_no
53 );
54 
55 
73 inline
74 void Gsl_Etx_impl( int gsl_code, const char* file, unsigned line_no )
75 {
76  if ( GSL_SUCCESS != gsl_code )
77  {
78  report_gsl_failure_and_throw_kjb_error( gsl_code, file, line_no );
79  }
80 }
81 
83 void gsl_iterate_EPE(int gsl_error_code);
84 
85 }
86 
87 #endif
#define GSL_SUCCESS
Definition: gsl_util.h:20
void gsl_iterate_EPE(int gsl_error_code)
On error, print a GSL iteration error message (like EPE)
Definition: gsl_util.cpp:40
void report_gsl_failure_and_throw_kjb_error(int gsl_code, const char *file, unsigned line_no)
Implements the error-handling activities of Gsl_Etx_impl().
Definition: gsl_util.cpp:22
void Gsl_Etx_impl(int gsl_code, const char *file, unsigned line_no)
On GSL error of some kind, throw an KJB_error exception.
Definition: gsl_util.h:74