An Implementation of the Marching Cubes Algorithm
1.0
|
00001 00025 #ifndef EXCEPTIONOBJECT_HPP 00026 #define EXCEPTIONOBJECT_HPP 00027 00028 #include <iostream> // std::cout, std::endl 00029 #include <string> // std::string 00030 #include <stdexcept> // std::exception 00031 00032 00040 #define treat_exception( e ) \ 00041 std::cout << "Exception: " << e.get_description() << std::endl \ 00042 << "File: " << e.get_file() << std::endl \ 00043 << "Line: " << e.get_line() << std::endl 00044 00045 00046 00061 namespace common { 00062 00063 00070 class ExceptionObject : public std::exception { 00071 public: 00072 // --------------------------------------------------------------- 00073 // 00074 // Public methods 00075 // 00076 // --------------------------------------------------------------- 00077 00088 ExceptionObject( 00089 const char *file = "Unknown" , 00090 unsigned int line = 0 , 00091 const char *desc = "None" 00092 ) 00093 { 00094 _file = file ; 00095 _desc = desc ; 00096 _line = line ; 00097 } 00098 00099 00110 ExceptionObject( 00111 const std::string& file , 00112 unsigned int line , 00113 const std::string& desc = "None" 00114 ) 00115 { 00116 _file = file ; 00117 _desc = desc ; 00118 _line = line ; 00119 } 00120 00121 00130 ExceptionObject( const ExceptionObject &xpt ) : exception() 00131 { 00132 _file = xpt._file ; 00133 _desc = xpt._desc ; 00134 _line = xpt._line ; 00135 } 00136 00137 00143 virtual ~ExceptionObject() throw() 00144 { 00145 } 00146 00147 00155 ExceptionObject& operator=( const ExceptionObject &xpt ) 00156 { 00157 _desc = xpt._desc ; 00158 _file = xpt._file ; 00159 _line = xpt._line ; 00160 00161 return *this ; 00162 } 00163 00164 00172 virtual const char* get_name_of_class() const 00173 { 00174 return "ExceptionObject" ; 00175 } 00176 00177 00185 virtual void set_description( const std::string& s ) 00186 { 00187 _desc = s ; 00188 } 00189 00190 00198 virtual void set_description( const char *s ) 00199 { 00200 _desc = s ; 00201 } 00202 00203 00211 virtual const char* get_description() const 00212 { 00213 return _desc.c_str() ; 00214 } 00215 00216 00226 virtual const char* get_file() const 00227 { 00228 return _file.c_str() ; 00229 } 00230 00231 00239 virtual unsigned int get_line() const 00240 { 00241 return _line ; 00242 } 00243 00244 00252 virtual const char* what() const throw() 00253 { 00254 return _desc.c_str() ; 00255 } 00256 00257 00258 private: 00259 // ----------------------------------------------------------------- 00260 // 00261 // Private attributes 00262 // 00263 // ----------------------------------------------------------------- 00264 00265 std::string _desc ; 00266 std::string _file ; 00267 unsigned int _line ; 00268 00269 } ; 00270 00271 00272 } // end of namespace common 00273 00274 //end of group class. 00276 00277 00278 #endif // EXCEPTIONOBJECT_HPP 00279