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 
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:
326  Size size_;
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 
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::Exception::CUDAError::CUDAError
CUDAError(const char *file, int line, const String &error)
BALL::Exception::SizeUnderflow::SizeUnderflow
SizeUnderflow(const char *file, int line, Size size=0)
BALL_EXPORT
#define BALL_EXPORT
Definition: COMMON/global.h:50
global.h
BALL::Exception::NoBufferAvailable::NoBufferAvailable
NoBufferAvailable(const char *file, int line, const String &reason)
BALL::Exception::InvalidIterator
Definition: COMMON/exception.h:270
BALL::Exception::GeneralException::~GeneralException
virtual ~GeneralException()
Destructor.
BALL::Exception::DivisionByZero::DivisionByZero
DivisionByZero(const char *file, int line)
BALL::Exception::InvalidFormat::InvalidFormat
InvalidFormat(const char *file, int line, const String &s)
BALL::Exception::FileNotFound::FileNotFound
FileNotFound(const char *file, int line, const String &filename)
BALL::Exception::SizeUnderflow
Definition: COMMON/exception.h:145
BALL::Exception::CUDAError
Definition: COMMON/exception.h:449
BALL::Exception::IllegalSelfOperation
Definition: COMMON/exception.h:249
BALL::Exception::InvalidSize
Definition: COMMON/exception.h:203
BALL::Exception::Postcondition
Definition: COMMON/exception.h:411
BALL::Exception::OutOfMemory::OutOfMemory
OutOfMemory(const char *file, int line, Size size=0)
BALL::Exception::GlobalExceptionHandler
Definition: COMMON/exception.h:494
BALL::Exception::IllegalPosition
Definition: COMMON/exception.h:378
BALL::Exception::GeneralException::GeneralException
GeneralException(const char *file, int line)
Constructor.
BALL::Exception::Precondition::Precondition
Precondition(const char *file, int line, const char *condition)
BALL::Exception::Postcondition::Postcondition
Postcondition(const char *file, int line, const char *condition)
BALL::Exception::GlobalExceptionHandler::terminate
static void terminate()
The BALL replacement for terminate.
BALL::Exception::InvalidArgument
Definition: COMMON/exception.h:179
BALL::Exception::FormatUnsupported
Definition: COMMON/exception.h:475
BALL::Exception::OutOfMemory::~OutOfMemory
virtual ~OutOfMemory()
BALL::Exception::TooManyErrors::TooManyErrors
TooManyErrors(const char *file, int line)
BALL::Exception::IndexUnderflow
Definition: COMMON/exception.h:124
BALL::Exception::OutOfGrid
Definition: COMMON/exception.h:351
BALL::Exception::TooManyBonds
Exception to be thrown if too many bonds for one atom.
Definition: COMMON/exception.h:438
BALL::Exception::OutOfMemory
Definition: COMMON/exception.h:318
BALL::Exception::GlobalExceptionHandler::newHandler
static void newHandler()
BALL::Exception::NullPointer::NullPointer
NullPointer(const char *file, int line)
BALL::Exception::NotImplemented
Definition: COMMON/exception.h:294
BALL::Exception::ParseError::ParseError
ParseError(const char *file, int line, const String &expression, const String &message)
BALL::String
Definition: string.h:57
BALL::Exception::GlobalExceptionHandler::message_
static std::string message_
Definition: COMMON/exception.h:554
BALL::Exception::GlobalExceptionHandler::name_
static std::string name_
Definition: COMMON/exception.h:553
BALL
Definition: constants.h:13
BALL::Exception::GlobalExceptionHandler::set
static void set(const String &file, int line, const String &name, const String &message)
Set all exception attributes.
BALL::Exception::GlobalExceptionHandler::file_
static std::string file_
Definition: COMMON/exception.h:551
BALL::Exception::Precondition
Definition: COMMON/exception.h:400
BALL::Exception::IllegalSelfOperation::IllegalSelfOperation
IllegalSelfOperation(const char *file, int line)
BALL::Exception::GeneralException::GeneralException
GeneralException(const GeneralException &exception)
Copy constructor.
BALL::Exception::GlobalExceptionHandler::setFile
static void setFile(const String &file)
The source file name where the exception was thrown.
BALL::Exception::GlobalExceptionHandler::GlobalExceptionHandler
GlobalExceptionHandler()
BALL::Exception::IncompatibleIterators::IncompatibleIterators
IncompatibleIterators(const char *file, int line)
BALL::Exception::DivisionByZero
Definition: COMMON/exception.h:342
BALL_INDEX_TYPE
BALL::Exception::InvalidOption
Exception to be thrown if an invalid option is given.
Definition: COMMON/exception.h:419
BALL_SIZE_TYPE
BALL::Exception::InvalidSize::InvalidSize
InvalidSize(const char *file, int line, Size size=0)
BALL::Exception::ParseError
Definition: COMMON/exception.h:388
BALL::Exception::BufferOverflow::BufferOverflow
BufferOverflow(const char *file, int line)
BALL::Exception::GlobalExceptionHandler::setName
static void setName(const String &name)
Assign the name of the exception. This should agree with the class name.
BALL::Exception::InvalidFormat::~InvalidFormat
~InvalidFormat()
BALL::Exception::GlobalExceptionHandler::line_
static int line_
Definition: COMMON/exception.h:552
BALL::Exception::FormatUnsupported::FormatUnsupported
FormatUnsupported(const char *file, int line)
BALL::Exception::NullPointer
Definition: COMMON/exception.h:260
BALL::Exception::InvalidIterator::InvalidIterator
InvalidIterator(const char *file, int line)
BALL::Exception::FileNotFound
Definition: COMMON/exception.h:361
BALL::Exception::IllegalPosition::IllegalPosition
IllegalPosition(const char *file, int line, float x, float y, float z)
BALL::Exception::NotInitialized::NotInitialized
NotInitialized(const char *file, int line, const String &reason)
BALL::Exception::BufferOverflow
Definition: COMMON/exception.h:333
BALL::Exception::IndexUnderflow::index_
Index index_
Definition: COMMON/exception.h:133
BALL::Exception::FileNotFound::~FileNotFound
~FileNotFound()
BALL::Exception::InvalidFormat
Definition: COMMON/exception.h:231
BALL::Exception::InvalidRange
Definition: COMMON/exception.h:189
BALL::Exception::NotInitialized
Definition: COMMON/exception.h:486
BALL::Exception::GeneralException::GeneralException
GeneralException()
Default constructor.
BALL::Exception::IllegalTreeOperation
Definition: COMMON/exception.h:305
BALL::Exception::IndexUnderflow::IndexUnderflow
IndexUnderflow(const char *file, int line, Index index=0, Size size=0)
BALL::Exception::globalHandler
BALL_EXPORT GlobalExceptionHandler globalHandler
BALL::Exception::IndexOverflow::size_
Size size_
Definition: COMMON/exception.h:170
BALL::Exception::GlobalExceptionHandler::setMessage
static void setMessage(const String &message)
Set the error message.
BALL::operator<<
BALL_EXPORT std::ostream & operator<<(std::ostream &os, const Exception::GeneralException &e)
BALL::Exception::SizeUnderflow::size_
Size size_
Definition: COMMON/exception.h:151
BALL::Exception::InvalidSize::size_
Size size_
Definition: COMMON/exception.h:209
BALL::Exception::InvalidArgument::InvalidArgument
InvalidArgument(const char *file, int line, const String &arg)
BALL::Exception::IndexOverflow::index_
Index index_
Definition: COMMON/exception.h:171
BALL::Exception::IndexOverflow
Definition: COMMON/exception.h:164
BALL::Exception::NoBufferAvailable
Definition: COMMON/exception.h:463
BALL::Exception::IndexUnderflow::size_
Size size_
Definition: COMMON/exception.h:132
BALL::Exception::GeneralException
Definition: COMMON/exception.h:61
BALL::Exception::GeneralException::GeneralException
GeneralException(const char *file, int line, const String &name, const String &message)
Constructor.
BALL::Exception::TooManyErrors
Exception to be thrown if too many errors occur, e.g. in ForceField.
Definition: COMMON/exception.h:429
BALL::Exception::NotImplemented::NotImplemented
NotImplemented(const char *file, int line)
BALL::Exception::IndexOverflow::IndexOverflow
IndexOverflow(const char *file, int line, Index index=0, Size size=0)
BALL::Exception::InvalidRange::InvalidRange
InvalidRange(const char *file, int line, float value)
BALL::Exception::IncompatibleIterators
Definition: COMMON/exception.h:281
BALL::RTTI::getName
const char * getName()
Definition: rtti.h:97
BALL::Exception::IllegalTreeOperation::IllegalTreeOperation
IllegalTreeOperation(const char *file, int line)
BALL::Exception::OutOfRange::OutOfRange
OutOfRange(const char *file, int line)
BALL::Exception::OutOfGrid::OutOfGrid
OutOfGrid(const char *file, int line)
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition: COMMON/global.h:64
BALL::Exception::TooManyBonds::TooManyBonds
TooManyBonds(const char *file, int line, const String &error)
BALL::Exception::InvalidOption::InvalidOption
InvalidOption(const char *file, int line, String option)
BALL::Exception::GlobalExceptionHandler::setLine
static void setLine(int line)
Set the line number the exception was thrown. Should be set to LINE in most cases.
BALL::Exception::OutOfRange
Definition: COMMON/exception.h:219