00001 00031 #ifndef _adevs_exception_h_ 00032 #define _adevs_exception_h_ 00033 #include <string> 00034 #include <exception> 00035 00036 namespace adevs 00037 { 00038 00043 class exception: public std::exception 00044 { 00045 public: 00051 exception(const char* msg, void* model = NULL): 00052 std::exception(), 00053 msg(msg), 00054 model(model) 00055 {} 00057 exception(const adevs::exception& src): 00058 std::exception(src), 00059 msg(src.msg), 00060 model(src.model) 00061 {} 00063 const char* what() const throw() 00064 { 00065 return msg.c_str(); 00066 } 00068 void* who() const { return model; } 00070 ~exception() throw(){} 00071 private: 00072 std::string msg; 00073 void* model; 00074 }; 00075 00080 class method_not_supported_exception: 00081 public exception 00082 { 00083 public: 00088 method_not_supported_exception(const char* method, void* model): 00089 exception((std::string("Unsupported method: ")+std::string(method)).c_str(), 00090 model) 00091 { 00092 } 00093 }; 00094 00099 class lookahead_impossible_exception: 00100 public exception 00101 { 00102 public: 00103 lookahead_impossible_exception(): 00104 exception("Lookahead cannot proceed") 00105 { 00106 } 00107 }; 00108 00109 } // end of namespace 00110 00111 #endif 00112