LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiDebug.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*--------------------------------------------------------------------
00025  * project ....: LTI-Lib: Image Processing and Computer Vision Library
00026  * file .......: ltiDebug.h
00027  * authors ....: Jochen Wickel, Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 24.02.2003
00030  * revisions ..: $Id: ltiDebug.h,v 1.3 2006/02/07 18:07:52 ltilib Exp $
00031  */
00032 
00033 /**
00034  * \file ltiDebug.h Definition of macros for debug purposes
00035  */
00036 
00037 #undef _lti_debug
00038 #undef _lti_debug1
00039 #undef _lti_debug2
00040 #undef _lti_debug3
00041 #undef _lti_debug4
00042 
00043 #undef _lti_if_debug
00044 #undef _lti_if_debug1
00045 #undef _lti_if_debug2
00046 #undef _lti_if_debug3
00047 #undef _lti_if_debug4
00048 
00049 #undef _lti_enterCTOR
00050 #undef _lti_leaveCTOR
00051 #undef _lti_enterDTOR
00052 #undef _lti_leaveDTOR
00053 
00054 #undef _lti_showVar
00055 
00056 /**
00057  * @name Debugging Macros
00058  *
00059  * Developers of the LTI-Lib use following macros to activate debugging
00060  * code in their implementations.
00061  *
00062  * To activate them, the macro _LTI_DEBUG must be defined before including 
00063  * this file.  The value of _LTI_DEBUG must be an integer value between 1 and 4
00064  * Debug level i+1 includes all information of level i.  This means, you
00065  * should use the macros _lti_debug and _lti_debug1 to display critical 
00066  * information, that must always be displayed when debugging is activated and
00067  * less critical information with higher levels.
00068  *
00069  * Don't forget to include the "ltiUndebug.h" file at the end of your source
00070  * code, to undefine all the debug macros defined here, especially if it is
00071  * a header file (e.g. _template.h, _inline.h).
00072  *
00073  * The typical use of this file is:
00074  * \code
00075  * // somewhere at the beginning of your source file
00076  * #undef _LTI_DEBUG
00077  * #define _LTI_DEBUG 1 // comment out this line to remove all debug info.
00078  * #include "ltiDebug.h"
00079  *
00080  * // somewhere in your code you can use 
00081  * _lti_debug("I've been here with value" << val);
00082  * 
00083  * _lti_debug4("Only in level 4 this will be displayed");
00084  *
00085  * // at the end of your file you MUST undefine every debugging macro, to
00086  * // avoid confusion if someone includes your file!  Of course this is
00087  * // not necessary if your file is a .cpp file.  This is important for
00088  * // _template.h and _inline.h files.
00089  * #include "ltiUndebug.h"
00090  * \endcode
00091  */
00092 //@{
00093 #ifdef _LTI_DEBUG
00094 #  include <iostream>
00095 
00096   /**
00097    * \def _lti_debug
00098    * Debug Information Level 0 (always displayed)
00099    */
00100 #  define _lti_debug(a) std::cerr << a
00101 #  define _lti_if_debug(a) a
00102 
00103   /**
00104    * \def _lti_debug1
00105    * Debug Information Level 1 (always displayed)
00106    */
00107 #  define _lti_debug1(a) std::cerr << a
00108 #  define _lti_if_debug1(a) a
00109 
00110 #  if _LTI_DEBUG > 1
00111 #    include "ltiClassName.h"
00112 #    ifndef _LTI_CLASSNAME_DEBUG
00113 #    define _LTI_CLASSNAME_DEBUG
00114      static lti::className _lti_cname;
00115 #    endif
00116      /**
00117       * \def _lti_debug2
00118       * Debug Information Level 2 
00119       */
00120 #    define _lti_debug2(a) std::cerr << a
00121 #    define _lti_if_debug2(a) a
00122 
00123 #    if _LTI_DEBUG > 2
00124        /**
00125         * \def _lti_debug3
00126         * Debug Information Level 3
00127         */
00128 #      define _lti_debug3(a) std::cerr << a
00129 #      define _lti_if_debug3(a) a
00130 
00131 #      if _LTI_DEBUG > 3
00132          /**
00133           * \def _lti_debug4
00134           * Debug Information Level 4
00135           */
00136 #        define _lti_debug4(a) std::cerr << a
00137 #        define _lti_if_debug4(a) a
00138 
00139 #      else
00140          /**
00141           * \def _lti_debug4
00142           * Debug Information Level 4
00143           */
00144 #        define _lti_debug4(a)
00145 #        define _lti_if_debug4(a)
00146 
00147 #      endif
00148 #    else
00149        /**
00150         * \def _lti_debug3
00151         * Debug Information Level 3
00152         */
00153 #      define _lti_debug3(a)
00154 #      define _lti_if_debug3(a)
00155 
00156 #    endif
00157 #  else
00158     /**
00159      * \def _lti_debug2
00160      * Debug Information Level 2
00161      */
00162 #    define _lti_debug2(a)
00163 #    define _lti_if_debug2(a)
00164 
00165 #  endif
00166 #endif
00167 
00168 #ifndef _lti_debug
00169   /**
00170    * \def _lti_debug
00171    * Debug Information Level 0 (always displayed)
00172    */
00173 #  define _lti_debug(a)
00174 #  define _lti_if_debug(a)
00175 
00176 #endif
00177 
00178 #ifndef _lti_debug1
00179   /**
00180    * \def _lti_debug1
00181    * Debug Information Level 1 (always displayed)
00182    */
00183 #  define _lti_debug1(a)
00184 #  define _lti_if_debug1(a)
00185 #endif
00186 
00187 
00188 #ifndef _lti_debug2
00189   /**
00190    * \def _lti_debug2
00191    * Debug Information Level 2
00192    */
00193 #  define _lti_debug2(a)
00194 #  define _lti_if_debug2(a)
00195 #endif
00196 
00197 #ifndef _lti_debug3
00198   /**
00199    * \def _lti_debug3
00200    * Debug Information Level 3
00201    */
00202 #  define _lti_debug3(a)
00203 #  define _lti_if_debug3(a)
00204 #endif
00205 
00206 #ifndef _lti_debug4
00207   /**
00208    * \def _lti_debug4
00209    * Debug Information Level 4
00210    */
00211 #  define _lti_debug4(a)
00212 #  define _lti_if_debug4(a)
00213 #endif
00214 
00215 /**
00216  * \def _lti_enterCTOR
00217  * Debug macro to indicate "entering constructor".  It displays the class name
00218  * followed by the string "::ctor(".  It uses debug level 2.
00219  */
00220 #define _lti_enterCTOR() _lti_debug2(_lti_cname.get(*this) << "::ctor(" << std::endl)
00221 
00222 /**
00223  * \def _lti_leaveCTOR
00224  * Debug macro to indicate "leaving constructor".  It displays the class name
00225  * followed by the string "::ctor)".  It uses debug level 2.
00226  */
00227 #define _lti_leaveCTOR() _lti_debug2(_lti_cname.get(*this) << "::ctor)" << std::endl)
00228 
00229 /**
00230  * \def _lti_enterDTOR
00231  * Debug macro to indicate "entering destructor".  It displays the class name
00232  * followed by the string "::dtor(".  It uses debug level 2.
00233  */
00234 #define _lti_enterDTOR() _lti_debug2(_lti_cname.get(*this) << "::dtor(" << std::endl)
00235 
00236 /**
00237  * \def _lti_leaveDTOR
00238  * Debug macro to indicate "leaving destructor".  It displays the class name
00239  * followed by the string "::ctor)".  It uses debug level 2.
00240  */
00241 #define _lti_leaveDTOR() _lti_debug2(_lti_cname.get(*this) << "::dtor)" << std::endl)
00242 
00243 /**
00244  * \def _lti_showVar
00245  * Debug macro to display at debug level 0 the value of a given variable.
00246  * It displays the name of the variable followed by " = " and the contents
00247  * of it.  The type of the variable must be supported by the std::cerr stream.
00248  */
00249 #define _lti_showVar(a) _lti_debug(#a " = " << a << "\n")
00250 
00251 //@}

Generated on Sat Apr 10 15:25:21 2010 for LTI-Lib by Doxygen 1.6.1