/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/ers/ers-00-00-03/ers/Assertion.h

Go to the documentation of this file.
00001 /*
00002  *  Assertion.h
00003  *  ers
00004  *
00005  *  Created by Matthias Wiesmann on 26.11.04.
00006  *  Copyright 2004 CERN. All rights reserved.
00007  *
00008  */
00009 
00014 #ifndef ERS_ASSERTION
00015 #define ERS_ASSERTION
00016 
00017 #include <stdio.h>
00018 #include "ers/Issue.h"
00019 
00020 namespace ers {
00021     
00032     class Assertion: public ers::Issue {
00033 protected:
00034     virtual std::string build_message(const char* condition_text, const std::string &msg, bool constant_expression=false) throw() ; 
00035     Assertion(const Context &context, severity_t s); 
00036     void setup(const char *condition, const std::string &message, bool constant_expression); 
00037     static const char* const MESSAGE_ELEMENTS[] ; 
00038 public:
00039     static const char* const ASSERT_CONDITION_KEY ;
00040     static const char* const CLASS_NAME ; 
00041      
00042     virtual const char*get_class_name() const throw() ;
00043     Assertion(); 
00044     Assertion(const Context &context, severity_t s, const char*condition, const std::string &message,  bool constant_expression=false) ;
00045 } ; 
00046 
00053 template <bool> struct Compile_time_error ; 
00054 
00057 template<> struct Compile_time_error<true> { };
00058 
00059 } // ers 
00060 
00061 
00062 
00068 #ifndef N_ERS_STATIC_ASSERT
00069 #define ERS_STATIC_ASSERT(expr) { ers::Compile_time_error <((expr) != 0)> ERROR_ASSERTION_FAILED ;   (void) ERROR_ASSERTION_FAILED ; }
00070 #else 
00071 #define ERS_STATIC_ASSERT(expr) 
00072 #endif 
00073 
00074 
00082 #ifndef N_ERS_ASSERT
00083 #ifdef __GNUC__
00084 #define ERS_ASSERT(expr,...) { if(!(expr)) { char assertion_buffer[256] ; snprintf(assertion_buffer,sizeof(assertion_buffer), __VA_ARGS__) ; ers::Assertion failed_assertion(ERS_HERE, ers::error, #expr,assertion_buffer,__builtin_constant_p(expr)) ; throw failed_assertion ; } }
00085 #else 
00086 #define ERS_ASSERT(expr,...) { if(!(expr)) { char assertion_buffer[256] ; snprintf(assertion_buffer,sizeof(assertion_buffer), __VA_ARGS__) ; ers::Assertion failed_assertion(ERS_HERE, ers::error,#expr,assertion_buffer,false) ; throw failed_assertion ; } }
00087 #endif
00088 #else 
00089 #define ERS_ASSERT(expr,...) ((void) (expr))
00090 #endif
00091 
00092 #endif
00093 

Generated on Tue Nov 29 22:57:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7