00001
00040 #ifndef __DEBUG_H__
00041 #define __DEBUG_H__
00042
00043 #ifdef _DEBUG
00044
00045 #include <stdlib.h>
00046 #include <iostream.h>
00047 #include <assert.h>
00048
00049 #define DBG_LINE { cerr << endl << "DBG_LINE " << __LINE__ << " at " << __FILE__ << endl; cerr.flush(); }
00050
00051 #define DBG_MSG(A) { cerr << endl << __FILE__ << "/" << __LINE__ << ':' << (A) << endl; cerr.flush(); }
00052
00053 #define DBG_MSG1(A,B) { cerr << endl << __FILE__ << "/" << __LINE__ << ':' << (A) << " (" << (B) << ')' << endl; cerr.flush(); }
00054
00055 #define DBG_MSG2(A,B,C) { cerr << endl << __FILE__ << "/" << __LINE__ << ':' << (A) << " (" << (B) << ", " << (C) << ')' << endl; cerr.flush(); }
00056
00057 #define DBG_SHOW(A) { cerr << endl << __FILE__ << "/" << __LINE__ << ':' << (A) << endl; cerr.flush(); }
00058 #define DBG_VAL(A) { cerr << endl << #A << " = " << (A) << endl; cerr.flush(); }
00059
00060 #define ASSERT(X) \
00061 if(!(X)) { \
00062 cerr << "ERROR: Assertion failed \"" << #X << "\" in " __FILE__ << ':' << __LINE__ << endl; \
00063 cerr.flush(); \
00064 assert(false); \
00065 }
00066
00067 #define WARNING(X, M) \
00068 if(X) { \
00069 cerr << "WARNING! " << M << ": \"" << #X << "\" in " __FILE__ << ':' << __LINE__ << endl << flush; \
00070 }
00071
00072
00073 #define ASSERT_VALID_NUM(A) ASSERT(!isnan(A) && finite(A))
00074
00075 #else
00076 #define DBG_LINE
00077 #define DBG_MSG(A)
00078 #define DBG_SHOW(A)
00079 #define ASSERT(X)
00080 #define WARNING(X, M)
00081
00082 #endif //_DEBUG
00083
00084 #endif //__DEBUG_H__