00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _ERROR_H_
00029 #define _ERROR_H_
00030
00031 #include "aa_config.h"
00032 #ifdef _MSC_VER
00033 #define __PRETTY_FUNCTION__ ""
00034 #endif
00035 #include <iomanip>
00036 #include <sstream>
00037 #include <iosfwd>
00038 #include <string>
00039 #include <string.h>
00040 #if HAVE_UNISTD_H
00041
00042 #endif
00043
00044 #define tVERIFY( x ) { if ( !( x ) ){ char const * mess = "Assertion " #x " failed"; tERR_ERROR_INT( mess ); } }
00045
00046 #ifdef DEBUG
00047
00048 typedef enum {high=0,normal,low,very_low} tLevel;
00049 typedef enum {flow=0,dump} tChannel;
00050
00051 extern tLevel st_debugLevel[2];
00052
00053 int st_debugValid(tLevel l,tChannel c);
00054
00055
00056 #define tERR_DUMP(level,stream,stuff) if(st_debugValid(level,stream)) std::cout << setw(28) << __FUNCTION__ << " : " << stuff << '\n'
00057
00058 #define tERR_FLOW() if(st_debugValid(low,flow)) std::cout << std::setw(30) << __PRETTY_FUNCTION__ << '\n'
00059
00060 #define tERR_FLOW_HIGH() if(st_debugValid(normal,flow)) std::cout << std::setw(30) << __PRETTY_FUNCTION__ << '\n'
00061
00062 #define tERR_FLOW_LOW() if(st_debugValid(very_low,flow)) std::cout << std::setw(30) << __PRETTY_FUNCTION__ << '\n'
00063
00064 #define tASSERT( x ) { if ( !( x ) ){ char const * mess = "Assertion " #x " failed"; tERR_ERROR_INT( mess ); } }
00065
00066 #define tASSERT_EVAL( x ) { if ( !( x ) ){ char const * mess = "Assertion " #x " failed"; tERR_ERROR_INT( mess ); } }
00067
00068 #else
00069 #define tERR_DUMP(level,stream,stuff)
00070 #define tERR_FLOW()
00071 #define tERR_FLOW_HIGH()
00072 #define tERR_FLOW_LOW()
00073 #define tASSERT( x )
00074 #define tASSERT_EVAL( x ) x
00075 #endif
00076
00077
00078
00079 void st_Breakpoint();
00080
00081 void st_PresentError( const char* caption, const char *message );
00082 void st_PresentMessage( const char* caption, const char *message );
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 #define tERR_ERROR_INT(mess) { std::ostringstream s; s << "Internal error in " << __PRETTY_FUNCTION__ << " in " << __FILE__<< ':' << __LINE__ << " : \n \t" << mess << "\nPlease send a Bug report!" << '\0'; st_PresentError( "Internal Error", s.str().c_str() );}
00103
00104 #define tERR_ERROR(mess) { std::ostringstream s; s << "Error in " << __PRETTY_FUNCTION__ << " in " << __FILE__<< ':' << __LINE__ << " : \n \t" << mess << '\n'; st_PresentError( "Error", s.str().c_str() ); }
00105
00106 #define tERR_MESSAGE(mess) { std::ostringstream s; s << "Message from " << __PRETTY_FUNCTION__ << " in " << __FILE__<< ':' << __LINE__ << " : \n \t" << mess << '\n'; st_PresentMessage( "Message", s.str().c_str() ); }
00107
00108 #define tERR_WARN(mess) {con << "Warning in " << __PRETTY_FUNCTION__ << " in " << __FILE__<< ':' << __LINE__ << " : \n \t" << mess << '\n';}
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 #endif // _ERROR_H_
00119