00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __IPDEBUG_HPP__
00010 #define __IPDEBUG_HPP__
00011
00012 #include "IpoptConfig.h"
00013 #include "IpTypes.hpp"
00014
00015 #ifdef HAVE_CASSERT
00016 # include <cassert>
00017 #else
00018 # ifdef HAVE_ASSERT_H
00019 # include <assert.h>
00020 # else
00021 # error "don't have header file for assert"
00022 # endif
00023 #endif
00024
00025 #if COIN_IPOPT_CHECKLEVEL > 0
00026 # ifdef NDEBUG
00027 # undef NDEBUG
00028 # endif
00029 # define DBG_ASSERT(test) assert(test)
00030 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
00031 ASSERT_EXCEPTION( (__condition), __except_type, __msg);
00032 # define DBG_DO(__cmd) __cmd
00033 #else
00034 # define DBG_ASSERT(test)
00035 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
00036 # define DBG_DO(__cmd)
00037 #endif
00038
00039 #if COIN_IPOPT_VERBOSITY < 1
00040 # define DBG_START_FUN(__func_name, __verbose_level)
00041 # define DBG_START_METH(__func_name, __verbose_level)
00042 # define DBG_PRINT(__printf_args)
00043 # define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
00044 # define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
00045 # define DBG_EXEC(__verbosity, __cmd)
00046 # define DBG_VERBOSITY() 0
00047 #else
00048 #include <string>
00049
00050 namespace Ipopt
00051 {
00052
00053 class Journalist;
00054
00059 class DebugJournalistWrapper
00060 {
00061 public:
00064 DebugJournalistWrapper(std::string func_name, Index verbose_level);
00065 DebugJournalistWrapper(std::string func_name, Index verbose_level,
00066 const void* const method_owner);
00067 ~DebugJournalistWrapper();
00069
00072 Index Verbosity()
00073 {
00074 return verbose_level_;
00075 }
00076 const Journalist* Jnlst()
00077 {
00078 return jrnl_;
00079 }
00080 Index IndentationLevel()
00081 {
00082 return indentation_level_;
00083 }
00085
00087 void DebugPrintf(Index verbosity, const char* pformat, ...);
00088
00089
00090
00091
00092 static void SetJournalist(Journalist* jrnl);
00093
00094 private:
00104 DebugJournalistWrapper();
00105
00107 DebugJournalistWrapper(const DebugJournalistWrapper&);
00108
00110 DebugJournalistWrapper& operator=(const DebugJournalistWrapper&);
00112
00113 static Index indentation_level_;
00114 std::string func_name_;
00115 Index verbose_level_;
00116 const void* method_owner_;
00117
00118 static Journalist* jrnl_;
00119 };
00120 }
00121
00122 # define DBG_START_FUN(__func_name, __verbose_level) \
00123 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
00124
00125 # define DBG_START_METH(__func_name, __verbose_level) \
00126 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
00127
00128 # define DBG_PRINT(__args) \
00129 dbg_jrnl.DebugPrintf __args;
00130
00131 # define DBG_EXEC(__verbose_level, __cmd) \
00132 if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
00133 (__cmd); \
00134 }
00135
00136 # define DBG_VERBOSITY() \
00137 dbg_jrnl.Verbosity()
00138
00139 #endif
00140
00141
00142 #endif