#ifndef __IPDEBUG_HPP__
#define __IPDEBUG_HPP__
#include "IpoptConfig.h"
#include "IpTypes.hpp"
#ifndef IPOPT_CHECKLEVEL
#define IPOPT_CHECKLEVEL 0
#endif
#if IPOPT_CHECKLEVEL > 0
# ifdef NDEBUG
# undef NDEBUG
# endif
# include <cassert>
# define DBG_ASSERT(test) assert(test)
# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
ASSERT_EXCEPTION( (__condition), __except_type, __msg);
# define DBG_DO(__cmd) __cmd
#else
# define DBG_ASSERT(test)
# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
# define DBG_DO(__cmd)
#endif
#ifndef IPOPT_VERBOSITY
#define IPOPT_VERBOSITY 0
#endif
#if IPOPT_VERBOSITY < 1
# define DBG_START_FUN(__func_name, __verbose_level)
# define DBG_START_METH(__func_name, __verbose_level)
# define DBG_PRINT(__printf_args)
# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
# define DBG_EXEC(__verbosity, __cmd)
# define DBG_VERBOSITY() 0
#else
#include <string>
namespace Ipopt
{
class Journalist;
class IPOPTLIB_EXPORT DebugJournalistWrapper
{
public:
DebugJournalistWrapper(
const std::string& func_name,
Index verbose_level
);
DebugJournalistWrapper(
const std::string& func_name,
Index verbose_level,
const void* const method_owner
);
~DebugJournalistWrapper();
Index Verbosity()
{
return verbose_level_;
}
const Journalist* Jnlst()
{
return jrnl_;
}
Index IndentationLevel()
{
return indentation_level_;
}
#ifdef __GNUC__
__attribute__((format(printf, 3, 4)))
#endif
void DebugPrintf(
Index verbosity,
const char* pformat,
...
);
private:
friend class IpoptApplication;
static void SetJournalist(
Journalist* jrnl
);
DebugJournalistWrapper();
DebugJournalistWrapper(
const DebugJournalistWrapper&
);
DebugJournalistWrapper& operator=(
const DebugJournalistWrapper&
);
static Index indentation_level_;
std::string func_name_;
Index verbose_level_;
const void* method_owner_;
static Journalist* jrnl_;
};
}
# define DBG_START_FUN(__func_name, __verbose_level) \
DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
# define DBG_START_METH(__func_name, __verbose_level) \
DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
# define DBG_PRINT(__args) \
dbg_jrnl.DebugPrintf __args;
# define DBG_EXEC(__verbose_level, __cmd) \
if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
(__cmd); \
}
# define DBG_VERBOSITY() \
dbg_jrnl.Verbosity()
#endif
#endif