00001 /* -*- mode: c++ -*- */ 00002 #ifndef __DAQpp__execption_h__ 00003 #define __DAQpp__execption_h__ 00004 00005 #include <exception> 00006 #include <iosfwd> 00007 #include <string> 00008 namespace DAQpp 00009 { 00016 class Exception : public std::exception 00017 { 00018 protected: 00020 std::string _why; 00021 public: 00023 Exception(); 00024 00026 Exception(const Exception &e); 00027 00029 virtual ~Exception() throw(); 00033 const char* what() const throw(); 00034 }; 00035 00042 class ParameterException : public Exception 00043 { 00044 protected: 00046 std::string name; 00047 public: 00049 ParameterException(const std::string &name); 00050 00052 ParameterException(const ParameterException &e); 00053 00055 ~ParameterException() throw() ; 00056 00058 std::string get_name() const 00059 { 00060 return name; 00061 } 00062 00064 const char* what() const throw(); 00065 }; 00066 00073 class ParameterNonExistent : public ParameterException 00074 { 00075 public: 00077 ParameterNonExistent(const std::string &name); 00078 00080 ParameterNonExistent(const ParameterNonExistent &e) 00081 : ParameterException(e) 00082 {} 00083 }; 00084 00091 class ParameterTypeDoesNotMatch : public ParameterException 00092 { 00093 public: 00095 ParameterTypeDoesNotMatch(const std::string &name); 00096 00098 ParameterTypeDoesNotMatch(const ParameterTypeDoesNotMatch &e) 00099 : ParameterException(e) 00100 {} 00101 }; 00102 00103 } 00104 00106 std::ostream &operator<<( std::ostream &os, const DAQpp::Exception &ex); 00107 00108 #endif 00109