- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# /home/coin/SVN-release/Ipopt-3.5.1/Ipopt/src/Common/IpDebug.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2004, 2007 International Business Machines and others.
    00002 // All Rights Reserved.
    00003 // This code is published under the Common Public License.
    00004 //
    00005 // $Id: IpDebug.hpp 1000 2007-06-16 06:52:34Z andreasw $
    00006 //
    00007 // Authors:  Carl Laird, Andreas Waechter     IBM    2004-08-13
    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   // forward definition
    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     /* Method for initialization of the static GLOBAL journalist,
    00090     * through with all debug printout is to be written.  This needs
    00091     * to be set before any debug printout can be done. */
    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