Go to the documentation of this file.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 COIN_IPOPT_CHECKLEVEL
00016 #ifdef HAVE_CASSERT
00017 # include <cassert>
00018 #else
00019 # ifdef HAVE_ASSERT_H
00020 # include <assert.h>
00021 # else
00022 # error "don't have header file for assert"
00023 # endif
00024 #endif
00025 #else
00026 #define COIN_IPOPT_CHECKLEVEL 0
00027 #endif
00028
00029 #if COIN_IPOPT_CHECKLEVEL > 0
00030 # ifdef NDEBUG
00031 # undef NDEBUG
00032 # endif
00033 # define DBG_ASSERT(test) assert(test)
00034 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
00035 ASSERT_EXCEPTION( (__condition), __except_type, __msg);
00036 # define DBG_DO(__cmd) __cmd
00037 #else
00038 # define DBG_ASSERT(test)
00039 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
00040 # define DBG_DO(__cmd)
00041 #endif
00042
00043 #ifndef COIN_IPOPT_VERBOSITY
00044 #define COIN_IPOPT_VERBOSITY 0
00045 #endif
00046
00047 #if COIN_IPOPT_VERBOSITY < 1
00048 # define DBG_START_FUN(__func_name, __verbose_level)
00049 # define DBG_START_METH(__func_name, __verbose_level)
00050 # define DBG_PRINT(__printf_args)
00051 # define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
00052 # define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
00053 # define DBG_EXEC(__verbosity, __cmd)
00054 # define DBG_VERBOSITY() 0
00055 #else
00056 #include <string>
00057
00058 namespace Ipopt
00059 {
00060
00061 class Journalist;
00062
00067 class DebugJournalistWrapper
00068 {
00069 public:
00072 DebugJournalistWrapper(std::string func_name, Index verbose_level);
00073 DebugJournalistWrapper(std::string func_name, Index verbose_level,
00074 const void* const method_owner);
00075 ~DebugJournalistWrapper();
00077
00080 Index Verbosity()
00081 {
00082 return verbose_level_;
00083 }
00084 const Journalist* Jnlst()
00085 {
00086 return jrnl_;
00087 }
00088 Index IndentationLevel()
00089 {
00090 return indentation_level_;
00091 }
00093
00095 void DebugPrintf(Index verbosity, const char* pformat, ...);
00096
00097
00098
00099
00100 static void SetJournalist(Journalist* jrnl);
00101
00102 private:
00112 DebugJournalistWrapper();
00113
00115 DebugJournalistWrapper(const DebugJournalistWrapper&);
00116
00118 DebugJournalistWrapper& operator=(const DebugJournalistWrapper&);
00120
00121 static Index indentation_level_;
00122 std::string func_name_;
00123 Index verbose_level_;
00124 const void* method_owner_;
00125
00126 static Journalist* jrnl_;
00127 };
00128 }
00129
00130 # define DBG_START_FUN(__func_name, __verbose_level) \
00131 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
00132
00133 # define DBG_START_METH(__func_name, __verbose_level) \
00134 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
00135
00136 # define DBG_PRINT(__args) \
00137 dbg_jrnl.DebugPrintf __args;
00138
00139 # define DBG_EXEC(__verbose_level, __cmd) \
00140 if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
00141 (__cmd); \
00142 }
00143
00144 # define DBG_VERBOSITY() \
00145 dbg_jrnl.Verbosity()
00146
00147 #endif
00148
00149
00150 #endif