BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/assertions.h
Go to the documentation of this file.
00001 // Copyright (c) 1999  Utrecht University (The Netherlands),
00002 // ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
00003 // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
00004 // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
00005 // and Tel-Aviv University (Israel).  All rights reserved.
00006 //
00007 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00008 // modify it under the terms of the GNU Lesser General Public License as
00009 // published by the Free Software Foundation; version 2.1 of the License.
00010 // See the file LICENSE.LGPL distributed with CGAL.
00011 //
00012 // Licensees holding a valid commercial license may use this file in
00013 // accordance with the commercial license agreement provided with the software.
00014 //
00015 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 //
00018 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/STL_Extension/include/CGAL/assertions.h $
00019 // $Id: assertions.h 46984 2008-11-21 16:47:39Z spion $
00020 //
00021 //
00022 // Author(s)     : Geert-Jan Giezeman and Sven Schoenherr
00023 
00024 #include <CGAL/config.h>
00025 
00026 #ifndef CGAL_ASSERTIONS_H
00027 #define CGAL_ASSERTIONS_H
00028 
00029 // #include <CGAL/assertions_behaviour.h> // for backward compatibility
00030 
00031 CGAL_BEGIN_NAMESPACE
00032 
00033 // function declarations
00034 // =====================
00035 // failure functions
00036 // -----------------
00037 void assertion_fail      ( const char*, const char*, int, const char* = "") CGAL_NORETURN;
00038 void precondition_fail   ( const char*, const char*, int, const char* = "") CGAL_NORETURN;
00039 void postcondition_fail  ( const char*, const char*, int, const char* = "") CGAL_NORETURN;
00040 
00041 // warning function
00042 // ----------------
00043 void warning_fail( const char*, const char*, int, const char* = "");
00044 
00045 
00046 // The following declarations are needed first, before assertions are used.
00047 // ---------------------------------------------------------------------
00048 template < typename T > class Uncertain;
00049 inline bool possibly(bool b);
00050 inline bool possibly(Uncertain<bool> c);
00051 
00052 
00053 // macro definitions
00054 // =================
00055 // assertions
00056 // ----------
00057 
00058 #ifdef NDEBUG
00059 #  define CGAL_NDEBUG
00060 #endif
00061 
00062 #ifdef CGAL_NDEBUG
00063 #  define CGAL_NO_ASSERTIONS
00064 #  define CGAL_NO_PRECONDITIONS
00065 #  define CGAL_NO_POSTCONDITIONS
00066 #  define CGAL_NO_WARNINGS
00067 #endif
00068 
00069 #if defined(CGAL_NO_ASSERTIONS)
00070 #  define CGAL_assertion(EX) (static_cast<void>(0))
00071 #  define CGAL_assertion_msg(EX,MSG) (static_cast<void>(0))
00072 #  define CGAL_assertion_code(CODE)
00073 #else
00074 #  define CGAL_assertion(EX) \
00075    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__))
00076 #  define CGAL_assertion_msg(EX,MSG) \
00077    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
00078 #  define CGAL_assertion_code(CODE) CODE
00079 #endif // CGAL_NO_ASSERTIONS
00080 
00081 #if defined(CGAL_NO_ASSERTIONS) || !defined(CGAL_CHECK_EXACTNESS)
00082 #  define CGAL_exactness_assertion(EX) (static_cast<void>(0))
00083 #  define CGAL_exactness_assertion_msg(EX,MSG) (static_cast<void>(0))
00084 #  define CGAL_exactness_assertion_code(CODE)
00085 #else
00086 #  define CGAL_exactness_assertion(EX) \
00087    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__))
00088 #  define CGAL_exactness_assertion_msg(EX,MSG) \
00089    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
00090 #  define CGAL_exactness_assertion_code(CODE) CODE
00091 #endif // CGAL_NO_ASSERTIONS
00092 
00093 #if defined(CGAL_NO_ASSERTIONS) || !defined(CGAL_CHECK_EXPENSIVE)
00094 #  define CGAL_expensive_assertion(EX) (static_cast<void>(0))
00095 #  define CGAL_expensive_assertion_msg(EX,MSG) (static_cast<void>(0))
00096 #  define CGAL_expensive_assertion_code(CODE)
00097 #else
00098 #  define CGAL_expensive_assertion(EX) \
00099    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__))
00100 #  define CGAL_expensive_assertion_msg(EX,MSG) \
00101    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
00102 #  define CGAL_expensive_assertion_code(CODE) CODE
00103 #endif // CGAL_NO_ASSERTIONS
00104 
00105 #if defined(CGAL_NO_ASSERTIONS) || !defined(CGAL_CHECK_EXACTNESS) || !defined(CGAL_CHECK_EXPENSIVE)
00106 #  define CGAL_expensive_exactness_assertion(EX) (static_cast<void>(0))
00107 #  define CGAL_expensive_exactness_assertion_msg(EX,MSG) (static_cast<void>(0))
00108 #  define CGAL_expensive_exactness_assertion_code(CODE)
00109 #else
00110 #  define CGAL_expensive_exactness_assertion(EX) \
00111    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__))
00112 #  define CGAL_expensive_exactness_assertion_msg(EX,MSG) \
00113    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::assertion_fail( # EX , __FILE__, __LINE__, MSG))
00114 #  define CGAL_expensive_exactness_assertion_code(CODE) CODE
00115 #endif // CGAL_NO_ASSERTIONS
00116 
00117 
00118 // preconditions
00119 // -------------
00120 
00121 #if defined(CGAL_NO_PRECONDITIONS)
00122 #  define CGAL_precondition(EX) (static_cast<void>(0))
00123 #  define CGAL_precondition_msg(EX,MSG) (static_cast<void>(0))
00124 #  define CGAL_precondition_code(CODE)
00125 #else
00126 #  define CGAL_precondition(EX) \
00127    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__))
00128 #  define CGAL_precondition_msg(EX,MSG) \
00129    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__, MSG))
00130 #  define CGAL_precondition_code(CODE) CODE
00131 #endif // CGAL_NO_PRECONDITIONS
00132 
00133 #if defined(CGAL_NO_PRECONDITIONS) || !defined(CGAL_CHECK_EXACTNESS)
00134 #  define CGAL_exactness_precondition(EX) (static_cast<void>(0))
00135 #  define CGAL_exactness_precondition_msg(EX,MSG) (static_cast<void>(0))
00136 #  define CGAL_exactness_precondition_code(CODE)
00137 #else
00138 #  define CGAL_exactness_precondition(EX) \
00139    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__))
00140 #  define CGAL_exactness_precondition_msg(EX,MSG) \
00141    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__, MSG))
00142 #  define CGAL_exactness_precondition_code(CODE) CODE
00143 #endif // CGAL_NO_PRECONDITIONS
00144 
00145 #if defined(CGAL_NO_PRECONDITIONS) || !defined(CGAL_CHECK_EXPENSIVE)
00146 #  define CGAL_expensive_precondition(EX) (static_cast<void>(0))
00147 #  define CGAL_expensive_precondition_msg(EX,MSG) (static_cast<void>(0))
00148 #  define CGAL_expensive_precondition_code(CODE)
00149 #else
00150 #  define CGAL_expensive_precondition(EX) \
00151    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__))
00152 #  define CGAL_expensive_precondition_msg(EX,MSG) \
00153    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__, MSG))
00154 #  define CGAL_expensive_precondition_code(CODE) CODE
00155 #endif // CGAL_NO_PRECONDITIONS
00156 
00157 #if defined(CGAL_NO_PRECONDITIONS) || !defined(CGAL_CHECK_EXACTNESS) || !defined(CGAL_CHECK_EXPENSIVE) 
00158 #  define CGAL_expensive_exactness_precondition(EX) (static_cast<void>(0))
00159 #  define CGAL_expensive_exactness_precondition_msg(EX,MSG) (static_cast<void>(0))
00160 #  define CGAL_expensive_exactness_precondition_code(CODE)
00161 #else
00162 #  define CGAL_expensive_exactness_precondition(EX) \
00163    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__))
00164 #  define CGAL_expensive_exactness_precondition_msg(EX,MSG) \
00165    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::precondition_fail( # EX , __FILE__, __LINE__, MSG))
00166 #  define CGAL_expensive_exactness_precondition_code(CODE) CODE
00167 #endif // CGAL_NO_PRECONDITIONS
00168 
00169 
00170 // postconditions
00171 // --------------
00172 
00173 #if defined(CGAL_NO_POSTCONDITIONS)
00174 #  define CGAL_postcondition(EX) (static_cast<void>(0))
00175 #  define CGAL_postcondition_msg(EX,MSG) (static_cast<void>(0))
00176 #  define CGAL_postcondition_code(CODE)
00177 #else
00178 #  define CGAL_postcondition(EX) \
00179    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__))
00180 #  define CGAL_postcondition_msg(EX,MSG) \
00181    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__, MSG))
00182 #  define CGAL_postcondition_code(CODE) CODE
00183 #endif // CGAL_NO_POSTCONDITIONS
00184 
00185 #if defined(CGAL_NO_POSTCONDITIONS) || !defined(CGAL_CHECK_EXACTNESS)
00186 #  define CGAL_exactness_postcondition(EX) (static_cast<void>(0))
00187 #  define CGAL_exactness_postcondition_msg(EX,MSG) (static_cast<void>(0))
00188 #  define CGAL_exactness_postcondition_code(CODE)
00189 #else
00190 #  define CGAL_exactness_postcondition(EX) \
00191    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__))
00192 #  define CGAL_exactness_postcondition_msg(EX,MSG) \
00193    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__, MSG))
00194 #  define CGAL_exactness_postcondition_code(CODE) CODE
00195 #endif // CGAL_NO_POSTCONDITIONS
00196 
00197 #if defined(CGAL_NO_POSTCONDITIONS) || !defined(CGAL_CHECK_EXPENSIVE)
00198 #  define CGAL_expensive_postcondition(EX) (static_cast<void>(0))
00199 #  define CGAL_expensive_postcondition_msg(EX,MSG) (static_cast<void>(0))
00200 #  define CGAL_expensive_postcondition_code(CODE)
00201 #else
00202 #  define CGAL_expensive_postcondition(EX) \
00203    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__))
00204 #  define CGAL_expensive_postcondition_msg(EX,MSG) \
00205    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__, MSG))
00206 #  define CGAL_expensive_postcondition_code(CODE) CODE
00207 #endif // CGAL_NO_POSTCONDITIONS
00208 
00209 #if defined(CGAL_NO_POSTCONDITIONS) || !defined(CGAL_CHECK_EXACTNESS) || !defined(CGAL_CHECK_EXPENSIVE)
00210 #  define CGAL_expensive_exactness_postcondition(EX) (static_cast<void>(0))
00211 #  define CGAL_expensive_exactness_postcondition_msg(EX,MSG) (static_cast<void>(0))
00212 #  define CGAL_expensive_exactness_postcondition_code(CODE)
00213 #else
00214 #  define CGAL_expensive_exactness_postcondition(EX) \
00215    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__))
00216 #  define CGAL_expensive_exactness_postcondition_msg(EX,MSG) \
00217    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::postcondition_fail( # EX , __FILE__, __LINE__, MSG))
00218 #  define CGAL_expensive_exactness_postcondition_code(CODE) CODE
00219 #endif // CGAL_NO_POSTCONDITIONS
00220 
00221 
00222 // warnings
00223 // --------
00224 
00225 #if defined(CGAL_NO_WARNINGS)
00226 #  define CGAL_warning(EX) (static_cast<void>(0))
00227 #  define CGAL_warning_msg(EX,MSG) (static_cast<void>(0))
00228 #  define CGAL_warning_code(CODE)
00229 #else
00230 #  define CGAL_warning(EX) \
00231    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__))
00232 #  define CGAL_warning_msg(EX,MSG) \
00233    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__, MSG))
00234 #  define CGAL_warning_code(CODE) CODE
00235 #endif // CGAL_NO_WARNINGS
00236 
00237 #if defined(CGAL_NO_WARNINGS) || !defined(CGAL_CHECK_EXACTNESS)
00238 #  define CGAL_exactness_warning(EX) (static_cast<void>(0))
00239 #  define CGAL_exactness_warning_msg(EX,MSG) (static_cast<void>(0))
00240 #  define CGAL_exactness_warning_code(CODE)
00241 #else
00242 #  define CGAL_exactness_warning(EX) \
00243    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__))
00244 #  define CGAL_exactness_warning_msg(EX,MSG) \
00245    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__, MSG))
00246 #  define CGAL_exactness_warning_code(CODE) CODE
00247 #endif // CGAL_NO_WARNINGS
00248 
00249 #if defined(CGAL_NO_WARNINGS) || !defined(CGAL_CHECK_EXPENSIVE)
00250 #  define CGAL_expensive_warning(EX) (static_cast<void>(0))
00251 #  define CGAL_expensive_warning_msg(EX,MSG) (static_cast<void>(0))
00252 #  define CGAL_expensive_warning_code(CODE)
00253 #else
00254 #  define CGAL_expensive_warning(EX) \
00255    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__))
00256 #  define CGAL_expensive_warning_msg(EX,MSG) \
00257    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__, MSG))
00258 #  define CGAL_expensive_warning_code(CODE) CODE
00259 #endif // CGAL_NO_WARNINGS
00260 
00261 #if defined(CGAL_NO_WARNINGS) || !defined(CGAL_CHECK_EXACTNESS) || !defined(CGAL_CHECK_EXPENSIVE)
00262 #  define CGAL_expensive_exactness_warning(EX) (static_cast<void>(0))
00263 #  define CGAL_expensive_exactness_warning_msg(EX,MSG) (static_cast<void>(0))
00264 #  define CGAL_expensive_exactness_warning_code(CODE)
00265 #else
00266 #  define CGAL_expensive_exactness_warning(EX) \
00267    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__))
00268 #  define CGAL_expensive_exactness_warning_msg(EX,MSG) \
00269    (CGAL::possibly(EX)?(static_cast<void>(0)): ::CGAL::warning_fail( # EX , __FILE__, __LINE__, MSG))
00270 #  define CGAL_expensive_exactness_warning_code(CODE) CODE
00271 #endif // CGAL_NO_WARNINGS
00272 
00273 // CGAL error
00274 #define CGAL_error_msg(MSG) ::CGAL::assertion_fail( "", __FILE__, __LINE__, MSG )
00275 #define CGAL_error()        ::CGAL::assertion_fail( "", __FILE__, __LINE__ )
00276 
00277 CGAL_END_NAMESPACE
00278 
00279 // This comes last as it is dependant on the macros to be defined.
00280 // But the macros need CGAL::possibly().
00281 #include <CGAL/Uncertain.h>
00282 
00283 #endif // CGAL_ASSERTIONS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines