LINEAR++ library: AFF to LAPACK
error.h
Go to the documentation of this file.
1 
38 // include guard
39 #ifndef LINEAR_ERROR_H_VERSION
40 
41 #define LINEAR_ERROR_H_VERSION \
42  "LINEAR_ERROR_H V1.2"
43 
44 namespace linear {
45 
64  class Exception
65  {
66  public:
68  Exception();
70  virtual ~Exception() { }
72  Exception(const char* message);
74  Exception(const char* message,
75  const char* condition);
77  Exception(const char* message,
78  const char* file,
79  const int& line,
80  const char* condition);
82  Exception(const char* message,
83  const char* file,
84  const int& line);
86  virtual void report() const;
88  static void report_on_construct();
90  static void dont_report_on_construct();
91  protected:
93  void base_report() const;
94  private:
96  static bool Mreport_on_construct;
98  const char* Mmessage;
100  const char* Mfile;
102  const int& Mline;
104  const char* Mcondition;
105  }; // class Exception
106 
107  /*----------------------------------------------------------------------*/
108 
115  public Exception
116  {
117  public:
119  LapackException(const char* message,
120  const char* subroutine,
121  const char* file,
122  const int& line,
123  const char* condition,
124  const int& value);
126  virtual ~LapackException() { }
128  virtual void report() const;
130  int value() const { return(Mvalue); }
132  const char* subroutine() const { return(Msubroutine); }
133  private:
135  int Mvalue;
136  const char* Msubroutine;
137  const char* Mmeaning;
138  }; // class LapackException
139 
140 } // namespace linear
141 
142 /*======================================================================*/
143 //
144 // preprocessor macros
145 // ===================
146 
154 #define LINEAR_Xassert(C,M,E) \
155  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
156 
166 #define LINEAR_LAPACK_failure(C,N,M,V) \
167  if ((C)) { throw( linear::LapackException ( M , N , __FILE__, \
168  __LINE__, #C, V )); }
169 
176 #define LINEAR_assert(C,M) LINEAR_Xassert( C , M , linear::Exception )
177 
183 #define LINEAR_abort(M) \
184  throw( linear::Exception ( M , __FILE__, __LINE__ ))
185 
195 #define LINEAR_debug(C,N,M) \
196  if (C) { \
197  std::cerr << "DEBUG (" << N << ", " \
198  << __FILE__ << " line #" << __LINE__ << "):" << std::endl \
199  << " " << M << std::endl; \
200  std::cerr.flush(); \
201  }
202 
203 #endif // LINEAR_ERROR_H_VERSION (includeguard)
204 
205 /* ----- END OF error.h ----- */
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:96
const char * Mmessage
pointer to message string
Definition: error.h:98
const char * Mmeaning
Definition: error.h:137
virtual void report() const
Screen report.
Definition: error.cc:135
void base_report() const
Screen report.
Definition: error.cc:98
int value() const
return INFO value
Definition: error.h:130
const int & Mline
pointer to line number in source file
Definition: error.h:102
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:80
Exception()
Creates exception with no explaning comments.
Definition: error.cc:49
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:86
int Mvalue
members to remember
Definition: error.h:135
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:104
const char * Mfile
pointer to file name string
Definition: error.h:100
const char * subroutine() const
return name of LAPACK subroutine
Definition: error.h:132
virtual void report() const
Screen report.
Definition: error.cc:92
LapackException(const char *message, const char *subroutine, const char *file, const int &line, const char *condition, const int &value)
take number of requested elements and their size
Definition: error.cc:124
const char * Msubroutine
Definition: error.h:136
Exception thrown in case of LAPACK return value error.
Definition: error.h:114
Modules of liblinearxx.a.
Definition: error.cc:43
virtual ~LapackException()
Needs a virtual destructor.
Definition: error.h:126
virtual ~Exception()
Needs a virtual destructor.
Definition: error.h:70
Base class for exceptions.
Definition: error.h:64