AppAssert.h

Go to the documentation of this file.
00001 /*
00002  * The information in this file is
00003  * Copyright(c) 2007 Ball Aerospace & Technologies Corporation
00004  * and is subject to the terms and conditions of the
00005  * GNU Lesser General Public License Version 2.1
00006  * The license text is available from   
00007  * http://www.gnu.org/licenses/lgpl.html
00008  */
00009 
00010 #ifndef APPASSERT_H
00011 #define APPASSERT_H
00012 
00013 #include <string>
00014 
00015 class AssertException
00016 {
00017 public:
00018    explicit AssertException(const char* pText) :
00019       mText(pText) {}
00020 
00021    explicit AssertException(const std::string& str) :
00022       mText(str) {}
00023 
00024    std::string getText() const
00025    {
00026       return mText;
00027    }
00028 
00029 private:
00030    std::string mText;
00031 };
00032 
00033 extern void AppAssert(const char* pExpression, const char* pFilename, unsigned line);
00034 
00035 #define APP_ASSERT(test) ((test) ? (void)0 : AppAssert(#test, __FILE__, __LINE__))
00036 
00037 #define REQUIRE(test) APP_ASSERT(test)
00038 #define ENSURE(test) APP_ASSERT(test)
00039 #define INVARIANT(test) APP_ASSERT(test)
00040 
00041 #ifdef NDEBUG
00042 #define REQUIRE_DEBUG(test)
00043 #define ENSURE_DEBUG(test)
00044 #define INVARIANT_DEBUG(test)
00045 #else
00046 #define REQUIRE_DEBUG(test) REQUIRE(test)
00047 #define ENSURE_DEBUG(test) ENSURE(test)
00048 #define INVARIANT_DEBUG(test) INVARIANT(test)
00049 #endif
00050 
00051 #endif

Software Development Kit - Opticks 4.9.0 Build 16218