/home/oan/prosjekt/gotools/segmentation/gpl_distro/lsseg_1.0_gpl/include/errormacros.h

Go to the documentation of this file.
00001 //===========================================================================
00002 // The Level-Set Segmentation Library (LSSEG)
00003 //
00004 //
00005 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway.
00006 //
00007 // This program is free software; you can redistribute it and/or          
00008 // modify it under the terms of the GNU General Public License            
00009 // as published by the Free Software Foundation version 2 of the License. 
00010 //
00011 // This program is distributed in the hope that it will be useful,        
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00014 // GNU General Public License for more details.                           
00015 //
00016 // You should have received a copy of the GNU General Public License      
00017 // along with this program; if not, write to the Free Software            
00018 // Foundation, Inc.,                                                      
00019 // 59 Temple Place - Suite 330,                                           
00020 // Boston, MA  02111-1307, USA.                                           
00021 //
00022 // Contact information: e-mail: tor.dokken@sintef.no                      
00023 // SINTEF ICT, Department of Applied Mathematics,                         
00024 // P.O. Box 124 Blindern,                                                 
00025 // 0314 Oslo, Norway.                                                     
00026 // 
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //
00033 //===========================================================================
00034 //===========================================================================
00035 //                                                                           
00036 // File: errormacros.h                                                       
00037 //                                                                           
00038 // Created: Tue May 14 12:22:16 2002                                         
00039 //                                                                           
00040 // Author: Atgeirr F Rasmussen <atgeirr@sintef.no>
00041 //                                                                           
00042 // Revision: $Id: errormacros.h,v 1.2 2006/09/20 22:55:48 oan Exp $
00043 //                                                                           
00044 // Description: Error macros. In order to use some of them, you must also
00045 //              include <iostream> or <exception>. The compile defines NDEBUG
00046 //              and NVERBOSE control the behaviour of these macros.
00050 //                                                                           
00051 //===========================================================================
00052 
00053 #ifndef _ERRORMACROS_H
00054 #define _ERRORMACROS_H
00055 
00056 #include <iostream>
00057 
00060 #ifdef NVERBOSE // Not verbose mode
00061 #  ifndef REPORT
00062 #    define REPORT
00063 #  endif
00064 #  ifndef MESSAGE
00065 #    define MESSAGE(x)
00066 #  endif
00067 #  ifndef MESSAGE_IF
00068 #    define MESSAGE_IF(cond, m)
00069 #  endif
00070 #else // Verbose mode
00071 #  ifndef REPORT
00072 #    define REPORT std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << std::endl
00073 #  endif
00074 #  ifndef MESSAGE
00075 #    define MESSAGE(x) std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << ": " << x << std::endl
00076 #  endif
00077 #  ifndef MESSAGE_IF
00078 #    define MESSAGE_IF(cond, m) do {if(cond) MESSAGE(m);} while(0)
00079 #  endif
00080 #endif
00081 
00083 #ifndef THROW
00084 #  define THROW(x) MESSAGE(x), throw std::exception()
00085 #endif
00086 
00087 #define ALWAYS_ERROR_IF(condition, message) do {if(condition){ THROW(message);}} while(0)
00088 
00092 #ifdef NDEBUG // Not in debug mode
00093 #  ifndef ASSERT
00094 #    define ASSERT(x)
00095 #  endif
00096 #  ifndef ASSERT2
00097 #    define ASSERT2(cond, x)
00098 #  endif
00099 #  ifndef DEBUG_ERROR_IF
00100 #    define DEBUG_ERROR_IF(cond, x)
00101 #  endif
00102 #else // Debug mode
00103 #  ifndef ASSERT
00104 #    define ASSERT(cond) if (!(cond)) THROW("Assertation \'" #cond "\' failed.")
00105 #  endif
00106 #  ifndef ASSERT2
00107 #    define ASSERT2(cond, x) do { if (!(cond)) THROW(x);} while(0)
00108 #  endif
00109 #  ifndef DEBUG_ERROR_IF
00110 //#    define DEBUG_ERROR_IF(cond, x) if (cond) THROW(x) 
00111 #    define DEBUG_ERROR_IF(cond, x) do { if (cond) THROW(x); } while(0)
00112 #  endif
00113 #endif
00114 
00115 
00116 #endif // _ERRORMACROS_H
00117 
00118 
00119 
00120 

Generated on Tue Nov 28 18:35:47 2006 for lsseg by  doxygen 1.4.7