EvolvingObjects
|
00001 /* 00002 (c) Thales group, 2010 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; 00007 version 2 of the License. 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 Contact: http://eodev.sourceforge.net 00019 00020 Authors: 00021 Johann Dréo <johann.dreo@thalesgroup.com> 00022 */ 00023 00024 #ifndef __eoExceptions_h__ 00025 #define __eoExceptions_h__ 00026 00027 #include <ctime> 00028 #include <stdexcept> 00029 00030 class eoMaxException : public std::exception {}; 00031 00032 00033 00041 class eoMaxTimeException : public eoMaxException 00042 { 00043 public: 00044 eoMaxTimeException( time_t elapsed) : _elapsed(elapsed) {} 00045 00046 virtual const char* what() const throw() 00047 { 00048 std::ostringstream ss; 00049 ss << "STOP in eoMaxTimeException: the maximum number of allowed seconds has been reached (" << _elapsed << ")."; 00050 return ss.str().c_str(); 00051 } 00052 00053 private: 00054 time_t _elapsed; 00055 }; 00056 00057 00065 class eoMaxEvalException : public eoMaxException 00066 { 00067 public: 00068 eoMaxEvalException(unsigned long threshold) : _threshold(threshold){} 00069 00070 virtual const char* what() const throw() 00071 { 00072 std::ostringstream ss; 00073 ss << "STOP in eoMaxEvalException: the maximum number of evaluation has been reached (" << _threshold << ")."; 00074 return ss.str().c_str(); 00075 } 00076 00077 private: 00078 unsigned long _threshold; 00079 }; 00080 00081 00089 class eoMissingParamException : public std::exception 00090 { 00091 public: 00092 eoMissingParamException(std::string name) : _name(name){} 00093 00094 virtual const char* what() const throw() 00095 { 00096 std::ostringstream ss; 00097 ss << "The command parameter " << _name << " has not been declared"; 00098 return ss.str().c_str(); 00099 } 00100 00101 ~eoMissingParamException() throw() {} 00102 00103 private: 00104 std::string _name; 00105 }; 00106 00114 class eoWrongParamTypeException : public std::exception 00115 { 00116 public: 00117 eoWrongParamTypeException(std::string name) : _name(name){} 00118 00119 virtual const char* what() const throw() 00120 { 00121 std::ostringstream ss; 00122 ss << "You asked for the parameter " << _name << " but it has not been declared under this type"; 00123 return ss.str().c_str(); 00124 } 00125 00126 ~eoWrongParamTypeException() throw() {} 00127 00128 private: 00129 std::string _name; 00130 }; 00131 00132 #endif // __eoExceptions_h__