/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/FrameWorks/OmniBase.framework/Versions/A/Headers/assertions.h

00001 // Copyright 1997-2005 Omni Development, Inc.  All rights reserved.
00002 //
00003 // This software may only be used and reproduced according to the
00004 // terms in the file OmniSourceLicense.html, which should be
00005 // distributed with this project and can also be found at
00006 // <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>.
00007 //
00008 // $Header: svn+ssh://source.omnigroup.com/Source/svn/Omni/tags/SourceRelease_2005-11-18/OmniGroup/Frameworks/OmniBase/assertions.h 68913 2005-10-03 19:36:19Z kc $
00009 
00010 #ifndef _OmniBase_assertions_h_
00011 #define _OmniBase_assertions_h_
00012 
00013 #import <OmniBase/FrameworkDefines.h>
00014 #import <objc/objc.h>
00015 
00016 #if defined(DEBUG) || defined(OMNI_FORCE_ASSERTIONS)
00017 #define OMNI_ASSERTIONS_ON
00018 #endif
00019 
00020 // This allows you to turn off assertions when debugging
00021 #if defined(OMNI_FORCE_ASSERTIONS_OFF)
00022 #undef OMNI_ASSERTIONS_ON
00023 #warning Forcing assertions off!
00024 #endif
00025 
00026 
00027 // Make sure that we don't accidentally use the ASSERT macro instead of OBASSERT
00028 #ifdef ASSERT
00029 #undef ASSERT
00030 #endif
00031 
00032 typedef void (*OBAssertionFailureHandler)(const char *type, const char *expression, const char *file, unsigned int lineNumber);
00033 
00034 #if defined(OMNI_ASSERTIONS_ON)
00035 
00036     OmniBase_EXTERN void OBSetAssertionFailureHandler(OBAssertionFailureHandler handler);
00037 
00038     OmniBase_EXTERN void OBAssertFailed(const char *type, const char *expression, const char *file, unsigned int lineNumber);
00039 
00040 
00041     #define OBPRECONDITION(expression)                                            \
00042     do {                                                                        \
00043         if (!(expression))                                                      \
00044             OBAssertFailed("PRECONDITION", #expression, __FILE__, __LINE__);    \
00045     } while (NO)
00046 
00047     #define OBPOSTCONDITION(expression)                                           \
00048     do {                                                                        \
00049         if (!(expression))                                                      \
00050             OBAssertFailed("POSTCONDITION", #expression, __FILE__, __LINE__);   \
00051     } while (NO)
00052 
00053     #define OBINVARIANT(expression)                                               \
00054     do {                                                                        \
00055         if (!(expression))                                                      \
00056             OBAssertFailed("INVARIANT", #expression, __FILE__, __LINE__);       \
00057     } while (NO)
00058 
00059     #define OBASSERT(expression)                                                  \
00060     do {                                                                        \
00061         if (!(expression))                                                      \
00062             OBAssertFailed("ASSERT", #expression, __FILE__, __LINE__);          \
00063     } while (NO)
00064 
00065     #define OBASSERT_NOT_REACHED(reason)                                        \
00066     do {                                                                        \
00067         OBAssertFailed("NOTREACHED", reason, __FILE__, __LINE__);              \
00068     } while (NO)
00069 
00070 
00071 #else   // else insert blank lines into the code
00072 
00073     #define OBPRECONDITION(expression)
00074     #define OBPOSTCONDITION(expression)
00075     #define OBINVARIANT(expression)
00076     #define OBASSERT(expression)
00077     #define OBASSERT_NOT_REACHED(reason)
00078 
00079 #endif
00080 
00081 
00082 #endif // _OmniBase_assertions_h_

Generated on Fri Jul 28 19:15:18 2006 for MacTrek by  doxygen 1.4.7