errormacros.h

00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools version 1.1
00003 //
00004 // GoTools module: CORE
00005 //
00006 // Copyright (C) 2000-2007 SINTEF ICT, Applied Mathematics, Norway.
00007 //
00008 // This program is free software; you can redistribute it and/or          
00009 // modify it under the terms of the GNU General Public License            
00010 // as published by the Free Software Foundation version 2 of the License. 
00011 //
00012 // This program is distributed in the hope that it will be useful,        
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00015 // GNU General Public License for more details.                           
00016 //
00017 // You should have received a copy of the GNU General Public License      
00018 // along with this program; if not, write to the Free Software            
00019 // Foundation, Inc.,                                                      
00020 // 59 Temple Place - Suite 330,                                           
00021 // Boston, MA  02111-1307, USA.                                           
00022 //
00023 // Contact information: E-mail: tor.dokken@sintef.no                      
00024 // SINTEF ICT, Department of Applied Mathematics,                         
00025 // P.O. Box 124 Blindern,                                                 
00026 // 0314 Oslo, Norway.                                                     
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 #ifndef _ERRORMACROS_H
00034 #define _ERRORMACROS_H
00035 
00036 #include <iostream>
00037 
00040 #ifdef NVERBOSE // Not verbose mode
00041 #  ifndef REPORT
00042 #    define REPORT
00043 #  endif
00044 #  ifndef MESSAGE
00045 #    define MESSAGE(x)
00046 #  endif
00047 #  ifndef MESSAGE_IF
00048 #    define MESSAGE_IF(cond, m)
00049 #  endif
00050 #else // Verbose mode
00051 #  ifndef REPORT
00052 #    define REPORT std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << std::endl
00053 #  endif
00054 #  ifndef MESSAGE
00055 #    define MESSAGE(x) std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << ": " << x << std::endl
00056 #  endif
00057 #  ifndef MESSAGE_IF
00058 #    define MESSAGE_IF(cond, m) do {if(cond) MESSAGE(m);} while(0)
00059 #  endif
00060 #endif
00061 
00062 #ifndef GO_NO_CHECKS
00063 #define GO_NO_CHECKS
00064 #endif
00065 
00067 #ifndef THROW
00068 #  define THROW(x) MESSAGE(x), throw std::exception()
00069 #endif
00070 
00071 #define ALWAYS_ERROR_IF(condition, message) do {if(condition){ THROW(message);}} while(0)
00072 
00076 #ifdef NDEBUG // Not in debug mode
00077 #  ifndef ASSERT
00078 #    define ASSERT(x)
00079 #  endif
00080 #  ifndef ASSERT2
00081 #    define ASSERT2(cond, x)
00082 #  endif
00083 #  ifndef DEBUG_ERROR_IF
00084 #    define DEBUG_ERROR_IF(cond, x)
00085 #  endif
00086 #else // Debug mode
00087 #  ifndef ASSERT
00088 #    define ASSERT(cond) if (!(cond)) THROW("Assertion \'" #cond "\' failed.")
00089 #  endif
00090 #  ifndef ASSERT2
00091 #    define ASSERT2(cond, x) do { if (!(cond)) THROW(x);} while(0)
00092 #  endif
00093 #  ifndef DEBUG_ERROR_IF
00094 //#    define DEBUG_ERROR_IF(cond, x) if (cond) THROW(x) 
00095 #    define DEBUG_ERROR_IF(cond, x) do { if (cond) THROW(x); } while(0)
00096 #  endif
00097 #endif
00098 
00099 
00100 #endif // _ERRORMACROS_H
00101 
00102 
00103 
00104 
00105 

Generated on Mon Jun 11 14:48:18 2007 for GoTools Core Library by  doxygen 1.5.1