Ipopt 3.11.9
Loading...
Searching...
No Matches
IpDebug.hpp
Go to the documentation of this file.
1// Copyright (C) 2004, 2007 International Business Machines and others.
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// $Id: IpDebug.hpp 2005 2011-06-06 12:55:16Z stefan $
6//
7// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8
9#ifndef __IPDEBUG_HPP__
10#define __IPDEBUG_HPP__
11
12#include "IpoptConfig.h"
13#include "IpTypes.hpp"
14
15#ifdef COIN_IPOPT_CHECKLEVEL
16#ifdef HAVE_CASSERT
17# include <cassert>
18#else
19# ifdef HAVE_ASSERT_H
20# include <assert.h>
21# else
22# error "don't have header file for assert"
23# endif
24#endif
25#else
26#define COIN_IPOPT_CHECKLEVEL 0
27#endif
28
29#if COIN_IPOPT_CHECKLEVEL > 0
30# ifdef NDEBUG
31# undef NDEBUG
32# endif
33# define DBG_ASSERT(test) assert(test)
34# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
35 ASSERT_EXCEPTION( (__condition), __except_type, __msg);
36# define DBG_DO(__cmd) __cmd
37#else
38# define DBG_ASSERT(test)
39# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
40# define DBG_DO(__cmd)
41#endif
42
43#ifndef COIN_IPOPT_VERBOSITY
44#define COIN_IPOPT_VERBOSITY 0
45#endif
46
47#if COIN_IPOPT_VERBOSITY < 1
48# define DBG_START_FUN(__func_name, __verbose_level)
49# define DBG_START_METH(__func_name, __verbose_level)
50# define DBG_PRINT(__printf_args)
51# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
52# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
53# define DBG_EXEC(__verbosity, __cmd)
54# define DBG_VERBOSITY() 0
55#else
56#include <string>
57
58namespace Ipopt
59{
60 // forward definition
61 class Journalist;
62
67 class DebugJournalistWrapper
68 {
69 public:
72 DebugJournalistWrapper(std::string func_name, Index verbose_level);
73 DebugJournalistWrapper(std::string func_name, Index verbose_level,
74 const void* const method_owner);
75 ~DebugJournalistWrapper();
77
80 Index Verbosity()
81 {
82 return verbose_level_;
83 }
84 const Journalist* Jnlst()
85 {
86 return jrnl_;
87 }
88 Index IndentationLevel()
89 {
90 return indentation_level_;
91 }
93
95 void DebugPrintf(Index verbosity, const char* pformat, ...);
96
97 /* Method for initialization of the static GLOBAL journalist,
98 * through with all debug printout is to be written. This needs
99 * to be set before any debug printout can be done. */
100 static void SetJournalist(Journalist* jrnl);
101
102 private:
112 DebugJournalistWrapper();
113
115 DebugJournalistWrapper(const DebugJournalistWrapper&);
116
118 DebugJournalistWrapper& operator=(const DebugJournalistWrapper&);
120
121 static Index indentation_level_;
122 std::string func_name_;
123 Index verbose_level_;
124 const void* method_owner_;
125
126 static Journalist* jrnl_;
127 };
128}
129
130# define DBG_START_FUN(__func_name, __verbose_level) \
131 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
132
133# define DBG_START_METH(__func_name, __verbose_level) \
134 DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
135
136# define DBG_PRINT(__args) \
137 dbg_jrnl.DebugPrintf __args;
138
139# define DBG_EXEC(__verbose_level, __cmd) \
140 if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
141 (__cmd); \
142 }
143
144# define DBG_VERBOSITY() \
145 dbg_jrnl.Verbosity()
146
147#endif
148
149
150#endif
int Index
Type for all incides.