BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/ers-00-00-03/ers/Precondition.h
Go to the documentation of this file.
1/*
2 * Precondition.h
3 * ers
4 *
5 * Created by Matthias Wiesmann on 08.12.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#ifndef ERS_PRECONDITION
11
12#include <stdio.h>
13#include "ers/Assertion.h"
14
15namespace ers {
16
17 /** A precondition is a special type of assertion that checks the entry condition for a function.
18 * Typically, precondition check entry values for function, and members state in object methods
19 * \author Matthias Wiesmann
20 * \version 1.0
21 * \brief Precondition issue.
22 */
23
24 class Precondition : public Assertion {
25protected:
26 virtual std::string build_message(const char* condition_text, const std::string &message, bool constant_expression = false) throw() ;
27 Precondition(const Context &context, severity_t s);
28public:
29 static const char* const PRECONDITION_CLASS ;
31 Precondition(const Context &context, severity_t s, const char*condition, const std::string &message , bool constant_expression=false) ;
32 virtual const char*get_class_name() const throw();
33 } ; // Precondition
34} // ers
35
36
37/** \def ERS_PRECONDITION(expr,msg,params) This macro inserts an assertion than checks condition e,
38 * if e is not true, then an issue of type ers::Asertion is thrown with message m.
39 * If the compiler is gcc, then the transient field of the assertion is set according to the transcience of the expression.
40 * This means that if the expression is detected by the compiler as being constant.
41 * If the macro \c N_DEBUG is defined then the macros are disabled.
42*/
43
44#ifndef N_ERS_ASSERT
45#ifdef __GNUC__
46#define ERS_PRECONDITION(expr,...) { if(!(expr)) { char precondition_buffer[256] ; snprintf(precondition_buffer,256, __VA_ARGS__) ; ers::Precondition failed_precondition(ERS_HERE,ers::error,#expr,precondition_buffer,__builtin_constant_p(expr)) ; throw failed_precondition ; } }
47#else
48#define ERS_PRECONDITION(expr,...) { if(!(expr)) { char precondition_buffer[256] ; snprintf(precondition_buffer,256, __VA_ARGS__) ; ers::Precondition failed_precondition(ERS_HERE,ers::error,#expr,precondition_buffer,false) ; throw failed_precondition ; } }
49#endif
50#else
51#define ERS_PRECONDITION(expr,...)
52#endif
53
54#endif
55
XmlRpcServer s
Definition: HelloServer.cpp:11
This Issue represents a basic assertion.
Source context for Issue.
const std::string & message() const
Message.
virtual std::string build_message(const char *condition_text, const std::string &message, bool constant_expression=false)
virtual const char * get_class_name() const
static const char *const PRECONDITION_CLASS
enum ers::_severity_t severity_t