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
00029
00044 #ifndef MAT_DEBUGPOLICIES
00045 #define MAT_DEBUGPOLICIES
00046
00047 #include <cstdlib>
00048
00049 namespace mat{
00050 #if 0
00051 #define ASSERTALWAYS(x) \
00052 this->assertAlways(__FILE__, __LINE__, __DATE__, __TIME__,x)
00053 #define ASSERTDEBUG(x) \
00054 this->assertDebug(__FILE__, __LINE__, __DATE__, __TIME__,x)
00055
00056
00057 class DebugLevelHigh {
00058 public:
00059 void assertAlways(char const * theFile, int const theLine,
00060 char const * theDate, char const * theTime,
00061 bool const statement) const {
00062 if (!statement) {
00063 std::cout<<"Assertion failed: "<<theFile<<":"<<theLine
00064 <<" Compiled on "<<theDate<<" at "<<theTime<<".\n";
00065 std::exit(1);
00066 }
00067 }
00068 inline void assertDebug(char const * theFile, int const theLine,
00069 char const * theDate, char const * theTime,
00070 bool const statement) const {
00071 assertAlways(theFile, theLine, theDate, theTime, statement);
00072 }
00073 };
00074 class DebugLevelMedium : public DebugLevelHigh {};
00075 class DebugLevelLow : public DebugLevelMedium {
00076 public:
00077 inline void assertDebug(char const * theFile, int const theLine,
00078 char const * theDate, char const * theTime,
00079 bool const statement) const {}
00080 };
00081
00082 #else
00083
00084
00085 #define ASSERTALWAYS(x) \
00086 this->assertAlways(__FILE__, __LINE__, __ID__,x)
00087 #define ASSERTDEBUG(x) \
00088 this->assertDebug(__FILE__, __LINE__, __ID__,x)
00089 #endif
00090
00091 class DebugLevelHigh {
00092 public:
00093 void assertAlways(char const * theFile, int const theLine,
00094 char const * theId, bool const statement) const {
00095 if (!statement) {
00096 std::cout<<"Assertion failed: "<<theFile<<":"<<theLine
00097 <<" svn info: "<<theId<<".\n";
00098 std::exit(1);
00099 }
00100 }
00101 inline void assertDebug(char const * theFile, int const theLine,
00102 char const * theId, bool const statement) const {
00103 assertAlways(theFile, theLine, theId, statement);
00104 }
00105 };
00106 class DebugLevelMedium : public DebugLevelHigh {};
00107 class DebugLevelLow : public DebugLevelMedium {
00108 public:
00109 inline void assertDebug(char const * theFile, int const theLine,
00110 char const * theId, bool const statement) const {}
00111 };
00112
00113
00114
00115 }
00116 #endif