BALL  1.5.0
COMMON/exception.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_COMMON_EXCEPTION_H
6 #define BALL_COMMON_EXCEPTION_H
7 
8 #ifndef BALL_CONFIG_CONFIG_H
9 # include <BALL/CONFIG/config.h>
10 #endif
11 
12 #ifndef BALL_COMMON_GLOBAL_H
13 # include <BALL/COMMON/global.h>
14 #endif
15 
16 #ifdef BALL_COMPILER_MSVC
17  #pragma warning(push)
18  #pragma warning( disable : 4251 ) //disable needs to have dll-interface to be used by clients of class 'std::string'
19 #endif
20 
21 #include <new>
22 #include <string>
23 
24 namespace BALL
25 {
26 
27  class String;
28 
32  namespace Exception
33  {
34 
60  : public std::exception
61  {
62  public:
63 
67 
70 
72  GeneralException(const char* file, int line);
73 
76  (const char* file, int line,
77  const String& name , const String& message);
78 
80  GeneralException(const GeneralException& exception);
81 
83  virtual ~GeneralException() throw();
85 
89 
91  const char* getName() const;
92 
94  const char* getMessage() const;
95 
97  void setMessage(const std::string& message);
98 
100  int getLine() const;
101 
103  const char* getFile() const;
105 
106  protected:
107  const char* file_;
108  int line_;
109 
110  std::string name_;
111  std::string message_;
112  };
113 
123  : public GeneralException
124  {
125  public:
126 
127  IndexUnderflow(const char* file, int line, Index index = 0, Size size = 0);
128 
129 
130  protected:
131 
134  };
135 
144  : public GeneralException
145  {
146  public:
147 
148  SizeUnderflow(const char* file, int line, Size size = 0);
149 
150  protected:
152  };
153 
163  : public GeneralException
164  {
165  public:
166  IndexOverflow(const char* file, int line, Index index = 0, Size size = 0);
167 
168  protected:
169 
172  };
173 
178  : public GeneralException
179  {
180  public:
181  InvalidArgument(const char* file, int line, const String& arg);
182  };
183 
188  : public GeneralException
189  {
190  public:
191  InvalidRange(const char* file, int line, float value);
192  };
193 
194 
202  : public GeneralException
203  {
204  public:
205 
206  InvalidSize(const char* file, int line, Size size = 0);
207 
208  protected:
210  };
211 
212 
218  : public GeneralException
219  {
220  public:
221  OutOfRange(const char* file, int line);
222  };
223 
230  : public GeneralException
231  {
232  public:
233  InvalidFormat(const char* file, int line, const String& s);
234 
235  ~InvalidFormat() throw();
236 
237  protected:
238 
239  std::string format_;
240  };
241 
248  : public GeneralException
249  {
250  public:
251  IllegalSelfOperation(const char* file, int line);
252  };
253 
259  : public GeneralException
260  {
261  public:
262  NullPointer(const char* file, int line);
263  };
264 
269  : public GeneralException
270  {
271  public:
272  InvalidIterator(const char* file, int line);
273  };
274 
280  : public GeneralException
281  {
282  public:
283  IncompatibleIterators(const char* file, int line);
284  };
285 
293  : public GeneralException
294  {
295  public:
296  NotImplemented(const char* file, int line);
297  };
298 
304  : public GeneralException
305  {
306  public:
307  IllegalTreeOperation(const char* file, int line);
308  };
309 
317  : public GeneralException, public std::bad_alloc
318  {
319  public:
320  OutOfMemory(const char* file, int line, Size size = 0);
321 
322  virtual ~OutOfMemory()
323  throw();
324 
325  protected:
327  };
328 
332  : public GeneralException
333  {
334  public:
335  BufferOverflow(const char* file, int line);
336  };
337 
341  : public GeneralException
342  {
343  public:
344  DivisionByZero(const char* file, int line);
345  };
346 
350  : public GeneralException
351  {
352  public:
353  OutOfGrid(const char* file, int line);
354  };
355 
360  : public GeneralException
361  {
362  public:
363  FileNotFound(const char* file, int line, const String& filename);
364 
365  ~FileNotFound()
366  throw();
367  String getFilename() const;
368 
369  protected:
370  std::string filename_;
371  };
372 
377  : public GeneralException
378  {
379  public:
380  IllegalPosition(const char* file, int line, float x, float y, float z);
381  };
382 
387  : public GeneralException
388  {
389  public:
391  ParseError(const char* file, int line, const String& expression,
392  const String& message);
393  };
394 
399  : public GeneralException
400  {
401  public:
403  Precondition(const char* file, int line, const char* condition);
404  };
405 
410  : public GeneralException
411  {
412  public:
414  Postcondition(const char* file, int line, const char* condition);
415  };
416 
419  {
420  public:
421 
423  InvalidOption(const char* file, int line, String option);
424  };
425 
429  {
430  public:
432  TooManyErrors(const char* file, int line);
433  };
434 
438  {
439  public:
441  TooManyBonds(const char* file, int line, const String& error);
442  };
443 
449  {
450  public:
451  CUDAError(const char* file, int line, const String& error);
452  };
453 
463  {
464  public:
465  NoBufferAvailable(const char* file, int line, const String& reason);
466  };
467 
475  {
476  public:
477  FormatUnsupported(const char* file, int line);
478  };
479 
486  {
487  public:
488  NotInitialized(const char* file, int line, const String& reason);
489  };
490 
494  {
495  public:
499 
518 
522 
524  static void setName(const String& name);
525 
527  static void setMessage(const String& message);
528 
530  static void setLine(int line);
531 
533  static void setFile(const String& file);
534 
536  static void set
537  (const String& file, int line,
538  const String& name, const String& message);
540 
541  protected:
542 
544  static void terminate();
545 
549  static void newHandler();
550 
551  static std::string file_;
552  static int line_;
553  static std::string name_;
554  static std::string message_;
555  };
556 
560 
561  }
581  std::ostream& operator << (std::ostream& os, const Exception::GeneralException& e);
582 
583 } // namespace BALL
584 
585 #ifdef BALL_COMPILER_MSVC
586  #pragma warning(pop)
587 #endif
588 
589 #endif // BALL_COMMON_EXCEPTION_H
BALL_INDEX_TYPE
BALL::Exception::GlobalExceptionHandler::name_
static std::string name_
Definition: COMMON/exception.h:553
BALL::Exception::OutOfMemory::size_
Size size_
Definition: COMMON/exception.h:326
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
BALL::Exception::IndexUnderflow::index_
Index index_
Definition: COMMON/exception.h:133
BALL::Exception::GlobalExceptionHandler::message_
static std::string message_
Definition: COMMON/exception.h:554
BALL::Exception::Postcondition
Definition: COMMON/exception.h:409
BALL::Exception::GeneralException::line_
int line_
Definition: COMMON/exception.h:108
BALL::Exception::CUDAError
Definition: COMMON/exception.h:447
BALL::Exception::SizeUnderflow
Definition: COMMON/exception.h:143
BALL::Exception::OutOfGrid
Definition: COMMON/exception.h:349
BALL::Exception::TooManyErrors
Exception to be thrown if too many errors occur, e.g. in ForceField.
Definition: COMMON/exception.h:427
BALL::Exception::GeneralException
Definition: COMMON/exception.h:59
BALL::Exception::IllegalTreeOperation
Definition: COMMON/exception.h:303
BALL::Exception::Precondition
Definition: COMMON/exception.h:398
BALL::Exception::InvalidIterator
Definition: COMMON/exception.h:268
BALL::Exception::GeneralException::file_
const char * file_
Definition: COMMON/exception.h:107
BALL_SIZE_TYPE
BALL::Exception::IllegalPosition
Definition: COMMON/exception.h:376
BALL::Exception::IllegalSelfOperation
Definition: COMMON/exception.h:247
BALL::Exception::GlobalExceptionHandler::line_
static int line_
Definition: COMMON/exception.h:552
BALL::Exception::DivisionByZero
Definition: COMMON/exception.h:340
BALL::Exception::InvalidSize
Definition: COMMON/exception.h:201
BALL::Exception::GlobalExceptionHandler
Definition: COMMON/exception.h:493
BALL::Exception::SizeUnderflow::size_
Size size_
Definition: COMMON/exception.h:151
BALL::Exception::InvalidSize::size_
Size size_
Definition: COMMON/exception.h:209
BALL
Definition: constants.h:12
BALL::Exception::InvalidArgument
Definition: COMMON/exception.h:177
BALL::Exception::FormatUnsupported
Definition: COMMON/exception.h:473
BALL::String
Definition: string.h:56
BALL::Exception::InvalidFormat::format_
std::string format_
Definition: COMMON/exception.h:239
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition: COMMON/global.h:64
BALL::Exception::NotImplemented
Definition: COMMON/exception.h:292
BALL::Exception::IndexOverflow::index_
Index index_
Definition: COMMON/exception.h:171
BALL::Exception::InvalidFormat
Definition: COMMON/exception.h:229
BALL::Exception::OutOfMemory
Definition: COMMON/exception.h:316
BALL::Exception::IncompatibleIterators
Definition: COMMON/exception.h:279
BALL::Exception::GlobalExceptionHandler::file_
static std::string file_
Definition: COMMON/exception.h:551
BALL::Exception::TooManyBonds
Exception to be thrown if too many bonds for one atom.
Definition: COMMON/exception.h:436
BALL::Exception::IndexUnderflow
Definition: COMMON/exception.h:122
BALL::Exception::NullPointer
Definition: COMMON/exception.h:258
BALL::Exception::IndexUnderflow::size_
Size size_
Definition: COMMON/exception.h:132
BALL::Exception::OutOfRange
Definition: COMMON/exception.h:217
BALL::Exception::globalHandler
BALL_EXPORT GlobalExceptionHandler globalHandler
BALL::operator<<
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
global.h
BALL::Exception::InvalidOption
Exception to be thrown if an invalid option is given.
Definition: COMMON/exception.h:418
BALL::Exception::ParseError
Definition: COMMON/exception.h:386
BALL::Exception::InvalidRange
Definition: COMMON/exception.h:187
BALL::Exception::IndexOverflow::size_
Size size_
Definition: COMMON/exception.h:170
BALL::Exception::NotInitialized
Definition: COMMON/exception.h:485
BALL::Exception::FileNotFound
Definition: COMMON/exception.h:359
BALL::Exception::BufferOverflow
Definition: COMMON/exception.h:331
BALL::RTTI::getName
const char * getName()
Definition: rtti.h:97
BALL::Exception::GeneralException::message_
std::string message_
Definition: COMMON/exception.h:111
BALL::Exception::GeneralException::name_
std::string name_
Definition: COMMON/exception.h:110
BALL::Exception::FileNotFound::filename_
std::string filename_
Definition: COMMON/exception.h:370
BALL::Exception::NoBufferAvailable
Definition: COMMON/exception.h:461
BALL::Exception::IndexOverflow
Definition: COMMON/exception.h:162