Fourier library: Operations in the Fourier domain
error.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef FOURIER_ERROR_H_VERSION
38 
39 #define FOURIER_ERROR_H_VERSION \
40  "FOURIER_ERROR_H V1.0"
41 
42 namespace fourier {
43 
62  class Exception
63  {
64  public:
66  Exception();
68  Exception(const char* message);
70  Exception(const char* message,
71  const char* condition);
73  Exception(const char* message,
74  const char* file,
75  const int& line,
76  const char* condition);
78  Exception(const char* message,
79  const char* file,
80  const int& line);
82  virtual ~Exception() { }
84  virtual void report() const;
86  static void report_on_construct();
88  static void dont_report_on_construct();
89  protected:
91  void base_report() const;
92  private:
94  static bool Mreport_on_construct;
96  const char* Mmessage;
98  const char* Mfile;
100  const int& Mline;
102  const char* Mcondition;
103  }; // class Exception
104 
113  void report_violation(const char* message,
114  const char* file,
115  const int& line,
116  const char* condition);
117 
118 } // namespace fourier
119 
120 /*======================================================================*/
121 //
122 // preprocessor macros
123 // ===================
124 
132 #define FOURIER_Xassert(C,M,E) \
133  if (!(C)) { throw( E ( M , __FILE__, __LINE__, #C )); }
134 
141 #define FOURIER_assert(C,M) FOURIER_Xassert( C , M , fourier::Exception )
142 
149 #define FOURIER_abort(M) \
150  throw( fourier::Exception ( M , __FILE__, __LINE__ ))
151 
152 #define FOURIER_illegal FOURIER_abort("illegal call!")
153 
154 
163 #define FOURIER_report_assert(C,M,V) \
164  if (!(C)) { \
165  fourier::report_violation(M, __FILE__, __LINE__, #C); \
166  std::cerr << "* comment: " << V << std::endl; \
167  std::cerr << std::endl; \
168  std::cerr.flush(); \
169  }
170 
180 #define FOURIER_nonfatal_assert(F,C,M,V) \
181  if (F) { FOURIER_report_assert(C,M,V) } else { FOURIER_assert(C,M) }
182 
183 
184 /*======================================================================*/
185 // some misc macro functions
186 //
187 
194 #define FOURIER_debug(C,N,M) \
195  if (C) { \
196  std::cerr << "DEBUG (" << N << ", " \
197  << __FILE__ << " line #" << __LINE__ << "):" << std::endl \
198  << " " << M << std::endl; \
199  std::cerr.flush(); \
200 }
201 
202 #endif // FOURIER_ERROR_H_VERSION (includeguard)
203 
204 /* ----- END OF error.h ----- */
void base_report() const
Screen report.
Definition: error.cc:99
Exception()
Creates exception with no explaning comments.
Definition: error.cc:50
const char * Mcondition
pointer to assertion condition text string
Definition: error.h:102
void report_violation(const char *message, const char *file, const int &line, const char *condition)
report violation of assertion
Definition: error.cc:124
const char * Mfile
pointer to file name string
Definition: error.h:98
virtual ~Exception()
provide explicit virtual destructor
Definition: error.h:82
Definition: error.cc:44
const int & Mline
pointer to line number in source file
Definition: error.h:100
static bool Mreport_on_construct
Shall we print to cerr at construction time?
Definition: error.h:94
static void report_on_construct()
Issue a screen report on construction of exception.
Definition: error.cc:81
virtual void report() const
Screen report.
Definition: error.cc:93
Base class for exceptions.
Definition: error.h:62
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:96