debug.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: debug.h,v 1.10 2004/02/23 21:35:17 anhi Exp $
00005 //
00006 
00007 #ifndef BALL_COMMON_DEBUG_H
00008 #define BALL_COMMON_DEBUG_H
00009 
00010 #ifndef BALL_CONFIG_CONFIG_H
00011 # include <BALL/CONFIG/config.h>
00012 #endif
00013 
00014 #ifdef BALL_NO_INLINE_FUNCTIONS
00015 # define BALL_INLINE
00016 #else
00017 # define BALL_INLINE inline
00018 #endif
00019 
00020 #include <string>
00021 
00022 #ifdef BALL_DEBUG
00023 
00024 # define BALL_PRECONDITION_EXCEPTION(condition, message)\
00025   if (!(condition))\
00026   {\
00027     Exception::Precondition e(__FILE__, __LINE__, #condition);\
00028     if (message != "")\
00029     {\
00030       ::std::string tmp(e.getMessage());\
00031       tmp += ::std::string(message);\
00032       e.setMessage(tmp);\
00033     }\
00034     throw e;\
00035   }\
00036 
00037 # define BALL_POSTCONDITION_EXCEPTION(condition, message)\
00038   if (!(condition))\
00039   {\
00040     Exception::Postcondition e(__FILE__, __LINE__, #condition);\
00041     if (message != "")\
00042     {\
00043       std::string tmp(e.getMessage());\
00044       tmp += std::string(message);\
00045       e.setMessage(tmp);\
00046     }\
00047     throw e;\
00048   }\
00049 
00050 #else
00051 
00052 # define BALL_PRECONDITION_EXCEPTION(condition, message)
00053 # define BALL_POSTCONDITION_EXCEPTION(condition, message)
00054 
00055 #endif // BALL_DEBUG
00056 
00057 #endif // BALL_COMMON_DEBUG_H