BOSS
7.0.5
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
15
namespace
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
{
25
protected
:
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
);
28
public
:
29
static
const
char
*
const
PRECONDITION_CLASS
;
30
Precondition
();
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
s
XmlRpcServer s
Definition:
HelloServer.cpp:11
ers::Assertion
This Issue represents a basic assertion.
Definition:
Event/ers/ers-00-00-03/ers/Assertion.h:32
ers::Context
Source context for Issue.
Definition:
Event/ers/ers-00-00-03/ers/Context.h:42
ers::Issue::message
const std::string & message() const
Message.
Definition:
ers/ers-00-00-03/src/Issue.cxx:689
ers::Precondition
Precondition issue.
Definition:
Event/ers/ers-00-00-03/ers/Precondition.h:24
ers::Precondition::Precondition
Precondition()
Definition:
Precondition.cxx:24
ers::Precondition::build_message
virtual std::string build_message(const char *condition_text, const std::string &message, bool constant_expression=false)
Definition:
Precondition.cxx:57
ers::Precondition::get_class_name
virtual const char * get_class_name() const
Definition:
Precondition.cxx:48
ers::Precondition::PRECONDITION_CLASS
static const char *const PRECONDITION_CLASS
Definition:
Event/ers/ers-00-00-03/ers/Precondition.h:29
ers
Definition:
Event/ers/ers-00-00-03/ers/Assertion.h:20
ers::severity_t
enum ers::_severity_t severity_t
source
Event
ers
ers-00-00-03
ers
Precondition.h
Generated by
1.9.6