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