Ipopt Documentation  
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 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
6 
7 #ifndef __IPDEBUG_HPP__
8 #define __IPDEBUG_HPP__
9 
10 #include "IpoptConfig.h"
11 #include "IpTypes.hpp"
12 
13 #ifdef COIN_IPOPT_CHECKLEVEL
14 #include <cassert>
15 #else
16 #define COIN_IPOPT_CHECKLEVEL 0
17 #endif
18 
19 #if COIN_IPOPT_CHECKLEVEL > 0
20 # ifdef NDEBUG
21 # undef NDEBUG
22 # endif
23 # define DBG_ASSERT(test) assert(test)
24 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
25  ASSERT_EXCEPTION( (__condition), __except_type, __msg);
26 # define DBG_DO(__cmd) __cmd
27 #else
28 # define DBG_ASSERT(test)
29 # define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
30 # define DBG_DO(__cmd)
31 #endif
32 
33 #ifndef COIN_IPOPT_VERBOSITY
34 #define COIN_IPOPT_VERBOSITY 0
35 #endif
36 
37 #if COIN_IPOPT_VERBOSITY < 1
38 # define DBG_START_FUN(__func_name, __verbose_level)
39 # define DBG_START_METH(__func_name, __verbose_level)
40 # define DBG_PRINT(__printf_args)
41 # define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
42 # define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
43 # define DBG_EXEC(__verbosity, __cmd)
44 # define DBG_VERBOSITY() 0
45 #else
46 #include <string>
47 
48 namespace Ipopt
49 {
50 // forward definition
51 class Journalist;
52 
60 class IPOPTLIB_EXPORT DebugJournalistWrapper
61 {
62 public:
65  DebugJournalistWrapper(
66  std::string func_name,
67  Index verbose_level
68  );
69 
70  DebugJournalistWrapper(
71  std::string func_name,
72  Index verbose_level,
73  const void* const method_owner
74  );
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(
96  Index verbosity,
97  const char* pformat,
98  ...
99  );
100 
101  /* Method for initialization of the static GLOBAL journalist,
102  * through with all debug printout is to be written.
103  *
104  * This needs to be set before any debug printout can be done.
105  */
106  static void SetJournalist(
107  Journalist* jrnl
108  );
109 
110 private:
122  DebugJournalistWrapper();
123 
125  DebugJournalistWrapper(
126  const DebugJournalistWrapper&
127  );
128 
130  DebugJournalistWrapper& operator=(
131  const DebugJournalistWrapper&
132  );
134 
135  static Index indentation_level_;
136  std::string func_name_;
137  Index verbose_level_;
138  const void* method_owner_;
139 
140  static Journalist* jrnl_;
141 };
142 }
143 
144 # define DBG_START_FUN(__func_name, __verbose_level) \
145  DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
146 
147 # define DBG_START_METH(__func_name, __verbose_level) \
148  DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
149 
150 # define DBG_PRINT(__args) \
151  dbg_jrnl.DebugPrintf __args;
152 
153 # define DBG_EXEC(__verbose_level, __cmd) \
154  if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
155  (__cmd); \
156  }
157 
158 # define DBG_VERBOSITY() \
159  dbg_jrnl.Verbosity()
160 
161 #endif
162 
163 #endif
Ipopt
This file contains a base class for all exceptions and a set of macros to help with exceptions.
Definition: IpInexactAlgBuilder.hpp:13
IPOPTLIB_EXPORT
#define IPOPTLIB_EXPORT
Definition: config_default.h:16
IpTypes.hpp
IpoptConfig.h
Index
int Index
Type for all indices.
Definition: IpStdCInterface.h:36