STFINV library: seek source wavelet correction filter
error.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef STFINV_ERROR_H_VERSION
38 
39 #define STFINV_ERROR_H_VERSION \
40  "STFINV_ERROR_H V1.0"
41 
42 #include <iostream>
43 
44 namespace stfinv {
45 
61  class Exception
62  {
63  public:
65  Exception();
67  Exception(const char* message);
69  Exception(const char* message,
70  const char* condition);
72  Exception(const char* message,
73  const char* file,
74  const int& line,
75  const char* condition);
77  Exception(const char* message,
78  const char* file,
79  const int& line);
81  virtual ~Exception() { }
83  virtual void report() const;
85  static void report_on_construct();
87  static void dont_report_on_construct();
88  protected:
90  void base_report() const;
91  private:
93  static bool Mreport_on_construct;
95  const char* Mmessage;
97  const char* Mfile;
99  const int& Mline;
101  const char* Mcondition;
102  }; // class Exception
103 
112  void report_violation(const char* message,
113  const char* file,
114  const int& line,
115  const char* condition);
116 
117 } // namespace stfinv
118 
119 /*======================================================================*/
120 //
121 // preprocessor macros
122 // ===================
123 
131 #define STFINV_Xassert(C,M,E) \
132  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
133 
140 #define STFINV_assert(C,M) STFINV_Xassert( C , M , stfinv::Exception )
141 
147 #define STFINV_abort(M) \
148  throw( stfinv::Exception ( M , __FILE__, __LINE__ ))
149 
154 #define STFINV_illegal STFINV_abort("illegal call!")
155 
164 #define STFINV_report_assert(C,M,V) \
165  if (!(C)) { \
166  stfinv::report_violation(M, __FILE__, __LINE__, #C); \
167  std::cerr << "* comment: " << V << std::endl; \
168  std::cerr << std::endl; \
169  std::cerr.flush(); \
170  }
171 
181 #define STFINV_nonfatal_assert(F,C,M,V) \
182  if (F) { STFINV_report_assert(C,M,V) } else { STFINV_assert(C,M) }
183 
184 #endif // STFINV_ERROR_H_VERSION (includeguard)
185 
186 /* ----- END OF error.h ----- */
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:93
Base class for exceptions.
Definition: error.h:61
Root namespace of library.
Definition: doxygen.txt:43
Exception()
Creates exception with no explaning comments.
Definition: error.cc:50
virtual ~Exception()
provide explicit virtual destructor
Definition: error.h:81
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:81
void base_report() const
Screen report.
Definition: error.cc:99
void report_violation(const char *message, const char *file, const int &line, const char *condition)
report violation of assertion
Definition: error.cc:124
virtual void report() const
Screen report.
Definition: error.cc:93
const int & Mline
pointer to line number in source file
Definition: error.h:99
static void dont_report_on_construct()
Issue NO screen report on construction of exception.
Definition: error.cc:87
const char * Mmessage
pointer to message string
Definition: error.h:95
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:101
const char * Mfile
pointer to file name string
Definition: error.h:97