designbycontract.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef DESIGNBYCONTRACT_H
00023
#define DESIGNBYCONTRACT_H
00024
00026
00031 class DesignByContract {
00032
00033
public:
00034
00035
#ifndef NDEBUG
00036
virtual bool isValid()
const;
00037
00038
static void __throw_error_(
const char *file,
const int line,
00039
const char *expr,
const char *type);
00040
00041
static void DesignByContract::__report_Message_(
const char *file,
const int line,
const char *msg);
00042
00043
#endif
00044
00045 };
00046
00047
00048
00049
00050
00051
#ifndef NDEBUG
00052
00053
#define ASSERT__(type,expr) if (!(expr)) DesignByContract::__throw_error_(__FILE__, __LINE__, #expr,type)
00054
00055
#define ASSERT(expr) ASSERT__("ASSERTION",expr)
00056
#define IS_VALID(obj) ASSERT__("CONSTISTENCY CHECK",(obj) != NULL && (obj)->isValid())
00057
#define IS_VALID_REF(obj) ASSERT__("CONSTISTENCY CHECK",(obj).isValid())
00058
#define REQUIRE(expr) ASSERT__("PRE-CONDITION",expr)
00059
#define ENSURE(expr) ASSERT__("POST-CONDITION",expr)
00060
00061
#define MESSAGE(msg) DesignByContract::__report_Message_(__FILE__,__LINE__,msg)
00062
00063
#else
00064
00065
00066
00067
00068
#define ASSERT(expr) ((void) 0)
00069
#define IS_VALID(expr) ((void) 0)
00070
#define IS_VALID_REF(expr) ((void) 0)
00071
#define REQUIRE(expr) ((void) 0)
00072
#define ENSURE(expr) ((void) 0)
00073
00074
#define MESGAGE(msg) ((void) 0)
00075
00076
#endif
00077
00078
#endif
Generated on Tue Mar 22 19:07:05 2005 for freesteam by
1.3.8