00001 #ifndef NMWR_GB_PRE_POST_CONDITION_H
00002 #define NMWR_GB_PRE_POST_CONDITION_H
00003
00004
00005
00006
00007
00008 #include <iostream.h>
00009 #include <stdlib.h>
00010
00012
00013
00032
00033
00034
00035 #define _ERRORLOG cerr
00036
00037 #define _PRECONDITION_ERROR _ERRORLOG << "\nERROR in FILE " << __FILE__ << ", LINE " << __LINE__\
00038 << "\n(compiled on " << __DATE__ << " at " __TIME__ << " )\n"\
00039 << "precondition violated:\n"
00040
00041 #define _POSTCONDITION_ERROR _ERRORLOG << "\nERROR in FILE " << __FILE__ << ", LINE " << __LINE__\
00042 << "\n(compiled on " << __DATE__ << " at " __TIME__ << " )\n"\
00043 << ": postcondition violated:\n"
00044
00045 #define REQUIRE_ALWAYS(condition, error_msg, severity)\
00046 if(! (condition)) { _PRECONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
00047
00048 #define ENSURE_ALWAYS(condition, error_msg, severity)\
00049 if(! (condition)) { _POSTCONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
00050
00051 #ifdef NMWR_DEBUG
00052
00053 #define REQUIRE(condition, error_msg, severity)\
00054 if(! (condition)) { _PRECONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
00055
00056 #define ENSURE(condition, error_msg, severity)\
00057 if(! (condition)) { _POSTCONDITION_ERROR << #condition << ' ' << error_msg << endl; abort();}
00058
00059 #else
00060 #define REQUIRE(condition, error_msg, severity)
00061 #define ENSURE(condition, error_msg, severity)
00062 #endif
00063
00065
00066
00067
00068
00069
00070 #endif