]>
Commit | Line | Data |
---|---|---|
90da00ad | 1 | #ifndef ALIHLTMUONCOREERROR_H |
2 | #define ALIHLTMUONCOREERROR_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
8356cc1d | 8 | //////////////////////////////////////////////////////////////////////////////// |
9 | // | |
10 | // Author: Artur Szostak | |
11 | // Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com | |
12 | // | |
90da00ad | 13 | // AliHLTMUONCoreError is the base excpetion class used by the dHLT subsystem. |
14 | // All child classes used to throw exception should be derived from this | |
15 | // class to allow easy catching of classes of errors. | |
16 | // | |
17 | // AliHLTMUONCoreOutOfMemory is also defined to be used when the system runs | |
18 | // out of memory. Do not throw this object directly but rather use | |
19 | // AliHLTMUONCoreThrowOutOfMemory which throws a pree allocated static object. | |
20 | // | |
8356cc1d | 21 | //////////////////////////////////////////////////////////////////////////////// |
22 | ||
8356cc1d | 23 | #include "BasicTypes.hpp" |
24 | #include <exception> | |
90da00ad | 25 | //#include <Riostream.h> |
26 | #include <ostream> | |
8356cc1d | 27 | |
8356cc1d | 28 | |
69d7cf2e | 29 | class AliHLTMUONCoreError : public std::exception |
8356cc1d | 30 | { |
3a682eae | 31 | /* Define the << operator for streams to be able to do something like: |
32 | ||
33 | Error myerror; | |
34 | cout << myerror << endl; | |
35 | */ | |
90da00ad | 36 | friend std::ostream& operator << (std::ostream& os, const AliHLTMUONCoreError& error) |
3a682eae | 37 | { |
38 | os << error.Message(); | |
39 | return os; | |
40 | }; | |
41 | ||
8356cc1d | 42 | public: |
43 | ||
69d7cf2e | 44 | AliHLTMUONCoreError() throw() {}; |
45 | virtual ~AliHLTMUONCoreError() throw() {}; | |
8356cc1d | 46 | |
47 | /* Should return a human readable string containing a description of the | |
48 | error. | |
49 | */ | |
50 | virtual const char* Message() const throw() = 0; | |
51 | ||
52 | /* Returns an error code describing the error. The error code should be | |
53 | unique to the entire system | |
54 | */ | |
55 | virtual Int ErrorCode() const throw() = 0; | |
56 | ||
57 | virtual const char* what() const throw() | |
58 | { | |
59 | return Message(); | |
60 | }; | |
8356cc1d | 61 | }; |
62 | ||
63 | ||
69d7cf2e | 64 | class AliHLTMUONCoreOutOfMemory : public AliHLTMUONCoreError |
8356cc1d | 65 | { |
66 | public: | |
67 | virtual const char* Message() const throw(); | |
68 | virtual Int ErrorCode() const throw(); | |
69 | }; | |
70 | ||
71 | ||
72 | /* When one needs to indicate that no more memory is available one should use the | |
3a682eae | 73 | AliHLTMUONCoreThrowOutOfMemory method rather than explicitly using the code |
8356cc1d | 74 | throw OutOfMemory(); |
75 | This is because the ThrowOutOfMemory routine throws a preallocated object so | |
76 | we are safe from having to allocate more (nonexistant) memory. | |
77 | */ | |
69d7cf2e | 78 | void AliHLTMUONCoreThrowOutOfMemory() throw (AliHLTMUONCoreOutOfMemory); |
8356cc1d | 79 | |
80 | ||
81 | // Error code declarations. | |
82 | enum | |
83 | { | |
3a682eae | 84 | kOutOfMemory = 0x10000001 |
8356cc1d | 85 | }; |
86 | ||
87 | ||
69d7cf2e | 88 | #endif // ALIHLTMUONCOREERROR_H |