00001 /*************** 00002 Copyright (C) 2000-2006 by James Nutaro 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Lesser General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public 00015 License along with this library; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 Bugs, comments, and questions can be sent to nutaro@gmail.com 00019 ***************/ 00020 00021 #ifndef _adevs_exception_h_ 00022 #define _adevs_exception_h_ 00023 #include <string> 00024 #include <exception> 00025 00026 namespace adevs 00027 { 00028 00033 class exception: public std::exception 00034 { 00035 public: 00041 exception(const char* msg, void* model = NULL): 00042 std::exception(), 00043 msg(msg), 00044 model(model) 00045 {} 00047 exception(const adevs::exception& src): 00048 std::exception(src), 00049 msg(src.msg), 00050 model(src.model) 00051 {} 00053 const char* what() const throw() 00054 { 00055 return msg.c_str(); 00056 } 00058 void* who() const { return model; } 00060 ~exception() throw(){} 00061 private: 00062 std::string msg; 00063 void* model; 00064 }; 00065 00070 class method_not_supported_exception: 00071 public exception 00072 { 00073 public: 00078 method_not_supported_exception(const char* method, void* model): 00079 exception((std::string("Unsupported method: ")+std::string(method)).c_str(), 00080 model) 00081 { 00082 } 00083 }; 00084 00089 class lookahead_impossible_exception: 00090 public exception 00091 { 00092 public: 00093 lookahead_impossible_exception(): 00094 exception("Lookahead cannot proceed") 00095 { 00096 } 00097 }; 00098 00099 } // end of namespace 00100 00101 #endif 00102