1 /*****************************************************************************/ 2 // Copyright 2006-2007 Adobe Systems Incorporated 3 // All Rights Reserved. 4 // 5 // NOTICE: Adobe permits you to use, modify, and distribute this file in 6 // accordance with the terms of the Adobe license agreement accompanying it. 7 /*****************************************************************************/ 8 9 /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_assertions.h#3 $ */ 10 /* $DateTime: 2012/09/05 12:31:51 $ */ 11 /* $Change: 847652 $ */ 12 /* $Author: tknoll $ */ 13 14 /** \file 15 * Conditionally compiled assertion check support. 16 */ 17 18 /*****************************************************************************/ 19 20 #ifndef __dng_assertions__ 21 #define __dng_assertions__ 22 23 /*****************************************************************************/ 24 25 #include "dng_exceptions.h" 26 #include "dng_flags.h" 27 28 /*****************************************************************************/ 29 30 #if qDNGDebug 31 32 /// Platform-specific function to display an assert. 33 34 void dng_show_message (const char *s); 35 36 /// Show a formatted error message. 37 38 void dng_show_message_f (const char *fmt, ...); 39 40 #endif 41 42 /*****************************************************************************/ 43 44 #ifndef DNG_ASSERT 45 46 #if qDNGDebug 47 48 /// Conditionally compiled macro to check an assertion and display a message if 49 /// it fails and assertions are compiled in via qDNGDebug 50 /// \param x Predicate which must be true. 51 /// \param y String to display if x is not true. 52 53 #define DNG_ASSERT(x,y) { if (!(x)) dng_show_message (y); } 54 55 #else 56 57 /// Conditionally compiled macro to check an assertion and display a message if 58 /// it fails and assertions are compiled in via qDNGDebug 59 /// \param x Predicate which must be true. 60 /// \param y String to display if x is not true. 61 62 #define DNG_ASSERT(x,y) do { } while(false) 63 64 #endif 65 #endif 66 67 /*****************************************************************************/ 68 69 #ifndef DNG_REQUIRE 70 71 #if qDNGDebug 72 73 /// Conditionally compiled macro to check an assertion, display a message, and throw 74 /// an exception if it fails and assertions are compiled in via qDNGDebug 75 /// \param condition Predicate which must be true. 76 /// \param msg String to display if condition is not true. 77 78 #define DNG_REQUIRE(condition,msg) \ 79 do \ 80 { \ 81 \ 82 if (!(condition)) \ 83 { \ 84 \ 85 DNG_ASSERT(condition, msg); \ 86 \ 87 ThrowProgramError (msg); \ 88 \ 89 } \ 90 \ 91 } \ 92 while (0) 93 94 #else 95 96 /// Conditionally compiled macro to check an assertion, display a message, and throw 97 /// an exception if it fails and assertions are compiled in via qDNGDebug 98 /// \param condition Predicate which must be true. 99 /// \param msg String to display if condition is not true. 100 101 #define DNG_REQUIRE(condition,msg) \ 102 do \ 103 { \ 104 \ 105 if (!(condition)) \ 106 { \ 107 \ 108 ThrowProgramError (msg); \ 109 \ 110 } \ 111 \ 112 } \ 113 while (0) 114 115 #endif 116 #endif 117 118 /*****************************************************************************/ 119 120 #ifndef DNG_REPORT 121 122 /// Macro to display an informational message 123 /// \param x String to display. 124 125 #define DNG_REPORT(x) DNG_ASSERT (false, x) 126 127 #endif 128 129 /*****************************************************************************/ 130 131 #endif 132 133 /*****************************************************************************/ 134