00001 00007 /* Copyright (C) 2005 - 2009, Bernd Speiser */ 00008 /* This file is part of Quantity. 00009 00010 Quantity is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU General Public License 00012 as published by the Free Software Foundation; either version 2 00013 of the License, or (at your option) any later version. 00014 00015 Quantity is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00023 02111-1307, USA. 00024 */ 00025 00026 #ifndef _QuantityError_h 00027 #define _QuantityError_h 00028 00029 //STL includes 00030 #include <string> 00031 00032 namespace quantity 00033 { 00034 00036 // 00037 // exception classes 00038 // 00040 00042 00046 class QuantityError 00047 { 00048 public: 00049 QuantityError( const std::string& message ) 00050 : _message( message ) 00051 {} 00052 virtual ~QuantityError(){} 00053 00054 virtual std::string message() const 00055 { 00056 return _message; 00057 } 00058 00059 00060 protected: 00061 std::string _message; 00062 00063 }; 00064 00066 00068 class InputError : public QuantityError 00069 { 00070 private: 00072 static const std::string INPUT_ERROR; 00073 00074 public: 00076 00078 InputError (void) : QuantityError (INPUT_ERROR) {} 00079 00081 00083 InputError (const std::string message) : QuantityError (message) {} 00084 }; 00085 00087 00090 class DimensionMismatch : public QuantityError 00091 { 00092 private: 00094 static const std::string DIMENSION_MISMATCH; 00095 00096 public: 00098 00100 DimensionMismatch (void) : QuantityError (DIMENSION_MISMATCH) {} 00101 00103 00105 DimensionMismatch (const std::string message) 00106 : QuantityError (message) {} 00107 }; 00108 00110 00114 class VectorOutOfBounds : public QuantityError 00115 { 00116 private: 00118 static const std::string VECTOR_OUT_OF_BOUNDS; 00119 00120 public: 00122 00124 VectorOutOfBounds (void) : QuantityError (VECTOR_OUT_OF_BOUNDS) {} 00125 00127 00129 VectorOutOfBounds (const std::string message) 00130 : QuantityError (message) {} 00131 }; 00132 00134 00139 class VectorSizeError : public QuantityError 00140 { 00141 private: 00143 static const std::string VECTOR_SIZE_ERROR; 00144 00145 public: 00147 00149 VectorSizeError (void) : QuantityError (VECTOR_SIZE_ERROR) {} 00150 00152 00154 VectorSizeError (const std::string message) 00155 : QuantityError (message) {} 00156 }; 00157 00159 00163 class LoadError : public QuantityError 00164 { 00165 private: 00167 static const std::string LOADERROR; 00168 00169 public: 00171 00173 LoadError (void) : QuantityError (LOADERROR) {} 00174 00176 00178 LoadError (const std::string message) : QuantityError (message) {} 00179 }; 00180 00181 00182 } // namespace quantity 00183 00184 #endif // _QuantityError_h 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197